-
Notifications
You must be signed in to change notification settings - Fork 2.5k
improvement: propagate McpErrors directly into ToolCallResult #5289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| .map_err(|e| ErrorData::new(ErrorCode::INTERNAL_ERROR, e.to_string(), None)) | ||
| .map_err(|e| match e { | ||
| ServiceError::McpError(error_data) => error_data, | ||
| _ => ErrorData::new(ErrorCode::INTERNAL_ERROR, e.to_string(), None), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still thinking a bit. may want to consider further expansion of these things too?
e.maybe_to_value() is another option for the third param instead of None
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can provide even more context in the optional data field. might be useful for debugging and also to send to the agent back
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| .map_err(|e| ErrorData::new(ErrorCode::INTERNAL_ERROR, e.to_string(), None)) | ||
| .map_err(|e| match e { | ||
| ServiceError::McpError(error_data) => error_data, | ||
| _ => ErrorData::new(ErrorCode::INTERNAL_ERROR, e.to_string(), None), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can provide even more context in the optional data field. might be useful for debugging and also to send to the agent back
8d7158d to
eca4c60
Compare
|
nice |
…5289) Signed-off-by: Blair Allan <Blairallan@icloud.com>
…5289) Signed-off-by: Blair Allan <Blairallan@icloud.com>
Issue:
Before this change, we wrapped all errors which occured during tool calling in a:
There are some issues with this. Only the message (albeit with original code embedded) was included, the error itself has an incorrect code, and no additional information about the error in the third param.
Change:
This change propgates the wrapped
ErrorDatafromServiceError::McpErrors during tool calling into theToolCallResultso that the model has better information about what happened. These will contain the proper error codes, original message, and additional data where the mcp sdk provides it.Testing
I tested with the following prompt:
Before (actual error wrapped and obscured):

After (actual error included directly):

Sonnet 4.5 did a valiant effort trying to include some info about the wrapped error, but other models are likely to be confused.