fix: handle truncated tool calls that break conversation alternation (#7424)

This commit is contained in:
tlongwell-block
2026-02-23 09:36:10 -05:00
committed by GitHub
parent ef3f5fa6c2
commit 33af64406b
+10
View File
@@ -1443,6 +1443,16 @@ impl Agent {
.lock().await.clone();
yield AgentEvent::Message(final_response.clone());
messages_to_add.push(final_response);
} else {
let error_msg = format!(
"[system: Tool call could not be parsed: {}. The response may have been truncated. Try breaking the task into smaller steps.]",
request.tool_call.as_ref().unwrap_err(),
);
let error_response = Message::user()
.with_generated_id()
.with_text(&error_msg);
yield AgentEvent::Message(error_response.clone());
messages_to_add.push(error_response);
}
}