Skip to content

Session Title

pawaca edited this page Aug 30, 2026 · 2 revisions

Session Title

Edge adaptation of the upstream session title generation system.

Upstream reference: Session Title documentation

What Upstream Provides

The Session Title manages persistent, write-once-override title state for sessions. It consists of two plugins:

  • SessionTitleService (ctx.sessionTitle) — maintains log-backed title state. Titles come from three sources: explicit user rename (pins the title, stops auto-generation), a registered provider, or a fallback (first N words of the first prompt). Appends session/title events to the session log.
  • FirstPromptTitle — a title provider that generates a concise title from the first user prompt via a lightweight LLM call. Configured with target word count, CJK character count, input byte limit, and timeout.

The title is also registered as a 'title' projection definition in SessionProjectionRegistry, enabling it to be pushed to clients via the standard projection mechanism.

What Edge Changed

Direct Reuse Both plugins

SessionTitleService and FirstPromptTitle are installed as-is with Edge-specific configuration:

  • fallbackMaxWords: 8, maxTitleBytes: 640 — title length limits
  • targetWords: 6, targetCjkCharacters: 12 — LLM generation targets
  • maxInputBytes: 4096, maxOutputTokens: 32, timeoutMs: 10_000 — LLM call bounds
  • provider: 'deepseek-official', model: 'deepseek-v4-flash' — uses the same DeepSeek provider configured for the main agent

Transport Bridge Title projection push

Title changes flow through the generic onChanged projection bridge — the same mechanism that delivers goal and all other projection keys. When SessionTitleService appends a session/title event, the projection registry computes the new title value, onChanged buffers it, and publishSessionEvent drains it as a WebSocket frame after flush.

What Edge Did NOT Change

  • Title state management (log-backed fold, user rename pinning, provider cadence)
  • LLM-based title generation logic and prompt construction
  • Fallback title derivation from first prompt text
  • session/title event format and semantics
  • Title projection definition and its participation in SessionProjectionCache

Performance Characteristics

Title generation latency

FirstPromptTitle generates titles asynchronously after the first user prompt. The LLM call is bounded at 32 output tokens with a 10-second timeout. It runs independently of the agent turn — the session can start responding before the title is ready. When the title arrives, it appends a session/title event, which triggers the projection push to update the browser's sidebar.

Cold-session title

Title is part of the projection cache managed by upstream SessionProjectionCache. Cold sessions serve the title from the cached snapshot or materialized summary — no event replay needed. The dsh_session_summaries table also stores the latest title event data for the session list.

Architecture Summary

| Component | Category | Edge Code |

|---|---|---|

| SessionTitleService | Reuse | One ctx.plugin() call with config |

| FirstPromptTitle | Reuse | One ctx.plugin() call with config |

| Title projection push | Bridge | Generic projection bridge |

Key observation: Title generation is fully upstream — Edge only provides configuration values and the generic projection bridge. The LLM call, fallback logic, and rename handling are upstream code. Title is one of the projections that proved the generic bridge works: the same onChanged mechanism serves goal, title, and any future projection key without per-key adapter code.

English

中文

Clone this wiki locally