Preserve MCP tool error outcomes#2138
Open
xeophon wants to merge 2 commits into
Open
Conversation
ApprovabilityVerdict: Needs human review This PR propagates MCP tool error state through the message pipeline, changing function signatures, message formatting (adding 'Tool execution failed:' prefix), and message hash computation. These runtime behavior changes, particularly the hash modification that could affect caching/deduplication, warrant human review. You can customize Macroscope's approvability policy. Learn more. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 1e47ec2. Configure here.
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.

Overview
Preserves MCP tool-declared outcome semantics across harness execution, typed messages, traces, replay, and provider conversion.
This PR follows #2134 in a native GitHub pull request stack. #2134 owns the shared null/bash MCP client and its session lifecycle and replay-safety behavior.
Details
MCP
CallToolResultcontains both model-visible content and anisErroroutcome. The shared MCP client now returns both values, and the harness program carries the outcome intoToolMessage.is_error.The typed outcome participates in graph identity and trace serialization, so success and failure results with identical content remain distinguishable after persistence and resume.
For chat-compatible providers, the localhost harness handoff uses a private marker that is removed before the provider request while adding a readable failure label to the model-visible content. Anthropic-native
tool_result.is_errormaps directly into the same typed representation.Note
Medium Risk
Touches message serialization, eval
apply_overrides, and graph identity; behavior changes for tool failures on chat providers (prefixed content) but is scoped to error semantics rather than core auth or data paths.Overview
Adds
ToolMessage.is_errorso MCP and harness tool failures are typed end-to-end, not only as text incontent.MCP → harness:
call_mcpnow returns(content, isError)fromCallToolResult; the bash/null program sets a private_vf_is_errormarker on tool wire messages and passes messages throughextra_bodyso interception keeps that field.Chat providers:
message_to_wirestrips the private marker before upstream requests and prefixes model-visible content withTool execution failed:\non errors; internal handoff (initial-messages JSON) usesinclude_internal=Trueto round-trip the flag.apply_overridesre-serializes messages that still carry the marker so eval overrides don’t leak private fields to the API.Anthropic:
tool_result.is_errormaps into the sameis_errorfield on parse.Traces / replay:
message_hashincludes error vs success so identical tool bodies dedupe differently after persist/resume.Reviewed by Cursor Bugbot for commit 47ea576. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Preserve MCP tool error outcomes across the message pipeline
is_error: bool = FalsetoToolMessagein types.py to carry tool failure status through the message model.call_mcpreturns a(content, is_error)tuple, and program.py propagates that flag via the internal_vf_is_errorkey on tool messages.message_to_wireprefixes errored content with a human-visible banner unlessinclude_internal=True, andChatDialect.apply_overridesstrips internal markers before forwarding requests upstream.is_errorwhen parsing Anthropictool_resultblocks.message_hash.Macroscope summarized 47ea576.