improvement: propagate McpErrors directly into ToolCallResult#5289
Merged
alexhancock merged 3 commits intomainfrom Oct 21, 2025
Merged
improvement: propagate McpErrors directly into ToolCallResult#5289alexhancock merged 3 commits intomainfrom
alexhancock merged 3 commits intomainfrom
Conversation
alexhancock
commented
Oct 21, 2025
| .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), |
Collaborator
Author
There was a problem hiding this comment.
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
Collaborator
There was a problem hiding this comment.
we can provide even more context in the optional data field. might be useful for debugging and also to send to the agent back
Collaborator
Author
DOsinga
approved these changes
Oct 21, 2025
| .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), |
Collaborator
There was a problem hiding this comment.
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
Collaborator
|
nice |
BlairAllan
pushed a commit
to BlairAllan/goose
that referenced
this pull request
Oct 25, 2025
…5289) Signed-off-by: Blair Allan <Blairallan@icloud.com>
BlairAllan
pushed a commit
to BlairAllan/goose
that referenced
this pull request
Nov 29, 2025
…5289) Signed-off-by: Blair Allan <Blairallan@icloud.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.