GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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 #16903

New issue
Copy link
New issue
Copy link
Closed as not planned
Closed as not planned
[BUG] GLM-5 model pollutes context window with broken thinking output#16903
Copy link
Assignees
kommander

Description

@tayroneoliveira2023
tayroneoliveira2023
opened on Mar 10, 2026
Issue body actions

Description

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

  1. Open OpenCode on Windows (cmd or PowerShell)
  2. Select the GLM-5 (Z.AI Coding Plan) model
  3. Run any task that triggers the model's thinking/reasoning mode (e.g., a build or code generation task)
  4. 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

OpenCode GLM-5 broken thinking output


  • 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

Activity

  1. github-actions
    assigned
    kommander
    on Mar 10, 2026
  2. github-actions
    added
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    windows
    on Mar 10, 2026
  3. github-actions commented on Mar 10, 2026

    @github-actions
    github-actionsBot
    on Mar 10, 2026 – with GitHub Actions
    Contributor
    More actions

    This issue might be a duplicate of existing issues. Please check:

    • Last token cut off in thinking (windows) #11194: Last token cut off in thinking (windows) — similar symptom of thinking tokens not rendering properly on Windows
    • Error "reasoning part reasoning-0 not found" from tool calls using GLM 4.5 Air #6486: Error "reasoning part reasoning-0 not found" from tool calls using GLM 4.5 Air — related GLM reasoning/thinking token handling issue

    If your issue is distinct from these, feel free to keep it open and provide any additional context that differentiates it.

  4. tayroneoliveira2023 commented on Mar 10, 2026

    @tayroneoliveira2023
    tayroneoliveira2023
    on Mar 10, 2026
    Author
    More actions

    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:

    • Support parsing <think> and <thinking> tags as reasoning blocks #11439 — Support parsing <think> and <thinking> tags as reasoning blocks (main tracking issue)
    • Thinking models: raw <think> tag content displayed instead of being collapsed #15380 — Thinking models: raw <think> tag content displayed instead of being collapsed (closed as duplicate of Support parsing <think> and <thinking> tags as reasoning blocks #11439)
    • thinking stop when use GLM-5 #15782 — thinking stop when use GLM-5
    • GLM 4.7 on Zai coding plan puts tool calls inside the thinking/reasoning tag. #6708 — GLM 4.7 puts tool calls inside thinking/reasoning tags
    • [bug] GLM 5 keeps screwing up the json parsing of read tool calling #13982 — GLM-5 keeps screwing up JSON parsing of read tool calling

    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
  5. tareko commented on Mar 27, 2026

    @tareko
    tareko
    on Mar 27, 2026
    More actions

    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
  6. toninho09 commented on Apr 1, 2026

    @toninho09
    toninho09
    on Apr 1, 2026
    More actions

    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.

  7. sa-altaiftech commented on Apr 3, 2026

    @sa-altaiftech
    sa-altaiftech
    on Apr 3, 2026
    More actions

    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

  8. jumski commented on Apr 6, 2026

    @jumski
    jumski
    on Apr 6, 2026
    More actions

    Same for me - GLM 5.1 is also broken and unusable.

  9. Silur commented on Apr 8, 2026

    @Silur
    Silur
    on Apr 8, 2026
    More actions

    Actual outputs of GLM5.1 from opencode:

    Image Image Image
  10. ShibuyaCyana commented on Apr 8, 2026

    @ShibuyaCyana
    ShibuyaCyana
    on Apr 8, 2026
    More actions

    According to this Reddit post it seems also happening in Claude code.

    So there seems to be two separate problems:

    1. OpenCode parsing for GLM models are broken;
    2. GLM models themselves are degrading, probably due to they've been overly quantized.
  11. saurav-shakya
    added a commit that references this issue on Apr 10, 2026

    fix: render think tags as reasoning blocks + fix MCP MaxListeners ove…

    This issue will close once commit fc36b7c is merged into the 'dev' branch.
    fc36b7c
  12. saurav-shakya commented on Apr 10, 2026

    @saurav-shakya
    saurav-shakya
    on Apr 10, 2026
    More actions

    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
  13. thdxr
    removed
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    windows
    on May 3, 2026
  14. zmlgit
    added a commit that references this issue on May 21, 2026

    fix: disable thinking/reasoning during compaction summarization

    59deffa
  15. github-actions commented on Jul 4, 2026

    @github-actions
    github-actionsBot
    on Jul 4, 2026 – with GitHub Actions
    Contributor
    More actions

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

  16. github-actions
    closed this as not plannedon Jul 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @kommander
    kommander

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.