Commit 1fdb393
committed
fix(opencode): resample turns with an unmapped finish reason
A provider stream that opens, delivers a first chunk, then dies without
sending a finish chunk is reported by the AI SDK as finishReason "other"
with null usage. "other" is not in the FinishReason literal set, so
session/llm/ai-sdk.ts maps it to "unknown".
The two loop guards then disagreed. The error check at prompt.ts:1295
excludes "unknown", so no error was recorded. The loop-exit check did
not, so the loop broke. The turn exited cleanly mid-task with no error,
no timeout and no errored span, and the run was indistinguishable from a
model that gave up.
Measured on the Odysseys benchmark: 0.054% of LLM calls, ~5.3% of tasks
(11/200 and 12/200 on two full runs), and 100% of them terminal.
"unknown" is the fallback in every mapper (openai-chat, openai-responses,
anthropic-messages, gemini, bedrock-converse) and never denotes a normal
completion, so exclude it from the loop-exit check as well and let the
turn resample. The dead turn contributes no model messages, so the repeat
request is identical to the one that was dropped. A warning log keeps the
event visible when the resample succeeds.1 parent b94c6ac commit 1fdb393
2 files changed
Lines changed: 44 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1108 | 1108 | | |
1109 | 1109 | | |
1110 | 1110 | | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
1111 | 1124 | | |
1112 | 1125 | | |
1113 | | - | |
| 1126 | + | |
1114 | 1127 | | |
1115 | 1128 | | |
1116 | 1129 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
810 | 810 | | |
811 | 811 | | |
812 | 812 | | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
813 | 843 | | |
814 | 844 | | |
815 | 845 | | |
| |||
0 commit comments