GeezerVison is showing github.com — [BUG] GLM-5 model pollutes context window with broken thinking output · Issue #16903 · anomalyco/opencode
[BUG] GLM-5 model pollutes context window with broken thinking output #16903DescriptionDescription
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 |
| GLM-5 |
Broken thinking tokens leak into context window, ? characters everywhere, TUI breaks |
Environment
- OS: Windows 10/11
- Terminal: cmd / PowerShell
- OpenCode version: Latest
- Model: GLM-5 (Z.AI Coding Plan)
Screenshot

- I have verified that this issue has not already been requested
- I have read the contributing guidelines
Reacted by nkosi23, Gabriel Patzleiner, Antonio H L Santos, Eddie and Charles Arnault Activitygithub-actions commented on 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 commented on 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:
Root cause
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 tareko commented on Mar 27, 2026 This seems to still exist in GLM-5.1, and essentially makes opencode unusable. Reacted by Iago S., Marcin Wojcik, Antonio H L Santos, Anderson Joseph, Robin Fröhlich, Silur and Ben Wibking toninho09 commented on Apr 1, 2026 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. sa-altaiftech commented on Apr 3, 2026
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 jumski commented on Apr 6, 2026 Same for me - GLM 5.1 is also broken and unusable. Silur commented on Apr 8, 2026 ShibuyaCyana commented on Apr 8, 2026 According to this Reddit post it seems also happening in Claude code.
So there seems to be two separate problems:
- OpenCode parsing for GLM models are broken;
- GLM models themselves are degrading, probably due to they've been overly quantized.
added a commit that references this issue on Apr 10, 2026This issue will close once commit fc36b7c is merged into the 'dev' branch.fc36b7c saurav-shakya commented on 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. Reacted by Wojtek Majewski and Stefan Schwarzer github-actions commented on 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.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|