Bug: openai-completions mapStopReason does not handle finish_reason "error" #1533
machinekoder
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Bug
mapStopReason()inpackages/ai/src/providers/openai-completions.tsdoes not handle the"error"finish reason. When an OpenAI-compatible proxy (e.g. GitHub Copilot) returnsfinish_reason: "error", the function falls into thedefaultcase and throws:This aborts the entire agent turn — tool calls emitted by the model are logged but never executed, and no tool result is returned to the model. The session becomes unrecoverable.
Affected code
packages/ai/src/providers/openai-completions.ts—mapStopReason():Reproduction
openai-completionsprovider withgithub-copilotpointing atgemini-3-flash-previewfinish_reason: "error"(likely mapping fromMALFORMED_FUNCTION_CALLor a transient issue)Unhandled stop reason: errorObserved in two separate OpenClaw agent sessions (
@mariozechner/pi-aiv0.52.12).Suggested fix
Add
case "error"to the switch — same pattern the Google and Anthropic providers already use:The
google-shared.tsandanthropic.tsproviders both correctly map their respective error finish reasons to"error". Theopenai-completionsprovider is the only one missing this case.Beta Was this translation helpful? Give feedback.
All reactions