fix: keep the failure reason and web search citations on tool rows

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Guilhem Lemouel
2026-09-16 17:45:53 +02:00
co-authored by Claude Fable 5.1
parent d08a324d54
commit 8da42eb8c7
2 changed files with 15 additions and 6 deletions
+12 -5
View File
@@ -711,12 +711,19 @@ async fn handle_tool_execution_error(
}
// Add tool message to conversation if chat_input_enabled (error case). Worded from the
// tool like every other tool row; nothing is put on the row because the tool's own job
// holds it — `handle_non_flow_job_error` above completed that job with this error, and it
// was pushed with the arguments the step's input transforms produced rather than the raw
// ones the model supplied.
// tool like every other tool row, with the error as the row's result so the reason
// survives a reload. The arguments are not put on the row: the tool's job was pushed
// with the ones the step's input transforms produced, not the raw ones the model
// supplied, and the job holds those.
let content = format!("Error executing {}", tool_call.function.name);
add_tool_message_to_chat(ctx, Some(job_id), &content, false, None).await;
add_tool_message_to_chat(
ctx,
Some(job_id),
&content,
false,
Some(MessageExtras { tool_result: Some(error_message.clone()), ..Default::default() }),
)
.await;
Ok(())
}
+3 -1
View File
@@ -1524,7 +1524,9 @@ pub async fn run_agent(
if let Some(memory_id) = memory_id {
let agent_job_id = job.id;
let db_clone = db.clone();
let message_content = "Used websearch tool successfully".to_string();
// Worded like every other tool row, so a reader recovers the
// tool name from the sentence and keeps the citations below.
let message_content = "Used websearch tool".to_string();
let step_name = step_name.clone();
// The search ran inside the provider's call, so this job's args
// describe the agent, not the search: its sources reach the row