anomalyco / anomalyco/opencode
GLM-5.3-Flash thinking degenerates into '!!!!!' loop in agentic tool-calling scenarios (similar to #25129)
@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 SGLanglmsysorg/sglang:glm-5.3-flashon 8x NVIDIA H20 - Access: litellm proxy -> SGLang
Repro
- Add GLM-5.3-Flash as an OpenAI-compatible model
- Send any message through the build agent
- TUI shows
Thought: N.Nsfollowed 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'sreasoning_contentfield contains only!characters (1800+ of them), andcontentis 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.