Skip to content

feat: generate semantic session titles via Anthropic API - #983

Open
nikita-ashihmin wants to merge 3 commits into
mainfrom
feat/semantic-session-titles
Open

feat: generate semantic session titles via Anthropic API#983
nikita-ashihmin wants to merge 3 commits into
mainfrom
feat/semantic-session-titles

Conversation

@nikita-ashihmin

Copy link
Copy Markdown
Collaborator

Problem

The Claude Code SDK sets session.summary to the last user message after each turn. As a result, editor tabs in AIR always showed raw prompt text (e.g. "продолжи", "смотри plugins/air...") instead of a meaningful title.

Two separate issues contributed:

  1. Wrong title sourcesession_info_update was forwarding the SDK summary (last user message) rather than a semantic label.
  2. Delayed update on openloadSession did not call maybeUpdateSessionTitle, so the correct title only arrived after the next inventory refresh (up to 60s later).

Changes

Semantic title generation (generateSemanticTitle)

  • After the first turn ends (session_state_changed: idle), calls claude-haiku-4-5-20251001 with the first user message (IDE context block stripped) to produce a concise 3–6 word title.
  • Sets session.titleGenerationAttempted so subsequent turns do not re-generate.
  • Only runs when ANTHROPIC_API_KEY is present; Bedrock/Vertex/gateway setups fall back silently to the existing behaviour (last user message).

Title priority in maybeUpdateSessionTitle

/rename (customTitle) > AI-generated title > SDK summary

Eager title push on loadSession

Calls maybeUpdateSessionTitle before history replay so:

  • The tab shows the current title immediately on open, without waiting for inventory refresh.
  • The title arrives at the AIR backend before backfillDerivedTitleIfNeeded runs during history replay, so the guard (projection.thread.title == agentDisplayName) fails and the first-user-message fallback never fires.

Test plan

  • Open a new session, send a message — after the first turn the tab title should be a short semantic label (e.g. "Fix auth bug") rather than the prompt text
  • Open an existing session from the session list — title appears immediately, not after 60 s
  • Run /rename My title — custom title wins and persists across turns
  • Run with no ANTHROPIC_API_KEY (Bedrock/Vertex) — tab still shows something (last user message fallback), no errors

nikita-ashihmin and others added 3 commits August 10, 2026 23:56
When the SDK marks the "default" model entry with a `resolvedModel`,
`buildConfigOptions` now fills the option's `description` with the
human-readable name of the matching named model (e.g. "Claude Sonnet 5")
so clients can display it instead of a bare "Default".

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The SDK's session summary is set to the last user message after each
turn, so editor tabs always showed the raw prompt text instead of a
meaningful label. This change:

- Calls claude-haiku after the first turn to generate a concise 3–6 word
  title from the first user message (IDE context block stripped)
- Prefers the generated title over the SDK summary in session_info_update
  (user /rename still wins)
- Eager-pushes the title in loadSession before history replay, so tabs
  update immediately on open instead of waiting for inventory refresh
- Skips title generation silently when ANTHROPIC_API_KEY is absent
  (Bedrock/Vertex/gateway setups fall back to existing behaviour)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant