Agent Host drops completed Copilot CLI reasoning when delta events are absent
- Dominant language
- TypeScript
- Stars
- 193k
- Forks
- 42.4k
- PR merge metrics
- PR metrics pending
Description
### Type of issue
Bug
### Environment
- VS Code 1.133.0 on macOS
- Agent Host using the Copilot CLI provider
- Built-in Custom Endpoint BYOK model
- `apiType: "responses"`, `thinking: true`
- No third-party chat extension
### Description
Reasoning summaries can be generated and persisted by the Copilot CLI session but remain absent from the live Agent Host UI. During an affected turn, the UI shows the generic "Considering"/"Reasoning" status and tool calls, but no readable reasoning summary. Reopening the persisted session can expose the missing reasoning.
This occurs when the SDK supplies completed reasoning (`assistant.reasoning`, or `assistant.message.reasoningText`) without usable `assistant.reasoning_delta` events.
### Steps to reproduce
1. Configure a reasoning-capable BYOK model through `chatLanguageModels.json` using the Responses API.
2. Open the Agents window with Agent Host preferred.
3. Start a turn that produces reasoning and tool calls.
4. Observe that tool calls render live, while readable reasoning does not.
5. Reopen or restore the same session and observe that the persisted reasoning may then appear.
### Expected
- `assistant.reasoning_delta` should continue to stream live when available.
- If no non-empty reasoning delta was rendered for the current parent/subagent scope, non-empty completed `assistant.reasoning` (or final `assistant.message.reasoningText`) should be emitted once as `ResponsePartKind.Reasoning`.
- The completed fallback must not duplicate reasoning when deltas were already rendered.
- Parent and subagent reasoning must remain scoped to the correct response part.
### Actual / code path
`CopilotSessionWrapper` exposes both `assistant.reasoning_delta` and `assistant.reasoning`.
In `src/vs/platform/agentHost/node/copilot/copilotAgentSession.ts`:
- `wrapper.onReasoningDelta(...)` calls `_emitReasoningDelta(...)` and renders live reasoning.
- `wrapper.onReasoning(...)` only logs the completed reasoning length.
- The live `wrapper.onMessage(...)` path renders `data.content` but does not use `data.reasoningText` as a fallback.
- The restored-session path does understand `reasoningText`.
As a result, completed reasoning can be generated and persisted but dropped specifically by the live Copilot CLI to Agent Host adapter whenever the delta event path is absent or empty.
### Suggested fix
Use the existing per-turn, per-parent/subagent reasoning-part state to render completed reasoning only when no non-empty delta created a live reasoning part. Ignore empty transport deltas, preserve tool-round boundaries, and add regression coverage for completed-event fallback, message fallback, no duplication, and subagent routing.
### Related work
- #312559 fixed reasoning rendering for **restored** Agent Host sessions.
- #328146 introduced Responses API handling for Agent Host BYOK models.
- #329873 / #330279 fixed a separate BYOK reasoning-chunk aggregation/rendering problem.
Those changes establish the relevant paths, but they do not cover the missing live completed-reasoning fallback described here.
Contributor guide
Assessment
This issue has not been assessed yet.