fix: surface reasoning as collapsible thinking parts in Copilot Chat (#22, #71)#72
Merged
Merged
Conversation
- Stream reasoning chunks via the proposed `LanguageModelThinkingPart` API. - Extend OpenAI and Anthropic response extractors to handle reasoning emission. - Add runtime guards to safely fall back to legacy text behavior on older hosts. - Retain tool-call replication and think-tag filtering compatibility. - Add type augmentation for the proposed VS Code API. - Update changelog, devlog, and issue research documentation. Fixes #22 Fixes #71
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.
Summary
Reasoning content from OpenCode models (DeepSeek, Kimi, GLM, Qwen, MiniMax, MiMo) is now streamed live to the Copilot Chat UI as collapsible thinking blocks via the proposed
LanguageModelThinkingPartAPI. This makeschat.agent.thinkingStyle(collapsed/collapsedPreview/fixedScrolling) work for OpenCode BYOK models, matching the behavior of Copilot-hosted models.Previously, reasoning was accumulated internally but never emitted as a thinking part — so it either appeared as flat plain text or was silently dropped when text/tool calls were present.
Background
Issues #22 and #71 are duplicates reporting the same bug. The previous conclusion (doc
23-*, 2026-06-15) was that this was blocked on upstreammicrosoft/vscode#318211. Deep-dive research found that conclusion was wrong:LanguageModelThinkingParthas been available at runtime since VS Code ~1.102 (Aug 2025), well within our^1.125.0floor. A shipping Marketplace extension (Vizards/deepseek-v4-for-copilot) already solved this exact problem — proving the approach works withoutenabledApiProposals.Full investigation:
docs/issues/33-20260709-thinking-part-byok-surfacing-research.mdChanges
src/vscode.proposed.languageModelThinkingPart.d.ts(NEW)LanguageModelThinkingPartclass (copied from VS Code reposrc/vscode-dts/vscode.proposed.languageModelThinkingPart.d.ts).src/streaming.ts(+202 / -17 lines)thinkingPartConstructormodule-level constant (runtime guard) +emitThinkingPart()helper.OpenAiResponseExtractorandAnthropicResponseExtractorconstructors to acceptprogress+localRequestId.handleReasoning()method to both extractors: accumulates reasoning for tool-call replication AND streams it live viaLanguageModelThinkingPart.this.reasoningContent +=sites withthis.handleReasoning().flushReasoningFallback()methods to early-return when the thinking part API is available.streamChatCompletions,streamAnthropicMessages,streamResponsesApi,streamGoogleGenerateContent).extractChatCompletionParts,extractAnthropicParts) to emit via thinking part for consistency.totalReasoningCharsmonotonic counter for accurate[stream-summary]log metrics.Not changed (by design):
package.json— noenabledApiProposals(proven unnecessary).onReasoningContentcallback wiring — tool-call replication intact.opencodego.stripThinkTags— composes with the new surfacing.Verification
npm run compile→ pass (exit 0)npx tsc --noEmit --strict→ pass (exit 0)chat.agent.thinkingStylerespected. Tool-call replication intact.Coverage
All 4 transports covered in both streaming + non-stream paths:
Fixes #22
Fixes #71