fix(copilot): stop Requesty/GLM reasoning leaking into content + artifacts - #1
Merged
Merged
Conversation
Initialize OpenSpec (spec-driven) and gitignore .claude/ (local Claude
Code state). Add the change 'fix-requesty-reasoning-leak' (proposal,
design, specs, tasks) for capability copilot-reasoning-separation:
isolate model reasoning ("thinking") from content and artifact text.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…acts Add ThinkTagSplitter (stateful, chunk-boundary-tolerant) + stripThinkTags. Wire it into the native adapter: streamText/streamObject route inline <think>…</think> onto the reasoning channel; text() excludes reasoning (emitReasoning:false). extractTextResponse now keeps only text parts and strips inline <think> from them, so code_artifact HTML is reasoning-free whether the model separates reasoning natively or emits it inline (e.g. GLM via Requesty). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Splitter: basic/multiple blocks, split-at-every-offset invariance, unterminated/partial tags, think-free passthrough. Integration: streamText/streamObject route inline <think> to the reasoning channel with clean content, text() excludes reasoning, extractTextResponse drops reasoning + strips inline tags, and code_artifact HTML is reasoning-free. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Why
Models via the Requesty router (notably GLM 5.2) emit chain-of-thought inline as
<think>…</think>inside the content stream, not a separate reasoning field. Nothing separated it, so the thinking text was baked into generated HTML artifacts (visible in the preview). A second latent defect folded even natively-separated reasoning into the artifact text.What changed
ThinkTagSplitter(providers/reasoning.ts) — stateful, chunk-boundary-tolerant splitter +stripThinkTags.native-adapter.ts—streamText/streamObjectroute inline<think>onto the reasoning channel;text()excludes reasoning (emitReasoning:false).native-execution-engine.ts—extractTextResponsekeeps onlytextparts and strips inline<think>from them (this is the pathcode_artifactuses).Net:
code_artifactHTML is reasoning-free whether the model separates reasoning natively or inline. Reasoning still surfaces on its own channel for display.Scope / decisions
<think>only) — no-op for providers that separate natively.model_registry.rsreasoning flag: deferred (the splitter is the provider-agnostic safety net).affine_doc_loader/llm_adaptercrates.Verification
tsx: 58 splitter + 13 integration assertions green (streamText/streamObject/text/extractTextResponse/code_artifact), cleantsc --noEmit.OpenSpec change:
openspec/changes/fix-requesty-reasoning-leak.🤖 Generated with Claude Code