fix: strip literal <think> tags leaking into OpenCode response text#516
Merged
Conversation
Kimi k2.7 (ollama-cloud) sometimes wraps chain-of-thought in literal <think>...</think> tags inside a visible text part, so part-kind classification can't hide it. Add a streaming-safe filter that strips the tags and routes their contents to the reasoning buffer, handling tags split across deltas. Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
alari76
force-pushed
the
fix/opencode-strip-think-tags
branch
from
June 14, 2026 10:19
7d518a3 to
2ea75b5
Compare
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
<think>...</think>tags inside a visible text part, so the existing part-kind classification (PR fix: use correct REST endpoint to classify OpenCode reasoning parts #515) can't hide it — the reasoning prose and a stray</think>tag showed up in the response.server/opencode-process.tsthat strips<think>...</think>content (routing it to the reasoning/thinking buffer) and correctly handles tags split across multiple streaming deltas (e.g.<thi+nk>).Test plan
npm test(server) — 99 tests pass, incl. two new regression tests:<think>...</think>emitted inside a single text part<think>tags split across multiple deltasnpm run build(typecheck) passes<think>tags or reasoning prose in the transcript🤖 Generated with Claude Code