description: "Shared model-backed title generation policy for users and maintainers configuring title providers or debugging auxiliary LLM requests."
English | 中文
dsh-session-title-llm generates concise session titles from selected human messages with a consistent model request policy. Callers choose which messages contribute to each revision and may either supply a provider and model route together or use the route recorded for the current session. Required limits cap the framed input, generated output, and end-to-end duration, while caller cancellation remains effective throughout streaming. Invalid, empty, late, tool-call, or otherwise non-text results are rejected before they can replace a title.
As a deployment, configure this policy through the first-prompt or all-prompts provider plugin. As a provider author, register through the shared helper instead of hand-rolling generation.
A provider plugin calls registerSessionTitleLlmProvider(ctx, config, id, automatic, selectMessages); the helper validates the shared config, registers the provider on ctx.sessionTitle, and runs every generation through the shared policy. The two shipped plugins register the first-prompt and all-prompts cadences with their message selectors, and a second registration on the service throws.
provider and model overrides are optional but must be supplied together as non-empty strings. Without that pair, the helper uses the exact provider/model route captured from the current session's logged request/header, so an explicit refresh before any route exists needs overrides. The helper measures the final JSON-framed user prompt against maxInputBytes before logging or dispatch instead of truncating it, and rechecks timeout and caller cancellation while consuming the stream and after it completes, so a late successful result cannot be accepted even if an interceptor or adapter ignores abort. Malformed or empty output, tool calls, and non-stop finish reasons reject; the session-title service decides whether that rejection is an automatic warning or an explicit caller failure.
Every field is required except the paired route override; there are no library defaults.
| Key | Default | Meaning |
|---|---|---|
targetWords |
required | Target word count for non-CJK titles |
targetCjkCharacters |
required | Target character count for Chinese, Japanese, or Korean titles |
maxInputBytes |
required | UTF-8 byte ceiling for the final JSON-framed user prompt |
maxOutputTokens |
required | Auxiliary generation token cap |
timeoutMs |
required | End-to-end deadline within the runtime timer limit |
provider, model |
optional | Explicit route; both or neither |
Read these pages when the generation policy is not enough. They move from the service it plugs into to the provider plugins that consume it.
The title model receives a fixed system instruction to return one concise unadorned title in the input language, including the configured word and CJK-character targets. Its one user message contains a JSON array of the exact selected human messages and their seqs.
The auxiliary request consumes tokens according to selected input size and maxOutputTokens. It is separate from the main agent request and does not add title text or framing to agent history. DeepSeek title calls disable thinking; the main conversation retains its configured thinking mode.
No main-request invalidation. Auxiliary cache reuse is provider-specific; the fixed instruction is reusable while the JSON message array changes with each revision.
These limits define the accepted generation shapes. They are current package constraints.
Runtime invariant: No companion is published. This stateless helper validates and freezes each auxiliary request before dispatch; deadline, stream, cited message seqs, and provider/model fields are checked synchronously and by tests.