Repository navigation
Breaking: reject a callable tool_filter on the deprecated OpenAI Agents MCP providers' servers #291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,7 +27,9 @@ | |
| ) | ||
| from temporalio.openai_agents._heartbeat_decorator import auto_heartbeater | ||
| from temporalio.openai_agents._mcp_server_checks import ( | ||
| _has_dynamic_tool_filter, | ||
| _has_worker_side_require_approval, | ||
| _reject_dynamic_tool_filter, | ||
| _reject_worker_side_require_approval, | ||
| ) | ||
| from temporalio.worker import PollerBehaviorSimpleMaximum, Worker | ||
|
|
@@ -190,6 +192,7 @@ def _create_server(self, factory_argument: Any | None) -> MCPServer: | |
| ) | ||
| else: | ||
| server = cast(Callable[[], MCPServer], self._server_factory)() | ||
| _reject_dynamic_tool_filter(self._server_name, server) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3 (non-blocking): on the deprecated routes, the error's only remedy, 'pass the filter to temporal_mcp_server() instead', is incomplete, and following it as written trades one endless retry for another. |
||
| _reject_worker_side_require_approval( | ||
| self._server_name, server, "stateless_mcp_server" | ||
| ) | ||
|
|
@@ -494,6 +497,7 @@ def _server_id(): | |
|
|
||
| def _server() -> MCPServer: | ||
| server = self._servers[_server_id()] | ||
| _reject_dynamic_tool_filter(self._server_name, server) | ||
| _reject_worker_side_require_approval( | ||
| self._server_name, server, "stateful_mcp_server" | ||
| ) | ||
|
|
@@ -538,11 +542,13 @@ async def connect( | |
| "Cannot connect to an already running server. Use a distinct name if running multiple servers in one workflow." | ||
| ) | ||
| server = self._server_factory(args.factory_argument if args else None) | ||
| # A server with a worker-side approval policy is never connected. | ||
| # The dedicated worker still runs, and each of its operations fails | ||
| # with the policy error, so the workflow sees that error at its | ||
| # first MCP call whatever its schedule-to-start timeout. | ||
| rejected = _has_worker_side_require_approval(server) | ||
| # A server with a callable tool filter or a worker-side approval | ||
| # policy is never connected. The dedicated worker still runs, and | ||
| # each of its operations fails with the same error, so the workflow | ||
| # sees that error at its first MCP call whatever its | ||
| # schedule-to-start timeout. | ||
| has_filter = _has_dynamic_tool_filter(server) | ||
| rejected = has_filter or _has_worker_side_require_approval(server) | ||
| self._servers[server_id] = server | ||
| try: | ||
| try: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P3 (non-blocking): this sentence is the only place the new rule is documented, and it leaves out the part that breaks code that works today. The API docs for these routes do not mention it.
stateless_mcp_server()andstateful_mcp_server()document only therequire_approvalrule (workflow.py:387-391,:450-454). The providers'server_factoryarguments (_mcp.py:167-169,:471-473) andmcp_server_providers(_temporal_openai_agents.py:372-374) document neither rule, although themcp_serversentry just below states both rejections for the v2 route. Release notes carry only the commit subject, so this paragraph is also where an upgrader learns that the check runs in every operation. Probes: a Workflow that only callscall_tool()andlist_prompts()on such a server completes on main but fails at its first MCP Activity at the head, on both routes. A run left retrying list-tools on main fails at its next attempt once a head Worker picks it up. Suggest one sentence in bothserver_factorydocstrings and inmcp_server_providers(a callabletool_filteron the returned server is rejected in every MCP operation; a static one is applied). Here, something like: 'So is a callabletool_filterthere, in every MCP operation, directcall_tool()and prompt calls included; a static filter still works. Remove such a filter from the factory in the same deploy, or let open runs finish first.'