Skip to content

Session titles are never generated for sdk-ts sessions (only the first prompt is forwarded) #861

Description

@rkage

Session titles are never generated for sdk-ts sessions (only the first prompt is forwarded)

Running Claude Code through this adapter in Zed, thread titles always show the first user prompt rather than a generated summary. The same account/model via claude --resume on the CLI shows proper titles, so it's not the model or proxy.

The cause is that title generation only runs in the interactive CLI. For SDK-hosted sessions (entrypoint: sdk-ts, i.e. this adapter) the SDK doesn't auto-generate a title — it only generates one when the host explicitly sends the generate_session_title control request. The adapter never sends it, so getSessionInfo().summary stays as the first-prompt fallback, and that's what maybeUpdateSessionTitle() forwards.

#383 added the session_info_update forwarding on the assumption that session.summary is already an SDK-generated summary. That holds for CLI sessions but not SDK ones, so the forwarding works but there's nothing real to forward.

Evidence from my local ~/.claude/projects/<proj>/*.jsonl, correlating entrypoint with the presence of a "type":"ai-title" record:

  • cli sessions: all have generated titles
  • sdk-ts sessions (this adapter): 0 have them

And generate_session_title doesn't appear anywhere in src/.

The SDK exposes generation as a method on the query object:

generateSessionTitle(description, { persist }) // => Promise<string>

Proposed fix: in maybeUpdateSessionTitle(), if getSessionInfo() returns no customTitle/aiTitle, call generateSessionTitle(firstPrompt, { persist: true }) and forward the result via the existing path. It persists as a durable record, so it's one-shot per session, not per-turn.

Worth gating to interactive sessions so headless/CI SDK users don't get a title model-call on every run — which is likely why the SDK leaves generation to the host in the first place.

(#819 is manual rename — related but separate. Minor aside: generateSessionTitle is on the runtime query object but missing from the Query interface in sdk.d.ts.)

Env: adapter 0.58.1, claude-agent-sdk 0.3.205, Zed, macOS arm64.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions