Session loop doesn't stop when model returns finish_reason=stop #7956

Open
opened 2026-02-16 18:08:46 -05:00 by yindo · 2 comments
Owner

Originally created by @tremo1 on GitHub (Jan 29, 2026).

Originally assigned to: @rekram1-node on GitHub.

When the model returns a response with finish_reason=stop (no tool calls, just text), the session loop continues making API calls with identical messages instead of stopping.

Expected: Loop stops when model indicates it's done
Actual: Loop continues, sending the same request repeatedly

Root cause: In processor.ts, the process() function returns "continue" even when finish_reason=stop. It only returns "stop" for errors or blocked states.

Impact: Causes infinite loops until timeout or error, wastes API calls

Originally created by @tremo1 on GitHub (Jan 29, 2026). Originally assigned to: @rekram1-node on GitHub. When the model returns a response with `finish_reason=stop` (no tool calls, just text), the session loop continues making API calls with identical messages instead of stopping. **Expected:** Loop stops when model indicates it's done **Actual:** Loop continues, sending the same request repeatedly **Root cause:** In `processor.ts`, the `process()` function returns `"continue"` even when `finish_reason=stop`. It only returns `"stop"` for errors or blocked states. **Impact:** Causes infinite loops until timeout or error, wastes API calls
Author
Owner

@github-actions[bot] commented on GitHub (Jan 29, 2026):

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

  • #10573: Custom provider with Openai compatible API showing blank output and keep looping - User reported the session keeps looping and API credits get spent continuously with custom provider setup

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Jan 29, 2026): This issue might be a duplicate of existing issues. Please check: - #10573: Custom provider with Openai compatible API showing blank output and keep looping - User reported the session keeps looping and API credits get spent continuously with custom provider setup Feel free to ignore if none of these address your specific case.
Author
Owner

@rekram1-node commented on GitHub (Jan 29, 2026):

what provider did u use that encountered this?

@rekram1-node commented on GitHub (Jan 29, 2026): what provider did u use that encountered this?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#7956