Skip to content

fix(session): stop loop when model returns non-tool finish reason#11152

Closed
tremo1 wants to merge 1 commit into
anomalyco:devfrom
tremo1:fix/stop-loop-on-finish-reason
Closed

fix(session): stop loop when model returns non-tool finish reason#11152
tremo1 wants to merge 1 commit into
anomalyco:devfrom
tremo1:fix/stop-loop-on-finish-reason

Conversation

@tremo1

@tremo1 tremo1 commented Jan 29, 2026

Copy link
Copy Markdown

Fixes #11153

When the model returns finish_reason=stop, the processor was returning "continue" causing repeated API calls with identical messages.

Change: Return "stop" from processor when finish reason is not "tool-calls" or "unknown".

Verification: Traced through logs from a stuck session - model returned finish_reason=stop but processor returned "continue", loop kept running. With this fix, processor returns "stop" and loop breaks.

When the model returns a response with finish_reason other than
"tool-calls" or "unknown" (e.g. "stop"), the processor was returning
"continue" which caused the main loop to keep running. This led to
repeated API calls with identical messages.

Now the processor correctly returns "stop" when the model indicates
it's done, breaking the loop as expected.
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

@github-actions

Copy link
Copy Markdown
Contributor

Closing this pull request because it has had no updates for more than 60 days. If you plan to continue working on it, feel free to reopen or open a new PR.

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.

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

1 participant