Repository navigation
Conversation
Some providers (e.g. GLM-5 Turbo via OpenAI-compatible gateways) return finishReason "unknown" instead of "stop" or "end_turn". The prompt loop previously treated "unknown" as non-terminal alongside "tool-calls", causing an infinite loop when no tool calls were present. Extract isTerminalFinishReason() so the invariant — only "tool-calls" keeps the loop running — is explicit and testable.
56319fa to
9e47961
Compare
|
Rebased onto latest dev. 9 The upstream code still has |
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
Issue for this PR
Closes #19339
Type of change
What does this PR do?
Providers like GLM-5 Turbo (via OpenAI-compatible gateways) return
finishReason: "unknown"instead of"stop". The prompt loop treated"unknown"as non-terminal alongside"tool-calls", causing an infinite loop when no tool calls were present.This PR removes
"unknown"from the non-terminal list so only"tool-calls"keeps the loop running. The check is extracted intoisTerminalFinishReason()to make the invariant explicit and testable.Note: the TUI has a similar pattern in
session/index.tsx— will address in a follow-up.How did you verify your code works?
finishReason: "unknown", step count reaching 100+)bun test test/session/finish-reason.test.ts— 9 tests passbun typecheckpassesChecklist