anomalyco / anomalyco/opencode

GLM-5.3-Flash thinking degenerates into '!!!!!' loop in agentic tool-calling scenarios (similar to #25129)

Open
#45,533 1 comment 0 reactions 1 assignee View on GitHub

@neriousy is already working on this.

Since Aug 27, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Description

Using GLM-5.3-Flash (served via SGLang backend) with opencode, requests through the build agent trigger a thinking degeneration loop where the TUI shows a "Thought" block followed by endless ! characters — the same symptom as #25129.

Environment

  • opencode 1.18.23
  • Model: zai-org/GLM-5.3-Flash (FP8), served via SGLang lmsysorg/sglang:glm-5.3-flash on 8x NVIDIA H20
  • Access: litellm proxy -> SGLang

Repro

  1. Add GLM-5.3-Flash as an OpenAI-compatible model
  2. Send any message through the build agent
  3. TUI shows Thought: N.Ns followed by endless !!!!!!!!!!!!!!!!!!!

Root cause (confirmed server-side, not opencode rendering)

The model itself degenerates under complex agentic prompts. Direct curl tests against the backend confirm:

  • Simple request (short prompt, no tools): correct answer returned.
  • Complex request (long agentic system prompt + multiple tools + tool_choice=auto): the streaming response's reasoning_content field contains only ! characters (1800+ of them), and content is empty.

This is a server-side issue (SGLang's reasoning parsing for GLM-5.3-Flash under multi-tool prompts — tracked at https://github.com/sgl-project/sglang/issues/36669), not an opencode rendering bug. However opencode surfaces it as the "Thought" + !!!! loop.

Suggestion

The proposed fix in #25129 — detect repetitive characters in thinking blocks (e.g. (.)\1{10,}) and abort/retry the request without the corrupted thinking context — would at least prevent the endless !!!! spam and make the failure recoverable. A more targeted mitigation would be to retry such requests with a reduced tool set or lower reasoning effort when a repetition loop is detected.

Why this matters

GLM-5.3-Flash is a current-gen 320B/18B MoE with always-on thinking. As more always-on-thinking models ship, opencode will hit this class of degeneration more often. A generic repetition guard would make opencode robust against model-side degeneration regardless of backend.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.