You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] GLM-5 model pollutes context window with broken thinking output #16903
When using the GLM-5 model (Z.AI), OpenCode's context window gets polluted with broken/malformed thinking output. The terminal displays ? characters scattered throughout the interface, the rendered content becomes garbled, and the TUI layout breaks completely. The context window shows raw thinking tokens that should be hidden or properly parsed.
The GLM 4.7 model works correctly without any of these rendering issues under the same conditions.
Steps to Reproduce
Open OpenCode on Windows (cmd or PowerShell)
Select the GLM-5 (Z.AI Coding Plan) model
Run any task that triggers the model's thinking/reasoning mode (e.g., a build or code generation task)
Observe the terminal output becoming corrupted
Expected Behavior
The context window should display clean, properly formatted output — thinking tokens should be hidden or correctly rendered, just like the GLM 4.7 model does.
Actual Behavior
Multiple ? characters appear throughout the terminal (top, bottom, status bar)
The thinking/reasoning output leaks into the visible context window in a broken/malformed state
The TUI layout breaks — code snippets, markdown, and status indicators become garbled
The status bar at the bottom shows ???■■■■■ instead of proper indicators
The overall context window becomes unusable and filled with noise
Specific observations from the screenshot
The title bar and content area show ? characters on the left margin where they shouldn't be
Code content (Java — EvidenciaRunner.java) is partially rendered but interspersed with broken formatting
The bottom status bar shows: ? Build · glm-5 followed by more ? lines, then ? Build GLM-5 Z.AI Coding Plan
The very bottom shows ???■■■■■ esc interrupt — the progress/status indicators are corrupted
Comparison
Model
Behavior
GLM 4.7
Clean output, no artifacts, thinking is properly handled
The extractReasoningMiddleware was intentionally removed in PR #11270 (v1.1.46+), which means <think> tags are now rendered as plain text instead of being collapsed into reasoning blocks. This causes the context window pollution seen in the screenshot — the GLM-5 thinking output leaks into the visible UI as garbled ? characters and broken formatting.
GLM 4.7 is unaffected because it handles reasoning differently and doesn't produce the same volume of raw <think> tag output.
Potential fix
PR #15382 by @erwinh22 implements the rendering-layer approach: tags are preserved in storage for multi-turn LLM context (respecting the decision in PR #11270), but parsed and rendered as reasoning blocks at display time in TUI, Web UI, and CLI. This PR appears to not have been merged yet.
Reacted by nkosi23, 芙兰朵布丁, Sergey Kostrukov and Gabriel Patzleiner
Try setting the temperature to 1.0 in opencode.json:
"provider": {
"zai-coding-plan": {
"models": {
"glm-5": {
"options": {
"temperature": 1.0
}
},
"glm-5.1": {
"options": {
"temperature": 1.0
}
}
}
}
}
The transform.ts file doesn't have this config yet. With temperature 1.0, GLM-5 and GLM-5.1 feel more stable to me.
its possible to set maximum context window? right now if above 80k is not useful, opencode still mark the context window is 200k so compaction not working and make thinking in a loop
Fixed by merging PR #15389, which renders “think” tags as reasoning blocks.
GLM-5’s thinking output will now be properly displayed in a reasoning block and won’t pollute the context.
Activity
github-actions commentedon Mar 10, 2026
This issue might be a duplicate of existing issues. Please check:
If your issue is distinct from these, feel free to keep it open and provide any additional context that differentiates it.
tayroneoliveira2023 commentedon Mar 10, 2026
Related issues and root cause
After investigating, this issue appears to be directly related to the known problem with
<think>/<thinking>tag handling in OpenCode:<think>and<thinking>tags as reasoning blocks #11439 — Support parsing<think>and<thinking>tags as reasoning blocks (main tracking issue)<think>tag content displayed instead of being collapsed (closed as duplicate of Support parsing<think>and<thinking>tags as reasoning blocks #11439)Root cause
The
extractReasoningMiddlewarewas intentionally removed in PR #11270 (v1.1.46+), which means<think>tags are now rendered as plain text instead of being collapsed into reasoning blocks. This causes the context window pollution seen in the screenshot — the GLM-5 thinking output leaks into the visible UI as garbled?characters and broken formatting.GLM 4.7 is unaffected because it handles reasoning differently and doesn't produce the same volume of raw
<think>tag output.Potential fix
PR #15382 by @erwinh22 implements the rendering-layer approach: tags are preserved in storage for multi-turn LLM context (respecting the decision in PR #11270), but parsed and rendered as reasoning blocks at display time in TUI, Web UI, and CLI. This PR appears to not have been merged yet.
tareko commentedon Mar 27, 2026
This seems to still exist in GLM-5.1, and essentially makes opencode unusable.
toninho09 commentedon Apr 1, 2026
Try setting the temperature to 1.0 in
opencode.json:The transform.ts file doesn't have this config yet. With temperature 1.0, GLM-5 and GLM-5.1 feel more stable to me.
sa-altaiftech commentedon Apr 3, 2026
its possible to set maximum context window? right now if above 80k is not useful, opencode still mark the context window is 200k so compaction not working and make thinking in a loop
jumski commentedon Apr 6, 2026
Same for me - GLM 5.1 is also broken and unusable.
Silur commentedon Apr 8, 2026
Actual outputs of GLM5.1 from opencode:
ShibuyaCyana commentedon Apr 8, 2026
According to this Reddit post it seems also happening in Claude code.
So there seems to be two separate problems:
fix: render think tags as reasoning blocks + fix MCP MaxListeners ove…
saurav-shakya commentedon Apr 10, 2026
Fixed by merging PR #15389, which renders “think” tags as reasoning blocks.
GLM-5’s thinking output will now be properly displayed in a reasoning block and won’t pollute the context.
fix: disable thinking/reasoning during compaction summarization
github-actions commentedon Jul 4, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.