Skip to content

AH: refine session title from first turn context - #322131

Merged
Benjamin Christopher Simmonds (benibenj) merged 1 commit into
mainfrom
agents/session-title-generation-models-2e4c284a
Jun 19, 2026
Merged

Benjamin Christopher Simmonds (benibenj) merged 1 commit into
mainfrom
agents/session-title-generation-models-2e4c284a

Conversation

@benibenj

Copy link
Copy Markdown
Contributor

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

  • New AgentHostSessionTitleController.refineTitleFromFirstTurn(channel, chatChannel?),
    invoked from AgentSideEffects._runTurnCompleteSideEffects on turn complete.
  • Runs only for the very first turn, and only when the current title still
    matches the one this controller last applied — a manual /rename, a user
    edit, or a forked session's inherited title all suppress it (tracked via a
    new _lastAppliedTitle map).
  • Context building:
    • The user's first request is always included.
    • Only normal markdown text response parts are considered — tool calls,
      reasoning/thinking, content refs, and system notifications are ignored.
    • The context is capped at 20,000 characters; oversized text has its middle
      removed and replaced with an ellipsis marker, preserving head and tail.
  • Uses the same utility completion path as the existing title generation
    (gpt-4o-mini), with the prompt phrased for a "conversation" when refining.

Testing

  • npm run typecheck-client passes; ESLint clean on changed files.
  • Added unit tests in agentHostSessionTitleController.test.ts covering:
    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 missing esbuild in
the extensions' node_modules (a pre-existing environment gap). The
truncation/context algorithm was additionally validated with a standalone
reproduction.

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]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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._runTurnCompleteSideEffects after 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

@benibenj
Benjamin Christopher Simmonds (benibenj) merged commit d689633 into main Jun 19, 2026
26 checks passed
@benibenj
Benjamin Christopher Simmonds (benibenj) deleted the agents/session-title-generation-models-2e4c284a branch June 19, 2026 18:32
@vs-code-engineering vs-code-engineering Bot added this to the 1.126.0 milestone Jun 19, 2026
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Aug 3, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants