test(mcp): add runner-level coverage for upstream tool errors#2554
Open
OiPunk wants to merge 2 commits intoopenai:mainfrom
Open
test(mcp): add runner-level coverage for upstream tool errors#2554OiPunk wants to merge 2 commits intoopenai:mainfrom
OiPunk wants to merge 2 commits intoopenai:mainfrom
Conversation
Contributor
Author
|
Follow-up update:
Revalidated locally:
Both pass. |
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.
Summary
This PR adds runner-level regression coverage for MCP upstream tool errors (issue #879).
Problem
Issue #879 reports that when an MCP upstream service returns an error (e.g., HTTP 422), the run can abort with an
AgentsExceptioninstead of returning model-visible tool output.Current code already implements graceful handling via
failure_error_functionin MCP tool wrappers, but there was no runner-level test that locks in this behavior end-to-end.Changes
test_runner_handles_mcp_upstream_errors_as_tool_output:call_toolraises an upstream error.Runner.runandRunner.run_streamedboth continue and complete with the next model turn.test_runner_raises_when_mcp_failure_error_function_disabled:mcp_config={"failure_error_function": None}preserves raising behavior.Why this is useful
Local validation
uv run --with pytest pytest -q tests/mcp/test_runner_calls_mcp.pyuv run --with ruff ruff check tests/mcp/test_runner_calls_mcp.pyuv run --with pytest pytest -q tests/mcp/test_mcp_util.py -k 'graceful_error_handling or failure_error_function'Closes #879