Repository navigation
AH: refine session title from first turn context - #322131
Merged
Benjamin Christopher Simmonds (benibenj) merged 1 commit intoJun 19, 2026
Merged
Benjamin Christopher Simmonds (benibenj) merged 1 commit into
Benjamin Christopher Simmonds (benibenj) merged 1 commit into
Conversation
After the first turn completes, regenerate the auto-generated session title using the first-turn context (user request + agent text response) via the gpt-4o-mini utility model, but only when the title has not been changed in the meantime (manual /rename, user edit, or forked title all suppress it). Only normal markdown text response parts are considered (tool calls, reasoning, and other parts are ignored). The user's first request is always included; the context is capped at 20000 chars by truncating the middle with an ellipsis marker. Co-authored-by: Copilot <[email protected]>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves agent-host session title generation by upgrading the initially seeded title (from the first user message) after the first turn completes, using richer first-turn context (user request + agent text response) while avoiding clobbering user-edited titles.
Changes:
- Add
AgentHostSessionTitleController.refineTitleFromFirstTurn(...)to regenerate the title from first-turn textual context with a capped/truncated prompt. - Invoke refinement from
AgentSideEffects._runTurnCompleteSideEffectsafter turn completion, including support for additional chat channels. - Add unit tests covering refinement behavior, no-clobber semantics, text-only filtering, and middle-truncation.
Show a summary per file
| File | Description |
|---|---|
| src/vs/platform/agentHost/test/node/agentHostSessionTitleController.test.ts | Adds unit tests for first-turn title refinement, filtering, and truncation behavior. |
| src/vs/platform/agentHost/node/agentSideEffects.ts | Triggers title refinement after turn completion, routing additional chat channels correctly. |
| src/vs/platform/agentHost/node/agentHostSessionTitleController.ts | Implements first-turn context construction, middle-truncation, and last-applied-title tracking to avoid clobbering. |
Copilot's findings
- Files reviewed: 3/3 changed files
- Comments generated: 0
Connor Peet (connor4312)
approved these changes
Jun 19, 2026
Benjamin Christopher Simmonds (benibenj)
merged commit Jun 19, 2026
d689633
into
main
26 checks passed
Benjamin Christopher Simmonds (benibenj)
deleted the
agents/session-title-generation-models-2e4c284a
branch
June 19, 2026 18:32
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
AH: refine session title from first turn context
What
After the first turn of an agent-host session completes, the auto-generated
session title is regenerated using the full first-turn context (the user's
request plus the agent's text response) instead of just the opening message.
This builds on the existing first-message title seeding: the title is still
seeded immediately from the first user message, then upgraded once the first
turn finishes and there is real conversation context to summarize.
Details
AgentHostSessionTitleController.refineTitleFromFirstTurn(channel, chatChannel?),invoked from
AgentSideEffects._runTurnCompleteSideEffectson turn complete.matches the one this controller last applied — a manual
/rename, a useredit, or a forked session's inherited title all suppress it (tracked via a
new
_lastAppliedTitlemap).reasoning/thinking, content refs, and system notifications are ignored.
removed and replaced with an ellipsis marker, preserving head and tail.
(gpt-4o-mini), with the prompt phrased for a "conversation" when refining.
Testing
npm run typecheck-clientpasses; ESLint clean on changed files.agentHostSessionTitleController.test.tscovering:regeneration from first-turn context, no-clobber after a manual rename,
text-only filtering (tool calls / reasoning ignored), and middle-truncation
of oversized responses.
Note: the in-repo Electron unit-test runner could not be executed locally
because the full
out/build is currently blocked by a missingesbuildinthe extensions'
node_modules(a pre-existing environment gap). Thetruncation/context algorithm was additionally validated with a standalone
reproduction.