feat: generate semantic session titles via Anthropic API - #983
Open
nikita-ashihmin wants to merge 3 commits into
Open
feat: generate semantic session titles via Anthropic API#983nikita-ashihmin wants to merge 3 commits into
nikita-ashihmin wants to merge 3 commits into
Conversation
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The Claude Code SDK sets
session.summaryto 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:
session_info_updatewas forwarding the SDK summary (last user message) rather than a semantic label.loadSessiondid not callmaybeUpdateSessionTitle, so the correct title only arrived after the next inventory refresh (up to 60s later).Changes
Semantic title generation (
generateSemanticTitle)session_state_changed: idle), callsclaude-haiku-4-5-20251001with the first user message (IDE context block stripped) to produce a concise 3–6 word title.session.titleGenerationAttemptedso subsequent turns do not re-generate.ANTHROPIC_API_KEYis 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 summaryEager title push on
loadSessionCalls
maybeUpdateSessionTitlebefore history replay so:backfillDerivedTitleIfNeededruns during history replay, so the guard (projection.thread.title == agentDisplayName) fails and the first-user-message fallback never fires.Test plan
/rename My title— custom title wins and persists across turnsANTHROPIC_API_KEY(Bedrock/Vertex) — tab still shows something (last user message fallback), no errors