fix: handle tool validation errors in stopWhen and willContinue#241
fix: handle tool validation errors in stopWhen and willContinue#241elpiarthera wants to merge 1 commit intoget-convex:mainfrom
Conversation
In AI SDK v6, failed tool calls produce tool-error content parts instead of tool-result. willContinue was only checking toolResults, treating validation failures as pending — causing premature stops. Also adds hasSuccessfulToolCall(toolName) stop condition that only matches tool calls which produced a tool-result, so agents retry on argument validation failures instead of stopping. Fixes get-convex#172
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdded a new Changes
Possibly related issues
Poem
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
hasSuccessfulToolCall(toolName)— new stop condition that only matches tool calls which produced atool-result(nottool-error). Use instead of the AI SDK'shasToolCallwhen agents should retry on argument validation failures.willContinuefix — countstool-errorcontent parts as completed outputs. In AI SDK v6, failed tool calls producetool-errorinstead oftool-result, causingwillContinueto incorrectly treat them as pending and stop prematurely.Context
When a tool call fails Zod argument validation in AI SDK v6, the result is a
tool-errorcontent part (nottool-result). Two problems occurred:willContinuecheckedstep.toolCalls.length > step.toolResults.length— sincetool-errorisn't intoolResults, it looked like a pending result, returningfalse(stop)hasToolCallmatches any tool call regardless of success, sostopWhen: [hasToolCall("myTool")]would stop even on validation failuresTest plan
npm run buildpassesnpm run typecheckpassesnpm run lintpasses (0 errors)npm testpasses (262/262)willContinuehas a single caller (streamText.ts:143), change is backwards-compatibleFixes #172
Orchestrator: Zeta — VantageOS Team Dev | 2026-04-06
Summary by CodeRabbit
New Features
Bug Fixes