File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
cli/src/commands/agent/run Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -363,7 +363,16 @@ pub async fn run_interactive(
363363 } ;
364364
365365 send_input_event ( & input_tx, InputEvent :: HasUserMessage ) . await ?;
366- tools_queue. clear ( ) ;
366+ // Add tool_result for any remaining queued tool calls before clearing.
367+ // Without this, assistant messages containing tool_use blocks for these
368+ // calls would be orphaned (no matching tool_result), causing Anthropic
369+ // API 400 errors on the next request.
370+ for abandoned_tool in tools_queue. drain ( ..) {
371+ messages. push ( tool_result (
372+ abandoned_tool. id ,
373+ "TOOL_CALL_CANCELLED" . to_string ( ) ,
374+ ) ) ;
375+ }
367376 messages. push ( user_msg) ;
368377
369378 // Capture telemetry when not using Stakpak API (local mode)
You can’t perform that action at this time.
0 commit comments