Preserve MCP tool error outcomes - #2138
Conversation
ApprovabilityVerdict: Needs human review This PR adds tool error tracking across multiple components with an unresolved design question from another reviewer questioning whether this departure from standard API is necessary. The architectural concern should be resolved before merging. You can customize Macroscope's approvability policy. Learn more. |
47ea576 to
1433270
Compare
| content: MessageContent | ||
| name: str | None = None | ||
| """Needed by templates such as Harmony when bridge tails omit the issuing call.""" | ||
| is_error: bool = False |
There was a problem hiding this comment.
why do we need this departure from standard api? can we not just put the error in the content and call it a day?
df1ae39 to
05ea449
Compare
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.
Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 05ea449. Configure here.
05ea449 to
254c065
Compare

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
Changes what chat-compatible models see for failed tools (failure prefix) and eval override message rewriting; trace hashing changes can fork dedup for identical-content success vs error results.
Overview
Adds
ToolMessage.is_errorso MCP and harness tool failures are typed end-to-end instead of living only in message text.The shared minimal harness program propagates
CallToolResult.isErrorinto tool messages via a private_vf_is_errorwire flag (andextra_bodyon chat completions so interception keeps that metadata). Bash/null harnesses serialize initial prompts withinclude_internal=Trueso resume handoff does not strip the flag.Chat dialect maps the private key into
is_erroron parse; on export it either keeps_vf_is_errorinternally or prefixes model-visible content withTool execution failed:before upstream LLM calls.apply_overridesre-wires flagged messages so providers never see the private field. Anthropic maps nativetool_result.is_errorinto the same field.Trace graph
message_hashtreats error vs success tool results as distinct even when content matches, so persistence and replay stay correct.Reviewed by Cursor Bugbot for commit 05ea449. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Preserve MCP tool error outcomes through the verifier pipeline
is_error: booltoToolMessagein types.py and propagates it through parsing, hashing, and wire serialization.result.isErrorfrom MCP tool calls and tags the tool message with a private_vf_is_errorkey."Tool execution failed:\n"when serializing for public wire format; the private flag is preserved instead wheninclude_internal=True.ChatDialect.apply_overridesstrips internal error keys before forwarding requests to the upstream chat/completions endpoint.include_internal=Trueso private error flags survive into the child program.Macroscope summarized 254c065.