Skip to content

[python/openai_agents] breaking: refuse a stateful MCP provider factory that isn't callable - #599

Merged
campoy merged 1 commit into
mainfrom
fix/openai-agents-python-stateful-mcp-factory-callable
Nov 16, 2026
Merged

campoy merged 1 commit into
mainfrom
fix/openai-agents-python-stateful-mcp-factory-callable

Conversation

@campoy

@campoy campoy commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

What was changed

The deprecated StatefulMCPServerProvider now checks that its factory is callable when you create it. If it isn't, it raises TypeError, so the Worker doesn't start:

MCP server factory 'files' is agents.mcp.server.MCPServerStreamableHttp, not callable

Today a server passed in place of its factory gets past Worker start. Then the session Activity fails when it calls the factory, every time a workflow opens that session.

This is the same check and message #593 added for OpenAIAgentsPlugin(mcp_servers=...). The deprecated StatelessMCPServerProvider already raises a TypeError when you create it, through inspect.signature, so it doesn't change.

Why?

The GA plan for OpenAI Agents Python asked whether the stateful provider should refuse a factory that isn't callable, as #555 does for TypeScript. Adding it after 2.0 would need a 3.0.

Is it breaking? (Breaking)

A Worker with a stateful provider whose factory isn't callable used to start, even though every session for that server failed. Now it doesn't start, even when no workflow uses that server. Fix the factory before upgrading. No Workflow code or Activity names change.

Checklist

  1. Closes: no issue. Follow-up to [openai-agents-python] breaking: refuse an MCP factory that isn't callable #593.

  2. How was this tested:

    • The existing test in test_mcp_v2.py that passes a value in place of the factory now builds the stateful provider too. It fails with DID NOT RAISE TypeError without the change and passes with it.
    • make test on Python 3.12: 619 passed, 2 skipped.
    • make lint passed.
    • git diff --check passed.
  3. Any docs updates needed? The README's paragraph on the deprecated providers now says both raise TypeError for a factory that isn't callable.

…built

StatefulMCPServerProvider now raises TypeError for a factory that isn't
callable, such as a server passed in its place, so the Worker doesn't
start. It used to start, and each session Activity then failed calling the
factory. OpenAIAgentsPlugin(mcp_servers=...) does the same since #593, and
the deprecated stateless provider already raised.
@campoy
campoy requested a review from a team as a code owner November 16, 2026 23:03
@campoy campoy changed the title [openai-agents-python] breaking: refuse a stateful MCP provider factory that isn't callable [python/openai_agents] breaking: refuse a stateful MCP provider factory that isn't callable Nov 16, 2026
@campoy
campoy merged commit 4398991 into main Nov 16, 2026
29 checks passed
@campoy
campoy deleted the fix/openai-agents-python-stateful-mcp-factory-callable branch November 16, 2026 23:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants