Repository navigation
[python/openai_agents] breaking: refuse a stateful MCP provider factory that isn't callable - #599
Merged
campoy merged 1 commit intoNov 16, 2026
Conversation
…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.
JasonSteving99
approved these changes
Nov 16, 2026
campoy
deleted the
fix/openai-agents-python-stateful-mcp-factory-callable
branch
November 16, 2026 23:40
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.
What was changed
The deprecated
StatefulMCPServerProvidernow checks that its factory is callable when you create it. If it isn't, it raisesTypeError, so the Worker doesn't start: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 deprecatedStatelessMCPServerProvideralready raises aTypeErrorwhen you create it, throughinspect.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
Closes: no issue. Follow-up to [openai-agents-python] breaking: refuse an MCP factory that isn't callable #593.
How was this tested:
test_mcp_v2.pythat passes a value in place of the factory now builds the stateful provider too. It fails withDID NOT RAISE TypeErrorwithout the change and passes with it.make teston Python 3.12: 619 passed, 2 skipped.make lintpassed.git diff --checkpassed.Any docs updates needed? The README's paragraph on the deprecated providers now says both raise
TypeErrorfor a factory that isn't callable.