Repository navigation
fix(base-action): don't reject successful runs when num_turns exceeds maxTurns - #1762
gunjanjaswal wants to merge 1 commit into
Conversation
… maxTurns maxTurns bounds model round trips, but result.num_turns counts every turn in the transcript, which batched tool calls inflate well past the round-trip count. The post-result guard compared the two and threw on runs the SDK had already reported as success within the limit (a --max-turns 14 run returning num_turns 27, per anthropics#1758). A genuine overrun is reported by the SDK as a non-success subtype (error_max_turns) and already fails via the isSuccess check, so the num_turns comparison was redundant and wrong. Remove it, and replace the num_turns:73/maxTurns:60 test with a batching-aware fixture that stays a success plus a test that a max-turns overrun still fails. Closes anthropics#1758
|
Gentle nudge on this one. |
|
Following up on this, it's been open about five weeks without a review. It's a small, self-contained fix: |
|
Following up again here. Still a small, self-contained fix, and I'm happy to rebase if it's drifted since. Let me know if there's anything you'd like adjusted before it can go in. |
Fixes #1758.
run-claude-sdk.tsre-checked the SDK's result withnum_turns > maxTurnsand threw on a run the SDK had already reported assubtype: "success", is_error: false. The two quantities aren't comparable:maxTurnsbounds model round trips, whilenum_turnscounts every turn in the transcript, and batched tool calls inflate it well past the round-trip count. The issue has a concrete trace, a--max-turns 14run returningnum_turns: 27, reported as a success by the SDK and then failed by this guard, leaving the tracking comment stuck.Dropping the guard doesn't lose genuine enforcement. A real overrun is reported by the SDK as a non-success subtype (
error_max_turns), which the existingisSuccesscheck (subtype === "success" && !is_error) already treats as a failure and throws on. So typedmaxTurnsenforcement,is_errorhandling, and timeouts all stay intact; the only thing removed is the second-guess against a metric that doesn't line up.Changes
num_turns > maxTurnsthrow inbase-action/src/run-claude-sdk.ts, with a comment on why the comparison isn't valid.num_turns: 73 / maxTurns: 60rejected). Replaced it with a batching-aware fixture (num_turns: 27 / maxTurns: 14stays a success, matching the issue's trace), and added a test that anerror_max_turnsresult still fails.Testing
bun test base-action/test/run-claude-sdk.test.ts— 5 passbun run typecheckclean,prettier --checkcleanFollow-up to #1607 / #1577. Per the issue, this keeps genuine
error_max_turnsenforcement rather than raising budgets or accepting failures.