Skip to content
This repository was archived by the owner on Feb 25, 2026. It is now read-only.

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

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

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: Kilo-Org/kilocode#6333

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 Kilo-Org/kilocode#6333

@kilo-code-bot
Copy link
Contributor

kilo-code-bot 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

@marius-kilocode marius-kilocode marked this pull request as draft February 11, 2026 14:56
@markijbema
Copy link
Contributor

Hi! Thank you for taking the time to contribute to this project—we really appreciate it. 🙏

We are currently working on re-platforming the core of our VS Code and JetBrains extensions to be based on our new Kilo CLI, with a complete rebuild based on OpenCode as our new foundation, and the moment has come to promote this repository to become the main repository. To do that, we moved the code from this repository to the kilocode repository.

This unfortunately means we cannot merge this branch here anymore. Please add https://github.com/Kilo-Org/kilocode.git as a remote, and push your branch there and create a new PR in https://github.com/Kilo-Org/kilocode . We unfortunately cannot do this for you as then the PR would not be in your name anymore. If you need any help, feel free to ask on our Discord in #kilo-dev-contributors

Sorry for the inconvenience and thank you for contributing to Kilo!

@markijbema markijbema closed this Feb 22, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Continuous Thinking Repetition with GLM 4.7 (free)

2 participants