Commit 5d49733
committed
🤖 Fix test flake: limit tool call steps to prevent infinite loops
Reasoning models (especially gpt-5-codex) can get stuck in infinite tool
call loops when combined with web_search and high reasoning effort. This
was causing the openai-web-search.test.ts integration test to timeout
after 120+ seconds with 15+ tool calls and no completion.
Root cause: The stream was using `stopWhen: stepCountIs(100000)` which
effectively allowed unlimited tool calls. With reasoning models, the model
can keep calling tools indefinitely without reaching a final answer.
Fix: Replace unlimited steps with `maxSteps: 25` to prevent infinite loops
while still allowing reasonable multi-turn tool use. This value is chosen
based on observed failure (15 tool calls) with some buffer.
The AI SDK will now stop the stream after 25 tool call rounds, ensuring
the stream completes and emits stream-end even if the model gets stuck.
Fixes: https://github.com/coder/cmux/actions/runs/187663779321 parent 07b5d7b commit 5d49733
1 file changed
+2
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | 7 | | |
9 | 8 | | |
10 | 9 | | |
| |||
476 | 475 | | |
477 | 476 | | |
478 | 477 | | |
479 | | - | |
480 | | - | |
| 478 | + | |
| 479 | + | |
481 | 480 | | |
482 | 481 | | |
483 | 482 | | |
| |||
0 commit comments