Skip to content

agentHost: render completed reasoning fallback - #332054

Open
Silence (silence48) wants to merge 3 commits into
microsoft:mainfrom
silence48:codex/agent-host-reasoning-fallback
Open

agentHost: render completed reasoning fallback#332054
Silence (silence48) wants to merge 3 commits into
microsoft:mainfrom
silence48:codex/agent-host-reasoning-fallback

Conversation

@silence48

Copy link
Copy Markdown

Summary

  • render completed Copilot CLI reasoning when no non-empty assistant.reasoning_delta created a live reasoning part
  • use assistant.message.reasoningText as the final fallback, matching restored-session behavior
  • preserve parent/subagent routing and existing tool-round response-part boundaries
  • suppress completed-event duplication after a successful delta stream and ignore empty transport deltas

Fixes #332053

Why

The live Agent Host adapter already renders assistant.reasoning_delta, but its assistant.reasoning handler only logs the completed text. The assistant.message handler likewise treats reasoningText as history-only even though the restored-session mapper renders it. Providers or SDK paths that emit only the completed form therefore persist a readable summary that never appears live.

The existing reasoningPartIds map already tracks the current parent/subagent reasoning scope and is cleared at tool-call boundaries. This change uses that state as a fail-safe fallback gate instead of adding a parallel lifecycle tracker.

Tests

Added focused regression coverage for:

  • completed reasoning after no non-empty delta
  • no duplicate after streamed reasoning
  • assistant.message.reasoningText fallback ordering before markdown
  • completed subagent reasoning routing

git diff --check passes. The full repository test suite is left to CI because this branch was prepared from a dependency-free sparse checkout.

Related: #312559, #328146, #329873, #330279.

AI-assisted implementation and description.

Copilot AI balanced review requested due to automatic review settings August 21, 2026 22:17

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

Adds live fallback rendering for completed Copilot CLI reasoning when streaming deltas are unavailable.

Changes:

  • Renders completed reasoning from reasoning events and message history fields.
  • Ignores empty reasoning deltas and preserves subagent routing.
  • Adds focused regression tests.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
copilotAgentSession.ts Implements completed-reasoning fallback behavior.
copilotAgentSession.test.ts Covers fallback, deduplication, ordering, and routing.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/vs/platform/agentHost/node/copilot/copilotAgentSession.ts
@silence48
Silence (silence48) force-pushed the codex/agent-host-reasoning-fallback branch from 57d0a74 to d9d317b Compare August 21, 2026 22:26
@silence48

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.

@silence48
Silence (silence48) marked this pull request as ready for review August 21, 2026 22:59

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Suppressed comments (1)

src/vs/platform/agentHost/node/copilot/copilotAgentSession.ts:1685

  • The SDK's documented turn order is assistant.reasoning_deltaassistant.reasoningassistant.message, but the completed handler removes the reasoning ID from this map before the message arrives. The subsequent message therefore sees no streamed state and emits reasoningText again, duplicating both streamed and completion-only reasoning in the normal event order. Keep prior rendered/completed reasoning state through the message boundary (and correlate it with the message fallback), then add a regression using the documented order.
		const streamedSinceLastMessage = turn.pendingReasoningDeltaIds.get(reasoningScope);
		turn.pendingReasoningDeltaIds.delete(reasoningScope);
		turn.pendingMessageReasoningFallbacks.delete(reasoningScope);
		if (!content || streamedSinceLastMessage?.size) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Approved. The fix is minimal and correct.

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.

Agent Host drops completed Copilot CLI reasoning when delta events are absent

4 participants