Skip to content

test(mcp): assert runner emits tool_call_output_item on MCP failures#2556

Merged
seratch merged 1 commit intoopenai:mainfrom
OiPunk:codex/openai-agents-879-runner-tool-output-assert
Feb 28, 2026
Merged

test(mcp): assert runner emits tool_call_output_item on MCP failures#2556
seratch merged 1 commit intoopenai:mainfrom
OiPunk:codex/openai-agents-879-runner-tool-output-assert

Conversation

@OiPunk
Copy link
Contributor

@OiPunk OiPunk commented Feb 27, 2026

Summary

This is a follow-up to #2554, adjusted based on maintainer feedback.

Instead of only asserting that the run continues, this test now explicitly verifies that runner-level MCP tool failures are surfaced as a generated tool_call_output_item.

What changed

  • Added test_runner_emits_mcp_error_tool_call_output_item in tests/mcp/test_runner_calls_mcp.py.
  • Introduced a crashing fake MCP server for deterministic failure behavior.
  • Asserted both sync and streaming paths:
    • a tool_call_output_item is produced
    • the item output matches the expected error text from default_tool_error_function
    • the run still continues to the next turn (final_output == "done")

Validation

Locally run:

  • env -u all_proxy -u ALL_PROXY -u http_proxy -u HTTP_PROXY -u https_proxy -u HTTPS_PROXY -u no_proxy -u NO_PROXY uv run --with pytest pytest -q tests/mcp/test_runner_calls_mcp.py
  • uv run --with ruff ruff check tests/mcp/test_runner_calls_mcp.py
  • uv run --with mypy mypy tests/mcp/test_runner_calls_mcp.py

All passed locally.

@github-actions github-actions bot added documentation Improvements or additions to documentation feature:mcp labels Feb 27, 2026
Copy link
Member

@seratch seratch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@OiPunk Thank you for working on this. I think this is worth adding, so I'll merge it.

That said, we're trying to keep review effort focused, so for future test-only PRs, please prioritize cases that cover critical or user-visible paths.

@seratch seratch merged commit fc284d4 into openai:main Feb 28, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation feature:mcp

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants