Skip to content

fix: stop reasoning-only loops for GLM/minimax#111

Open
marius-kilocode wants to merge 2 commits intodevfrom
fix/104-reasoning-stuck-loop
Open

fix: stop reasoning-only loops for GLM/minimax#111
marius-kilocode wants to merge 2 commits intodevfrom
fix/104-reasoning-stuck-loop

Conversation

@marius-kilocode
Copy link
Collaborator

@marius-kilocode marius-kilocode commented Feb 4, 2026

Problem

Some models (reported with z-ai/glm-4.7:free and minimax/minimax-m2.1:free) can stream only reasoning (<think>/reasoning deltas) and finish the step with finish: \"unknown\". SessionPrompt.loop keeps looping on unknown, causing an infinite repetition.

Original issue: #104

Fix

  • Add a dedicated MessageReasoningStuckError.
  • In SessionProcessor, track whether a step produced any non-reasoning output (text/tool parts).
  • If a step is reasoning-only and exceeds a threshold (or finishes with unknown), mark the message with MessageReasoningStuckError and stop the loop.
  • Format the error nicely in the CLI.

Tests

  • bun run typecheck
  • bun test (packages/opencode)

Closes #104

@kiloconnect
Copy link
Contributor

kiloconnect bot commented Feb 4, 2026

Code Review Summary

Status: 2 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 1
Issue Details (click to expand)

WARNING

File Line Issue
packages/opencode/src/session/processor.ts 66 Abort forwarding listener can leak across loop iterations

SUGGESTION

File Line Issue
packages/opencode/src/cli/error.ts 45 Reasoning-stuck formatting ignores error's data.message
Other Observations (not in diff)

Issues found in unchanged code that cannot receive inline comments:

File Line Issue
packages/opencode/src/session/processor.ts N/A Existing inline comments already cover heuristic token-vs-char threshold + stream finalization/finish-gating; re-review after updates to avoid reintroducing loop/cleanup issues.
Files Reviewed (4 files)
  • packages/opencode/src/cli/error.ts - 1 suggestion
  • packages/opencode/src/session/message-v2.ts - 0 issues
  • packages/opencode/src/session/processor.ts - 1 warning
  • packages/sdk/js/src/v2/gen/types.gen.ts - 0 issues

Fix these issues in Kilo Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Continuous Thinking Repetition with GLM 4.7 (free)

1 participant