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:
@@ -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))
|
||||
})
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user