fix: Improve error messages for invalid tool calls (#6483)

Signed-off-by: J. Carr <jcarr250@protonmail.com>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Jason Carr
2026-01-14 07:14:34 -06:00
committed by GitHub
parent d923b323f8
commit 355d319bc4
2 changed files with 15 additions and 7 deletions
+5 -5
View File
@@ -529,11 +529,11 @@ impl Agent {
"tool_execution_failed",
&format!("{}: {}", tool_call.name, e),
);
ToolCallResult::from(Err(ErrorData::new(
ErrorCode::INTERNAL_ERROR,
e.to_string(),
None,
)))
// Try to downcast to ErrorData to avoid double wrapping
let error_data = e.downcast::<ErrorData>().unwrap_or_else(|e| {
ErrorData::new(ErrorCode::INTERNAL_ERROR, e.to_string(), None)
});
ToolCallResult::from(Err(error_data))
})
};