fix(mcp): surface swallowed workflow error in _workflow_response#1173
Merged
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
An errored workflow run returned {success:false, findings:[], cost:0}
with no error field — indistinguishable from a clean empty result.
SDK-native failures (e.g. an auth 401) leave result.error None and
carry the message in metadata (is_error + raw_result_text), which
_workflow_response never read.
Surface result.error / metadata.raw_result_text as an `error` field
(plus error_type) whenever a run errored; only str messages are
accepted so a mocked result never injects a spurious key. Adds 5
regression tests; the success-path response shape is unchanged.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…-29) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
73a6a61 to
2cd968d
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Problem
When an MCP workflow run errored,
_workflow_responsereturned{success: false, findings: [], cost: 0}with no error field —indistinguishable from a clean, empty result. SDK-native failures
(e.g. an auth
401) leaveresult.errorasNoneand carry themessage in
result.metadata(is_error+raw_result_text), which_workflow_responsenever read. The real reason was swallowed (theremoving-dead-code"fake-success signature").
Found during a QA/dogfood session: every SDK workflow came back
success:false / cost:0and the actual cause (Invalid API key) wasonly visible via a direct repro.
Fix
Surface the real failure reason as an
errorfield (pluserror_type)whenever a run errored — gated on
result.success is Falseormetadata["is_error"]. Onlystrmessages are accepted, so a mockedresult never injects a spurious key. The success-path response shape
is unchanged (strict-equality tests still pass).
Verification
test_workflow_response.pytests/unit/mcp/suite green (367 passed; the one failure was alive network test unrelated to this change)
error: "Failed to authenticate. API Error: 401 …"instead of asilent empty result
Out of scope (flagged separately)
The SDK adapter can report
success: Truewhileis_error: True(subtype-based logic in
agent_sdk_adapter). This PR surfaces theerror regardless of that flag; fixing the mislabel itself is a deeper,
separate change.
🤖 Generated with Claude Code