description: "Log-backed session titles for users and maintainers choosing a title source, configuring the service, or debugging title state."
English | 中文
Use dsh-session-title to give each session a client-visible title from the first eligible human message, an optional asynchronous generator, or an explicit user rename. Accepted titles persist through replay, resume, and paging but never enter model input. Automatic generation never delays the main agent response, and newer title requests supersede older work. Choose the package when clients need durable titles with configurable length limits and a deliberate refresh() path for regenerating them.
Mount the service to give sessions titles that clients can display and that never reach the model. The common path is explicit: load the session store, mount the service with its required limits, and optionally mount one provider plugin.
Titles come from three sources, newest wins. The built-in fallback derives from the first eligible human message's leading words within the configured caps; a registered provider generates a title over eligible messages; an explicit rename() accepts a user-supplied title. Only text blocks from human user/message events are eligible, and empty or non-text prompts wait for later eligible input. A user-sourced latest title pins the session — later user messages schedule no automatic revision, and an explicit refresh() remains the deliberate unpin.
All limits are required; the library supplies no defaults. Mount the service with the three bounds:
- name: '@deepseek-ai/dsh-session'
- name: '@deepseek-ai/dsh-session-title'
config:
fallbackMaxWords: 8
fallbackMaxBytes: 96
maxTitleBytes: 120
| Field | Default | Meaning |
|---|---|---|
fallbackMaxWords |
required | Maximum whitespace-delimited words in the deterministic fallback |
fallbackMaxBytes |
required | Maximum UTF-8 bytes in the fallback; must not exceed maxTitleBytes |
maxTitleBytes |
required | Maximum UTF-8 bytes accepted from any source |
The generated configuration catalog is the exhaustive source for every accepted field and its JSDoc.
One optional asynchronous provider may be registered through ctx.sessionTitle.register(provider); a second registration throws. The shipped model-backed providers are first-prompt and all-prompts, both using the shared LLM generation policy. A provider starts only after a marked loop-built request's exact route matches the logged request/header, and a newer revision supersedes and aborts older work.
get(session) reads the latest folded title from one live or replayed session, and foldSessionTitle(events) is the pure fold over a log. The service requires ctx.sessionProjections and registers two units: the client-visible title unit (the accepted title string for client list rows) and the host-only titleInput unit, which folds the first and latest eligible messages plus their count so scheduling and fallback reads are O(1) through stateOf(); the full eligible prefix for one provider generation is scanned from the session log at execution time. An explicit refresh(session) materializes the fallback when needed, then explicitly runs the registered provider over the current eligible messages.
Automatic failures warn and retain the latest title; explicit refresh() rejects on provider error or caller cancellation, and cancellation does not roll back an already accepted fallback event. Automatic work never delays the main agent response, its late completion appends a standalone log-only event without opening a turn, and a stale completion cannot append. Forks inherit title events in their seed unchanged.
Read these pages when the service contract is not enough. They move from the subsystem reference to the model-backed providers that plug in here.
Nothing. session/title is log-only and never enters the session surface, deriveMessages(), system prompt, tool schemas, or request prefix.
The fallback and accepted provider revisions add zero tokens to the main agent request. An optional provider's separate auxiliary request is documented by that provider package.
None for the main request; title events do not change its reconstructed content or cache key.
These limits define what the title service does not provide. They are current package constraints.
refresh, search, and list indexing are outside this service.