Repository navigation
Breaking: refuse a tool meta resolver on the OpenAI Agents MCP factory's server and send _meta from the TypeScript MCP handles - #210
Conversation
DABH
left a comment
There was a problem hiding this comment.
Review at head 8dad56a (three commits over c664a34, seven files under typescript/openai-agents). Recipe: ten finder angles, 35 raw items deduplicated to 15 candidates, one adversarial verifier per candidate, then a gap sweep that found nothing new. Verdicts: 9 confirmed, 1 plausible, 5 refuted and dropped (the rollback paragraph is accurate, verified by replaying recorded histories on main's handle; the arity-preserving ternary mirrors upstream mcp.js:620-622 and is observable by arity-sensitive spies; a two-argument user wrapper behaves the same under the upstream Runner; the Activity logger only throws on the undocumented _getActivities() path; the non-generic MCPToolMetaResolver type matches upstream's own option types). In an isolated clone at the head: make sync, tsc and eslint clean (8 pre-existing warnings), 208 tests pass; make lint fails locally only because its nested pnpm resolves the global pnpm 9, not a PR issue. The fix itself is right and matches the Python plugin's design; I verified it against issue #208's reproduction and left my recommendation on the warn-versus-fail question there (keep the warning, fail fast for the whole family in a follow-up marked breaking).
Severity: P1 = wrong result or stuck run in realistic use; P2 = correctness or robustness in an edge case; P3 = docs, tests, cleanup.
Where the problems cluster: both real defects are about what the resolver is handed, not about forwarding: a nested agent's resolver sees an empty run context, and a stateful handle's resolver sees the internal suffixed server name. The rest is a mixed-fleet caveat the README omits, warning noise, and the call-tool input contract now spelled in four places.
Findings on lines outside the diff
typescript/openai-agents/src/workflow/agent-tools.ts:48: P2 (root cause predates the PR; this README section is the first documented feature that depends on it):agentAsToolstarts the nested run without the parent's run context, so a nested agent'stoolMetaResolverbuilds_metafrom an empty{}context and the README's own example silently sends a tenant-less request. Lines 48-52 callrunner.run(agent, parsed.input, sandbox === undefined ? undefined : { runConfig: { sandbox } })and ignore_runContext;runner.ts:297setscontext: options?.context(undefined) and upstreamrunContext.js:97-98defaults it to{}; upstreamAgent.asTool(agent.js:228-229, :292) passescontext: runContext, so native nested servers get the tenant. Reproduced at the head: an orchestrator run with{ context: { tenant: 'tenant-7' } }delegating viaagentAsTool(child), where the child's server uses the README resolver, made the Worker-sidecallToolreceive_meta{"contextType":"object","contextJson":"{}"}; with the one-line fix ({ context: _runContext, ... }) it receivedtenant-7. No error, warning or failed task either way. Fix it here or add the caveat to the new README section; #270 touches the same code.typescript/openai-agents/src/workflow/stateful-mcp-client.ts:123: P2: the new option hands user codeserverName<name>-statefulforstatefulMcpServer(name)but<name>forstatelessMcpServer(name), so the same resolver behaves differently per handle kind and can send an internal name to the MCP server. UpstreamresolveMcpToolMeta(mcp.js:562) buildsserverName: server.name; this getter returnsthis._name, which line 105 set to${name}-stateful, while the stateless handle (mcp-client.ts:41-43) returns the bare name.statefulMcpServer('tickets', { toolMetaResolver: ({ serverName }) => metaByServer[serverName] })withmetaByServer = { tickets: {...} }misses the lookup and sends no_meta; the identical resolver on the stateless handle works; a resolver echoingserverNamesendstickets-stateful. Reproduced at the head by addingserver: serverNameto the test resolver: recordedmetaStatelessversusmetaStateful-stateful. The suffix predates the PR (it already reaches thetoolFiltercontext and span data), but this option is what makes it reach the server; the new test cannot catch it because its resolver omitsserverNameand both expected entries are identical (test-openai-agents.ts:227-230). Fix without changingget name()(upstream's tool cache is keyed by it): wrap the option in the constructor,this.toolMetaResolver = r && ((ctx) => r({ ...ctx, serverName: name })), and assertserverNameper server in the test.typescript/openai-agents/src/__tests__/test-openai-agents.ts:134: P3 (tests): no test pins the compatibility claim that no-resolver calls still reach the server ascallTool(toolName, args)with nometakey in the Activity input. Changing the handles tometa: meta ?? {}and the Worker toserver.callTool(toolName, args, meta ?? {})at the head leaves all 208 tests green: this test asserts onlyfactoryArgument, the History-inspecting tests filterACTIVITY_TASK_SCHEDULEDby Activity type name only (95-100, 267-277, 561-567), and onlymetaTestServerrecordsmeta, on the with-resolver path. A 16-line addition here (rest-paramcallToolasserting two arguments, plus decoding thetestMcp-stateless-call-toolscheduled input and deep-equalling it to{ toolName: 'get_time', args: {}, factoryArgument: { tenantId: 'tenant-42' } }) fails under that edit and passes at head.
PR body: it ends 'Draft while this question is open', but the PR is not marked draft. Not verifiable here: the mixed-fleet scenario (code reading of main's handlers, no two-version run); the result-metadata item depends on users setting those options.
|
Thanks for the review. Pushed 55a1bb6 and 0309d28 (shared handle options, agreed with #209). On the findings outside the diff:
|
|
One change since my last comment: I had already picked refusal for factory-side options the Worker can't run, and #209 now does that for a callable Every MCP Activity for a server whose factory returns a |
…rvers The agent builds each MCP tool call's `_meta` with the server's `toolMetaResolver` and passes it to `callTool`. The plugin's references dropped that argument, and the Worker-side server's resolver never ran, so MCP servers got no `_meta`. - `statelessMcpServer()` and `statefulMcpServer()` take a new `toolMetaResolver` option that the agent runs in the Workflow with the run context, as for a native server. - The references pass the `_meta` to the call-tool Activity, which passes it to the server's `callTool`. A `toolMetaResolver` on the factory's server needs the run context, so the Worker skips it and logs a warning.
- The stateful handle gives the toolMetaResolver option the name passed to statefulMcpServer(), not the internal suffixed one, as the stateless handle does. - The Worker warns about a toolMetaResolver on the factory's server only when the Workflow sent no _meta, and once per server. - The factoryArgument test checks that callTool gets no meta argument when there is no resolver. - README: older Workers drop _meta during an upgrade.
Both handle option types extend McpServerHandleOptions, so the toolMetaResolver option and its doc comment are written once. #209 adds toolFilter to the same interface.
The Worker can't run a resolver on the server the factory returns, since it needs the run context. Instead of skipping it with a warning, every MCP Activity for that server now fails with a non-retryable ApplicationFailure of type MCPToolMetaResolverUnsupported, as #209 does for a callable toolFilter.
c4c135b to
bfc90d6
Compare
DABH
left a comment
There was a problem hiding this comment.
Re-review at head bfc90d6 (eight commits over f395ae7; the branch was rebased since my review at 8dad56a, and the new work is the stateful serverName fix, the shared McpServerHandleOptions, and the switch from a Worker warning to a non-retryable refusal of a factory-side toolMetaResolver). In a worktree at the head: make sync, make lint (0 errors, the 8 existing warnings) and make test (248 pass, including the four new MCP tests). Probes, each a temporary test removed afterwards: a stateless factory server with a resolver, run through an agent, fails the Workflow in about 100 ms with ActivityFailure (testMcp-stateless-list-tools) caused by a non-retryable MCPToolMetaResolverUnsupported, with no connect() and no failed Workflow Task, so a stuck run is ruled out; the same refusal from a call-tool Activity does not fail the run (first comment); adding one await Promise.resolve() to the stateful handle's callTool path makes the new replay test fail with [TMPRL1100] (orderingAfterMcp versus orderingAfterGate), so the recorded History guards what it claims; making the Worker call callTool(name, args, meta ?? {}) fails the factoryArgument arity assertion. Not verified: a real two-version fleet; the upgrade-window statements come from the probe that simulates it and from reading the code. The branch now conflicts with main in the import block of test-openai-agents.ts after #215 (db14ec3); CI is green on the current base and needs a rerun after the rebase.
Severity: P1 = wrong result or stuck run in realistic use; P2 = correctness or robustness in an edge case; P3 = docs, tests, cleanup.
Previous rounds. Addressed: the stateful handle now gives the option serverName <name> (constructor wrap, asserted per server in the new test); the README states the mixed-fleet upgrade order (README:526); the factoryArgument test pins the two-argument call with no resolver; the option and its doc comment live once in McpServerHandleOptions; the stale draft line is gone from the body. Superseded: the per-call warning, replaced by the refusal. Accepted declines: agentAsTool dropping the run context is left to #270, which deletes it (until #270 lands, a nested agent's resolver still builds _meta from {}, so the two are best shipped in the same release); { signal } forwarding, a shared call-tool input type, the full-result Activity and a shared fake MCP server are follow-ups. On #208 I suggested keeping the warning and failing fast in a later breaking change; refusing here to match #209 is a reasonable call. The first two comments below are about where the refusal doesn't yet do what that decision promises. Nothing from earlier rounds is still open.
Where the problems cluster: the P2 and the first P3 are about how the refusal lands: from a tool call it turns into text for the model instead of failing the run, and on a stateful server it waits the schedule-to-start timeout, unlike #209's. The other two P3s are a missing export with stale doc comments, and the name fix not covering a resolver assigned on the handle.
Commenting rather than approving: new runs fail fast as intended, but the upgrade-window behavior of the refusal (P2) and its placement relative to #209 should be settled before this merges.
| factoryArgument?: unknown; | ||
| }) => { | ||
| const s = this.serverFactory(input.factoryArgument); | ||
| rejectToolMetaResolver(s); |
There was a problem hiding this comment.
P2: the refusal fails the run only when it comes from listing tools; from a tool call it becomes a tool output the model reads, so runs that cross the upgrade lose the tool without failing. Upstream runs every MCP tool call inside the function tool's error handling: the rejected callTool reaches invokeWithoutTimeout (tool.js:823-833 in agents-core 0.14.3), and because by default neither the handle nor the agent's mcpConfig sets an errorFunction, defaultToolErrorFunction (tool.js:559-561) turns the failure into text. Probe at the head: a stateless provider whose factory returns a server without a resolver for the list-tools Activity and with one for the call-tool Activity, which is what a run sees when it listed tools on an older Worker (a rolling upgrade without Worker Versioning, or a run open at the upgrade) and calls the tool on this version. The Workflow completes with 'final answer without the tool', History shows the call-tool Activity failed, the tool never ran, and the model's next input holds An error occurred while running the tool. Please try again. Error: ActivityFailure: Activity task failed. This needs the stateless handle's default cacheToolsList, so the run doesn't list again on the new Worker; a stateful run keeps the per-run Worker its session started on. So the body's "A run still open ... fails at its next MCP Activity for that server" holds only when that Activity is a listing; otherwise the failure shows up only as a failed Activity in History and the Worker log, and the model may answer without the data, where before this change the call succeeded without _meta. #209's call-tool refusal has the same path. The smallest fix is a sentence in the README section: remove a toolMetaResolver from the factory's server before upgrading Workers, because a run that listed tools on an older Worker gets a tool error instead of a failure from then on. Making the refusal fail the run would need an errorFunction on the handles that rethrows it (a throwing errorFunction propagates, tool.js:868-873), but a server's errorFunction takes precedence over the agent's mcpConfig.errorFunction (mcp.js:578-581), so that has its own cost.
There was a problem hiding this comment.
Thanks for the probe. I added the README sentence you suggested in 62599e6. A new run fails at its first list-tools Activity, but a stateless run that listed tools on an older Worker gets a tool error for each call to that server and keeps going, so remove the factory-side resolver before upgrading Workers. The body's upgrade line says the same now. I didn't add a rethrowing errorFunction on the handles, since it would take precedence over the agent's mcpConfig.errorFunction. #209 answers its call-tool refusal the same way.
|
|
||
| const server = this._serverFactory(input?.factoryArgument); | ||
| // Refuse before connecting, so the session fails at once instead of retrying the connection. | ||
| rejectToolMetaResolver(server); |
There was a problem hiding this comment.
P3: the stateful refusal doesn't behave like #209's, which is the reason given for refusing here instead of warning. This line refuses in the session Activity before connect(), so no dedicated Worker starts and an operation already scheduled waits its full schedule-to-start timeout (config.scheduleToStartTimeout, 30 s by default) before the handle rethrows the session failure. Through an agent that is the usual case, since the runner's first step after connect() is listTools(), scheduled in the same Workflow Task as the session; statefulMcpFactoryResolverWorkflow exercises the same timing directly with a 3 s timeout. That wait is also why stateful-mcp-client.ts needs _sessionRefusal, the extra handleWorkerFailure argument and the replay fixture. #209 at 055c3ad refuses a callable toolFilter in getServerOrThrow(), so its session connects and every operation fails at once with no Workflow-side change. Once both merge, a stateful server with a factory resolver stalls for the schedule-to-start timeout and fails from the session Activity, while one with a callable filter fails immediately from the operation Activity. Pick one placement before the second PR merges: if not connecting matters, move #209's check into the session as well; if fast failure matters, call rejectToolMetaResolver in getServerOrThrow() and drop the handle changes. Non-blocking.
There was a problem hiding this comment.
Moved it back to getServerOrThrow() in 602f1d1, where #209 refuses a callable toolFilter. The session connects and every operation fails at once, so I dropped _sessionRefusal, the extra handleWorkerFailure argument, the replay fixture and its Workflow. The stateful integration test now expects listTools() and callTool() to get the refusal and cleanup() to succeed.
| export const DEDICATED_WORKER_FAILURE_TYPE = 'DedicatedWorkerFailure'; | ||
|
|
||
| /** Error type for a `toolMetaResolver` on the server the factory returns, which the Worker refuses. */ | ||
| export const TOOL_META_RESOLVER_UNSUPPORTED_TYPE = 'MCPToolMetaResolverUnsupported'; |
There was a problem hiding this comment.
P3: TOOL_META_RESOLVER_UNSUPPORTED_TYPE isn't exported, unlike DEDICATED_WORKER_FAILURE_TYPE above it, so Workflow code that handles the refusal must hard-code the string. src/index.ts:15 and src/workflow.ts:15 export only DEDICATED_WORKER_FAILURE_TYPE, and the README describes that one as "exported as". The doc comments on statefulMcpServer() (stateful-mcp-client.ts:250-251) and StatefulMCPServerProvider (stateful-mcp-provider.ts:31-32) still say a dedicated Worker that never starts makes operations throw DedicatedWorkerFailure, which is no longer the whole story. Export the constant from both entry points and add a sentence to those two comments. Non-blocking.
There was a problem hiding this comment.
Exported from both entry points next to DEDICATED_WORKER_FAILURE_TYPE in aa51e5f. The README says "exported as" and lists it with the other exports, and the unit test now imports it from the package. With the refusal back in the operation Activities, the dedicated Worker starts as before, so the two doc comments are still right and I left them. #209 exports TOOL_FILTER_UNSUPPORTED_TYPE the same way.
| this._cacheToolsList = options?.cacheToolsList ?? true; | ||
| // Give the resolver the name the caller passed, as statelessMcpServer() does, not the suffixed one. | ||
| const toolMetaResolver = options?.toolMetaResolver; | ||
| this.toolMetaResolver = toolMetaResolver && ((context) => toolMetaResolver({ ...context, serverName: name })); |
There was a problem hiding this comment.
P3: the name fix covers only the option; a resolver assigned on the stateful handle still gets serverName <name>-stateful, and that is the path the README presents as rollback-safe. toolMetaResolver is a public field (line 115) and this wrap runs once in the constructor, so const s = statefulMcpServer('tickets'); s.toolMetaResolver = r; replaces it. Upstream builds the context from server.name (mcp.js:562), which here is ${name}-stateful (lines 118 and 137-139), while the same assignment on statelessMcpServer('tickets') gives tickets. README:528 names server.toolMetaResolver = ... next to the option without the caveat. Either wrap on assignment with an accessor pair that applies the same { ...context, serverName: name } override, or add one sentence to the README saying that a resolver set directly on a stateful handle sees the suffixed name. Non-blocking.
…escript-mcp-tool-meta-dropped # Conflicts: # typescript/openai-agents/src/__tests__/test-openai-agents.ts
… does Move the stateful refusal back to getServerOrThrow(), where #209 refuses a callable toolFilter. The session connects and every operation fails at once, with no Workflow-side change, so drop the handle's session-refusal handling, the ordering replay fixture and its Workflow.
Export the refusal's failure type from both entry points, next to DEDICATED_WORKER_FAILURE_TYPE, so Workflow code that handles it doesn't hard-code the string.
…'s name A run that listed tools on an older Worker gets the call-tool refusal as a tool error and keeps going, so say to remove a factory-side toolMetaResolver before upgrading Workers. Also say that a resolver set on a stateful handle gets the internal `<name>-stateful` name.
…escript-mcp-tool-meta-dropped # Conflicts: # typescript/openai-agents/README.md # typescript/openai-agents/src/__tests__/mcp-provider.test.ts # typescript/openai-agents/src/__tests__/test-openai-agents.ts # typescript/openai-agents/src/__tests__/workflows/openai-agents.ts # typescript/openai-agents/src/common/mcp-types.ts # typescript/openai-agents/src/index.ts # typescript/openai-agents/src/worker/mcp-provider.ts # typescript/openai-agents/src/worker/stateful-mcp-provider.ts # typescript/openai-agents/src/workflow.ts # typescript/openai-agents/src/workflow/mcp-client.ts # typescript/openai-agents/src/workflow/stateful-mcp-client.ts
DABH
left a comment
There was a problem hiding this comment.
Third round, at head 0af5470 (my last review was at bfc90d6; since then 602f1d1, aa51e5f and 62599e6, plus two merges of main, the second of which brings in #209). In a worktree at the head with pnpm 10.27.0: make lint (0 errors, the 8 existing warnings) and make test (254 pass). The body's replay check and #208 reproduction were run at 964bc6b, the original warn-only commit, so I re-ran replay at this head with a probe Workflow: a stateless or stateful handle with no resolver, a resolver assigned on the handle, the new option, or a resolver only on the factory's server, and one tool call, two parallel calls to one server, or parallel calls to two servers, recorded on origin/main 88745dc and on the head (18 histories each; the option only on the head, the factory's resolver only on main). All 18 main histories replay on the head, so upgrading the plugin is replay-safe. The head's histories replay on main except the option with calls to two servers, which fails with [TMPRL1100], as the README's rollback paragraph says. A resolver on the factory's server now fails a new run at its first list-tools Activity for both handle kinds (MCPToolMetaResolverUnsupported, no failed Workflow Task), and deleting the check from getServerOrThrow() makes the new stateful test fail with 'unexpected-success' twice. Refuted: a replay break on upgrade (above), and a lost option or README section in the #209 merge (both options share McpServerHandleOptions, and both sections are intact). Not verified: a live two-version fleet; the README's mixed-fleet sentence rests on main's handlers, which ignore the meta key.
Severity: P1 = wrong result or stuck run in realistic use; P2 = correctness or robustness in an edge case; P3 = docs, tests, cleanup.
Previous rounds. Addressed: the README and the body now say that a stateless run that listed tools on an older Worker gets a tool error from the refusal instead of failing, and that the factory's resolver should be removed before upgrading (the smallest fix I suggested; declining a rethrowing errorFunction because it would override mcpConfig.errorFunction is reasonable). The stateful refusal moved to getServerOrThrow(), where #209 refuses a callable filter, so the session connects, both operations fail at once, and _sessionRefusal, the extra handleWorkerFailure argument and the replay fixture are gone. TOOL_META_RESOLVER_UNSUPPORTED_TYPE is exported from both entry points, and the two doc comments are right again now that the dedicated Worker starts. The README says a resolver assigned on a stateful handle sees <name>-stateful (the probe records rv5sf-stateful for an assigned resolver and rv5sf for the option). The round-one fixes still hold. Accepted declines stand: { signal }, the shared call-tool input type, the full-result Activity and a shared fake server are follow-ups, and agentAsTool dropping the run context is left to #270, which is still open, so the two should ship in the same release. Every comment has a reply, and nothing from earlier rounds is still open.
Where the problems cluster: the code is right and the upgrade replays cleanly; all three items are documentation. The one that matters: this PR now requires everyone with a resolver on the factory's server to move it into Workflow code, and that move is itself a Workflow change that open runs can fail to replay.
Commenting rather than approving: nothing in the code blocks, but the README should say that adding a resolver to a Workflow with open runs needs a patched() guard or those runs to finish first (the P2 below), and that one sentence is all I'd want before approving.
Parity: the Python plugin forwards _meta through its call-tool Activity the same way, but on origin/main it accepts a tool_meta_resolver on the factory's server and silently ignores it: the v2 backend's factory check rejects only a callable tool_filter and an approval policy (_mcp_backend.py:163-164), the deprecated providers check only the approval policy, and the Python SDK reads the resolver only on the agent's side. After this PR, TypeScript fails a run that Python completes without _meta. A Python follow-up in the #275 pattern would line the two up; not a blocker here.
PR body and title: the title becomes the release-note line and names only the fix; naming the break would help readers of the notes, for example '... and refuse a toolMetaResolver on the factory's server (breaking)'. The #208 reproduction also gives a different result at this head than the body states: its factory server always sets toolMetaResolver, so both of its cases now hit the refusal and the script exits 2 at its first execute, not 1. To show the fix, it needs the resolver removed from the factory's server.
| }); | ||
| ``` | ||
|
|
||
| A new run with a `toolMetaResolver` on the factory's server fails at its first list-tools Activity. A `statelessMcpServer()` run that listed tools on an older Worker instead gets a tool error, which the model reads, for each call to that server, and the run keeps going. So remove the `toolMetaResolver` from the factory's server before you upgrade Workers. |
There was a problem hiding this comment.
P2: the migration the refusal points to is itself a Workflow code change that can fail replay of open runs, and the README describes the command change only as a rollback concern. The refusal's message, line 534 and the body's API paragraph all tell users with a resolver on the factory's server to pass it as the toolMetaResolver option. A run that is open across that deploy then replays a History recorded without a resolver. Because the agent awaits the resolver, a turn that called a tool on this server and a tool on another server in parallel now schedules the other server's Activity first. Reproduced at this head: a History recorded on origin/main 88745dc with statelessMcpServer('rv5sl') (resolver only on the factory's server, or none) plus statelessMcpServer('rv5plain'), where one model turn calls echo_a and plain_c in parallel. Replayed on the head with the Workflow changed only to pass a pure synchronous { toolMetaResolver }, it fails with [TMPRL1100] Nondeterminism error: Activity type of scheduled event 'rv5sl-stateless-call-tool' does not match activity type of activity command 'rv5plain-stateless-call-tool'. The stateful handle fails the same way with rv5sf-stateful-call-tool, and a resolver assigned on the handle reorders identically (main itself records rv5plain first once one is assigned). One call per turn and parallel calls to one server replay fine, and the same main histories replay on the head when the Workflow adds no resolver. So the plugin upgrade is safe; the break is the code change. That change is easy to judge safe, because it looks like it only adds _meta to Activity inputs, which replay does not compare. On a live Worker, each affected run then fails its Workflow Tasks until the change is reverted or patched. A resolver that changes the run context can break open runs the same way. Fix: one sentence after this paragraph and in the body's upgrade line, for example: 'Adding a resolver to a Workflow that has open runs, including moving one off the factory's server, can fail their replay for the reasons given below for a rollback, so guard it with patched() or let those runs finish first.'
There was a problem hiding this comment.
Agreed, and thanks for the reproduction. In e100cfa I added a paragraph after the rollback one: adding a resolver to a Workflow that has open runs, including moving one off the factory's server, can fail their replay for the same reasons, so guard the change with patched() or let those runs finish first. The body's API line says the same now.
| | `@temporalio/openai-agents/workflow-interceptor` | Worker bundling | Manual `workflowInterceptorModules` wiring without a plugin | | ||
|
|
||
| `@temporalio/openai-agents` exports `OpenAIAgentsPlugin`, MCP provider classes, `SandboxClientProvider`, model option types, hosted tool credential types, and `DEDICATED_WORKER_FAILURE_TYPE`. `OpenAIAgentsTraceClientInterceptor` is also public for Clients that need manual interceptor wiring instead of plugin registration. | ||
| `@temporalio/openai-agents` exports `OpenAIAgentsPlugin`, MCP provider classes, `SandboxClientProvider`, model option types, hosted tool credential types, `DEDICATED_WORKER_FAILURE_TYPE` and `TOOL_META_RESOLVER_UNSUPPORTED_TYPE`. `OpenAIAgentsTraceClientInterceptor` is also public for Clients that need manual interceptor wiring instead of plugin registration. |
There was a problem hiding this comment.
P3: the export lists name TOOL_META_RESOLVER_UNSUPPORTED_TYPE but not TOOL_FILTER_UNSUPPORTED_TYPE, which src/index.ts:15 and src/workflow.ts:15 export on the same line. The gap dates from #209, but this PR rewrites both sentences (here and line 747), and the tool-filter section already says 'exported as TOOL_FILTER_UNSUPPORTED_TYPE'. Add it to both lists. Non-blocking.
There was a problem hiding this comment.
Added TOOL_FILTER_UNSUPPORTED_TYPE to both lists in e100cfa.
| * Builds each tool call's MCP `_meta` in the Workflow, as for a native MCP server. It gets the | ||
| * run context and must be deterministic. Older plugin versions ignore this option and may not | ||
| * replay a History in which it ran, because running it can change the Workflow's commands or | ||
| * their order. |
There was a problem hiding this comment.
P3: this doc comment, which is what callers see on hover, doesn't say that the resolver's result is recorded in Workflow History. The README says so (line 544), and it is the caveat with a security cost: the values sit in the call-tool Activity input, visible in the Web UI without a payload codec. Add a sentence such as 'Its result is recorded in Workflow History as part of the call-tool Activity input, so it must not hold secrets.' Non-blocking.
There was a problem hiding this comment.
Added in e100cfa: "Its result is recorded in Workflow History as part of the call-tool Activity input, so it must not hold secrets."
- README: adding a resolver to a Workflow with open runs, including moving one off the factory's server, can fail their replay, so guard it with patched() or let those runs finish. - README: both export lists name TOOL_FILTER_UNSUPPORTED_TYPE too. - The option's doc comment says its result is recorded in History, so it must not hold secrets.
|
Thanks for the third round. e100cfa covers the three threads; replies are in each.
|
…escript-mcp-tool-meta-dropped
The same decision covers both languages: the Python plugin silently ignored a tool_meta_resolver on the server a factory returns, so the server got no _meta. temporal_mcp_server, StatelessMCPServerProvider and StatefulMCPServerProvider now refuse one with a non-retryable error, as they do a callable tool_filter and a require_approval policy, and the stateful session never connects such a server. The README and docstrings say so.
|
Following up on the Python parity note: I've added it here rather than in a separate PR. After merging |
DABH
left a comment
There was a problem hiding this comment.
Fourth round, at head 6161ecf (my last review was at 0af5470; since then e100cfa for that round's items, a merge of main at ca669af, and 6161ecf, which adds the Python refusal). In a worktree at the head: TypeScript make lint (0 errors, the 8 existing warnings) and make test (254 pass); Python make lint and make test (450 pass). The TypeScript source is unchanged since 0af5470 apart from the doc comment, and main hasn't changed typescript/openai-agents since my last base, so I replayed last round's 18 histories recorded on origin/main (stateless and stateful handles; no resolver, an assigned one, or one only on the factory's server; one call, parallel calls to one server, or parallel calls to two servers): all 18 replay on this head. Rerunning last round's P2 reproduction, the Workflow changed to pass a synchronous toolMetaResolver still fails the four histories with parallel calls to two servers with [TMPRL1100]; with the option behind patched(), as the README now says, all 12 migration histories replay, and new runs on that code record the marker, send _meta and replay. For Python, deleting any one of the three new refusal calls, or the resolver term in the stateful session's rejected condition, fails a test; through a dev server, temporal_mcp_server(tool_meta_resolver=...) delivers _meta to the factory's server, and a resolver on a v2 factory's server fails the run at its first list-tools Activity with a non-retryable error and no failed Workflow Task. The Python changes run only in Activities, so they can't affect replay. Both P2s below were reproduced at this head. Refuted: extra promise steps in the handles (the stateful wrapper returns the resolver's value synchronously); an uncovered Python operation (every operation on all three routes, the legacy Activity names included, runs the check before connecting); the connection pool retrying or swallowing the refusal; and the Python README's workflow.patched() advice being wrong (stricter than a synchronous resolver needs, since the SDK awaits only an awaitable result, but not wrong). Not verified: a live two-version fleet; the README's mixed-fleet sentence matches main's handlers, which ignore the meta key.
Severity: P1 = wrong result or stuck run in realistic use; P2 = correctness or robustness in an edge case; P3 = docs, tests, cleanup.
Previous rounds. Addressed: the README now says that adding a resolver to a Workflow with open runs, including moving one off the factory's server, needs a patched() guard or those runs to finish (the round-three P2; the guard works, above); both export lists name TOOL_FILTER_UNSUPPORTED_TYPE; and the option's doc comment says its result is recorded in History and must not hold secrets. The title names the break, the body gives the #208 reproduction's result at this head (exit 2), and Python no longer silently ignores the same misconfiguration. Accepted declines stand: { signal }, the shared call-tool input type, the full-result Activity and a shared fake server are follow-ups, and agentAsTool dropping the run context is left to #270, which is still open, so the two should still ship in the same release. Every comment has a reply, and nothing from earlier rounds is still open.
Where the problems cluster: the code is right in both languages and the upgrade replays cleanly; what's left is guidance. The Python refusal sends users of the deprecated providers to an API their route can't reach, and the new TypeScript section leaves out the resume case that its filter counterpart documents. Both are short fixes; the P3s are smaller doc and test gaps.
Commenting rather than approving: nothing in the code blocks, but the Python refusal's remedy leaves runs stuck when deprecated-provider users follow it, and the resolver section omits the resume case in which a tool call silently turns into an error; with those two fixed I'd approve.
Findings on lines outside the diff
python/openai_agents/src/temporalio/openai_agents/_temporal_openai_agents.py:372: P3: theOpenAIAgentsPlugindocstrings formcp_server_providers(lines 372-377) andmcp_servers(378-387) still name only a callabletool_filterand an approval policy as refused, although the body says the docstrings cover the new refusal. Addtool_meta_resolverto both, and formcp_serversthe pointer toworkflow.temporal_mcp_server(tool_meta_resolver=...). Non-blocking.
Parity: both languages now refuse a resolver on the factory's server and deliver _meta from a Workflow-side one. The remaining differences follow the earlier PRs: TypeScript fails with the exported type MCPToolMetaResolverUnsupported and its stateful session still connects the refused server (settled in the earlier rounds, as #209 does), while Python's ApplicationError has no type (.type is None in the probe) and its stateful session never connects. A type= on the Python error would let Workflow code match the refusal the same way in both languages; optional.
PR body and title: the squash subject becomes a line in both plugins' release notes, and 'send MCP tool call _meta' isn't new for Python (its handles already forwarded meta, and the body notes that temporal_mcp_server(tool_meta_resolver=...) already worked). Something like 'Breaking: refuse a tool meta resolver on the OpenAI Agents MCP factory's server and send _meta from the TypeScript MCP handles' reads right in both. The body's API paragraph repeats the Python remedy from the first P2.
| f"MCP server {name!r} sets tool_meta_resolver on its worker-side " | ||
| "MCPServer, which cannot run there because the run context it " | ||
| "receives exists only in the workflow; pass it to " | ||
| "temporal_mcp_server(tool_meta_resolver=...) and remove it from the " |
There was a problem hiding this comment.
P2: on the two deprecated routes this message, the Python README's paragraph for them (lines 550-553) and the body's API paragraph send users to temporal_mcp_server(tool_meta_resolver=...), which those routes can't reach; followed literally, it leaves new runs stuck. StatelessMCPServerProvider._create_server (_mcp.py:212) and StatefulMCPServerProvider's _server() (_mcp.py:522) raise this same text. temporal_mcp_server() schedules temporalio.mcp.<name>.* Activities, which only a factory registered with OpenAIAgentsPlugin(mcp_servers=...) provides, and without the mcp extra, which the README says the deprecated routes don't need (README lines 541-545), it raises RuntimeError in Workflow code (workflow.py:521-524). Reproduced through a dev server: with mcp_server_providers=[StatelessMCPServerProvider('HelloServer', ...)] unchanged and the Workflow switched to temporal_mcp_server('HelloServer', tool_meta_resolver=resolver), the run is still Running after 12 s, with temporalio.mcp.HelloServer.list-tools pending at attempt 5, last failure NotFoundError, retryable. For a run that is already open, switching routes also changes its Activity types, so it needs a patched() guard too. The neighbouring checks handle these routes separately: #220 gave stateless_mcp_server() and stateful_mcp_server() a require_approval parameter so #275's message can name the route, and #291's _LEGACY_TOOL_FILTER_REMEDY (_mcp.py:41-45) spells out the registration step. Neither deprecated function takes a tool_meta_resolver, but their Workflow-side servers honour an assigned one: a probe Workflow doing server = stateless_mcp_server('HelloServer'); server.tool_meta_resolver = resolver, and the same inside async with stateful_mcp_server(...) as server, delivered {'tenant': 't-7', 'tool': 'say_hello', 'server': 'HelloServer-stateless'} (and 'HelloServer-stateful') to the factory's server. Fix: give this check a remedy per route, as the other two have. Either add tool_meta_resolver to the two deprecated functions, as #220 did for require_approval, and name <route>(tool_meta_resolver=...); or say 'set tool_meta_resolver on the stateless_mcp_server() or stateful_mcp_server() object in workflow code, or register the factory with OpenAIAgentsPlugin(mcp_servers=...) and pass it to temporal_mcp_server(tool_meta_resolver=...)'. Then update README lines 550-553, the body and the assertion at tests/test_openai.py:3147. While in the README: the v2 paragraph (README lines 472-475) tells users to let open runs finish before upgrading, but for a resolver, removing it from the factory's server in the same deploy is enough, since it never had an effect; the deprecated paragraph and the TypeScript README already say so.
There was a problem hiding this comment.
Good catch, thanks. b2f2d76 gives each route its own remedy, as the other two checks have. On the deprecated providers the message now says to set tool_meta_resolver on the server that stateless_mcp_server() or stateful_mcp_server() gives the workflow, or to register the factory with OpenAIAgentsPlugin(mcp_servers=...) and pass it to temporal_mcp_server(tool_meta_resolver=...). I went with the message rather than a new parameter on the deprecated functions, since an assigned resolver already works there. The README paragraph, the body and the test assertion follow. The v2 paragraph now also says that removing a factory-side resolver in the same deploy is enough.
|
|
||
| ### MCP request metadata | ||
|
|
||
| A `toolMetaResolver` builds each tool call's MCP `_meta` from the run context, which exists only in the Workflow. Pass it as the `toolMetaResolver` option of `statelessMcpServer()` or `statefulMcpServer()`; it runs in Workflow code and must be deterministic. The call-tool Activity passes its result to the server's `callTool`. The Worker can't run a `toolMetaResolver` on the factory's server, so it refuses one: every list-tools and call-tool Activity for that server fails with a non-retryable `ApplicationFailure` of type `MCPToolMetaResolverUnsupported` (exported as `TOOL_META_RESOLVER_UNSUPPORTED_TYPE`). |
There was a problem hiding this comment.
P2: after a run resumes from a RunState, for example after a tool approval, the resolver gets the context rebuilt from JSON, and this section doesn't say so; the filter section does (line 526), and here the failure is quiet. The runner always rebuilds the state from its string form, even for the live result.state (src/workflow/runner.ts:286), so runContext.context then holds plain objects without class methods. Reproduced at this head: the context is { session: new TenantSession('tenant-7') } and the resolver returns { tenant: session.tenantId() }; the model calls the MCP tool, then a needsApproval tool; the Workflow approves and resumes with runner.run(agent, first.state), and the model calls the MCP tool again. The first call delivered {"tenant":"tenant-7"}. The second never reached the server: the model got the tool output 'An error occurred while running the tool. Please try again. Error: TypeError: runContext.context.session.tenantId is not a function', and the run completed with done. The example below, which reads plain data, is unaffected. Fix: one sentence after the example, mirroring line 526: 'A resolver also runs for tool calls after a run resumes from a RunState, for example after a tool approval, and then sees the context rebuilt from JSON: plain objects, without class methods. If it throws there, the model gets a tool error and the server isn't called.'
There was a problem hiding this comment.
Added your sentence after the example in ca75958.
|
|
||
| The `_meta` values are recorded in the call-tool Activity input in Workflow History, so don't put secrets in them. | ||
|
|
||
| A call-tool Activity that runs on a Worker with an older plugin version drops the `_meta`, and nothing fails. Upgrade every Worker on the Task Queue before Workflows rely on `_meta`, or use Worker Versioning. |
There was a problem hiding this comment.
P3: 'Upgrade every Worker on the Task Queue' doesn't say which queue, and a statelessMcpServer() handle with a taskQueue option schedules its call-tool Activity on that queue (src/workflow/mcp-client.ts:21-26), so an MCP Worker pool left on an older version keeps dropping _meta without an error. Suggested: 'Upgrade every Worker that runs the call-tool Activities, including Workers on a taskQueue you pass to statelessMcpServer(), before Workflows rely on _meta.' Non-blocking.
| assert "temporal_mcp_server()" in str(err.value) | ||
|
|
||
|
|
||
| def test_worker_side_tool_meta_resolver_is_rejected() -> None: |
There was a problem hiding this comment.
P3 (tests): nothing committed exercises the path every refusal now points to: no test passes tool_meta_resolver to temporal_mcp_server() or checks the meta the factory's server receives. grep -rn tool_meta_resolver tests/ finds only the two refusal tests, and InProcessMCPServer.call_tool (lines 125-132) forwards meta with no assertion on it, so the body's 'already worked' rests on no test. A probe passes at this head: a subclass of InProcessMCPServer that appends meta in call_tool, a Workflow with temporal_mcp_server('hello', tool_meta_resolver=resolver) where resolver returns {'tenant': 't-7', 'tool': ctx.tool_name, 'server': ctx.server_name}, a model making one say_hello call, and assert metas == [{'tenant': 't-7', 'tool': 'say_hello', 'server': 'hello'}]. Non-blocking.
There was a problem hiding this comment.
Added test_temporal_mcp_server_sends_tool_meta in b2f2d76. A RecordingServer records the meta the factory's server gets, the Workflow passes temporal_mcp_server("hello", tool_meta_resolver=...), and the test asserts {"tenant": "t-7", "tool": "say_hello", "server": "hello"} for both calls.
The deprecated providers sent users to temporal_mcp_server(), which their route can't reach. Their refusal now says to set tool_meta_resolver on the server stateless_mcp_server() or stateful_mcp_server() gives the workflow, or to move to OpenAIAgentsPlugin(mcp_servers=...) and temporal_mcp_server(tool_meta_resolver=...). The README says the same, and that removing a factory-side resolver in the same deploy is enough. The plugin's docstrings name the resolver, and a new test checks that temporal_mcp_server(tool_meta_resolver=...) sends _meta.
- A resolver also runs after a run resumes from a RunState and then sees the context rebuilt from JSON; if it throws, the model gets a tool error. - Upgrade every Worker that runs the call-tool Activities, including Workers on a taskQueue passed to statelessMcpServer().
|
Thanks for the fourth round. b2f2d76 (Python) and ca75958 (TypeScript README) cover the four threads; replies are in each.
|
DABH
left a comment
There was a problem hiding this comment.
Fifth round, at head ca75958 (my last review was at 6161ecf; since then b2f2d76 for the Python items and ca75958 for the TypeScript README). In a worktree at the head: Python make lint and make test (451 pass, one more than last round: the new meta test); TypeScript make lint (0 errors, the 8 existing warnings, none in files this PR touches) and make test (254 pass); CI is green. On a local trial merge with origin/main (61fe33a; main's only change in either plugin since the merge base is #166's Worker-plugin Activity check), TypeScript make lint and make test pass too (256 tests). I checked the fixes by rerunning last round's reproductions at this head rather than from the replies: through a dev server, the remedy on both deprecated routes and the refusal text on all three Python routes, and the TypeScript resume probe. I also probed a resolver assigned to each TypeScript handle (the stateless one gets rv7Stateless as serverName, the stateful one rv7Stateful-stateful, as README line 550 says), and mutated _TemporalMCPServer.call_tool to drop meta, which the new Python test catches ([None, None]). Replay: the TypeScript source and both lockfiles are byte-identical to 6161ecf, where last round's 18 histories recorded on origin/main replayed; main hasn't touched either plugin's Workflow code since; and the Python changes since then are the refusal text, which runs in Activities, and docstrings. So histories recorded on main still replay, and the rollback caveat for the new option stays disclosed in the README, the doc comment and the body. Checked and fine: the v2 client records meta in the call-tool Activity input, as the new Python README paragraph says. Not verified: a live mixed-version fleet.
Severity: P1 = wrong result or stuck run in realistic use; P2 = correctness or robustness in an edge case; P3 = docs, tests, cleanup.
Previous rounds. Both P2s from the last round are fixed, each rerun at this head. The deprecated providers' refusal now names a remedy their route can reach (_legacy_tool_meta_resolver_remedy, _mcp.py:48): with the resolver removed from the factory and assigned to the stateless_mcp_server() server, or inside async with stateful_mcp_server(...), both runs complete and the factory's server receives the _meta; the refusal text names each route's own function; README lines 552-557, the body and the test assertion follow; and the v2 paragraph now says that removing a factory-side resolver in the same deploy is enough. The TypeScript README has the RunState sentence (line 542), and last round's probe still does exactly what it says: the first call delivered {"tenant":"tenant-7"}, the call after the approval resume ended as the tool error TypeError: runContext.context.session.tenantId is not a function, the server was called once, and the run completed. The P3s are done too: the call-tool Worker wording (line 548), test_temporal_mcp_server_sends_tool_meta, both plugin docstrings, and the title, which now reads right in both plugins' release notes. Accepted decline: the Python error keeps no type, matching the #275 and #291 refusals; a change for all three belongs in its own PR. Earlier declines stand ({ signal }, the shared call-tool input type, the full-result Activity, a shared fake server), and agentAsTool dropping the run context is still left to #270, which is still open, so the two should ship in the same release. Every thread has a reply, and nothing from earlier rounds is open.
Parity: both languages refuse a resolver on the factory's server and deliver _meta from a Workflow-side one. The remaining differences (the TypeScript failure type, and the TypeScript stateful session connecting a server it refuses) were settled in earlier rounds; the one doc gap below is on the Python side.
Approving: both P2s from my last round are fixed and verified at this head, CI is green, replay is unaffected, and the one item left is a non-blocking README clause.
PR body, non-blocking: the test counts (248 TypeScript, 450 Python) predate the latest merges and this round's test (254 and 451 at this head), and the README bullet's "(upgrade every Worker on the Task Queue first, ...)" is now the narrower call-tool wording.
| `tool_meta_resolver` there, in every MCP operation, direct `call_tool()` and | ||
| prompt calls included; a static filter still works. On these routes, set a | ||
| resolver on the server that `stateless_mcp_server()` or `stateful_mcp_server()` | ||
| gives the workflow (`server.tool_meta_resolver = ...`). Remove such a filter or |
There was a problem hiding this comment.
P3: the deprecated routes' remedy doesn't say that the resolver then gets the suffixed server name, which the TypeScript README says for its equivalent case. Following this sentence through a dev server at this head (factory registered with StatelessMCPServerProvider('HelloServer', ...) or StatefulMCPServerProvider('HelloServer', ...) without a resolver, and {'tenant': 't-7', 'tool': ctx.tool_name, 'server': ctx.server_name} assigned as server.tool_meta_resolver in workflow code), both runs complete, and the factory's server receives 'server': 'HelloServer-stateless' and 'HelloServer-stateful'; temporal_mcp_server('HelloServer', tool_meta_resolver=...) gives 'HelloServer'. So a resolver that branches on server_name or forwards it, like the one in the new test_temporal_mcp_server_sends_tool_meta, behaves differently here with no hint, while TypeScript README line 550 states the same thing for a resolver assigned to a stateful handle (<name>-stateful). This paragraph also doesn't carry over what the v2 paragraph (lines 466-470 and 480-481) says about the move: the resolver runs in the workflow and must be deterministic, its result is recorded in history, and adding it to a workflow with open runs is a workflow change; a reader of the deprecated section may not have read that one. Suggested: '... gives the workflow (server.tool_meta_resolver = ...); it then gets <name>-stateless or <name>-stateful as server_name. As with temporal_mcp_server(), it runs in the workflow and must be deterministic, its result is recorded in workflow history, and adding it to a workflow with open runs needs workflow.patched() or those runs to finish first.' Non-blocking.
There was a problem hiding this comment.
Added your wording in 0a36fee: the resolver then gets <name>-stateless or <name>-stateful as server_name. Like with temporal_mcp_server(), it runs in the workflow and must be deterministic, its result is recorded in workflow history, and adding it to a workflow with open runs needs workflow.patched() or those runs to finish first.
A resolver set on the server stateless_mcp_server() or stateful_mcp_server() gives the workflow gets <name>-stateless or <name>-stateful as server_name. Also repeat for these routes what the v2 paragraph says: it runs in the workflow and must be deterministic, its result is recorded in history, and adding it to a workflow with open runs needs workflow.patched() or those runs to finish first.
|
Thanks for the approval and for rerunning the reproductions. 0a36fee adds the README clause from your thread. I also updated the body: the test counts are now 254 TypeScript and 451 Python, and the README bullet uses the narrower call-tool Worker wording. |
…escript-mcp-tool-meta-dropped # Conflicts: # typescript/openai-agents/src/__tests__/workflows/openai-agents.ts
What was changed
statelessMcpServer()andstatefulMcpServer()take themetaargument ofcallTooland put it in the call-tool Activity input, only when there is one, so the input of other calls doesn't change. The call-tool Activities pass it to the server'scallTool(toolName, args, meta), as the agent does for a native server.toolMetaResolveroption onstatelessMcpServer()andstatefulMcpServer(). The handle exposes it as itstoolMetaResolver, so the agent runs it in the Workflow with the run context, as for a native server. It must be deterministic. On the stateful handle it gets the name passed tostatefulMcpServer()asserverName, as on the stateless one, not the internal-statefulname.toolMetaResolveron the factory's server needs the run context, which only the Workflow has, so the Worker now refuses it with a non-retryableApplicationFailureof typeMCPToolMetaResolverUnsupported, exported asTOOL_META_RESOLVER_UNSUPPORTED_TYPE. Every list-tools and call-tool Activity for that server fails that way: the stateless ones before connecting, and the stateful ones ingetServerOrThrow(), where fix(openai-agents): apply MCP tool filters on the plugin's MCP servers (breaking) #209 refuses a callabletoolFilter. The handles add no promise steps.patched()or those runs to finish, that a resolver after aRunStateresume sees the context rebuilt from JSON, that a resolver set on a stateful handle gets<name>-statefulasserverName, that the_metavalues are recorded in History, so they must not hold secrets, that a Worker with an older plugin version drops_meta(upgrade every Worker that runs the call-tool Activities first, or use Worker Versioning), and that Workflows using the new option should finish before Workers roll back to an older plugin version.temporal_mcp_server,StatelessMCPServerProviderandStatefulMCPServerProvidernow refuse atool_meta_resolveron the factory's server with a non-retryableApplicationError, as they refuse a callabletool_filterand arequire_approvalpolicy since Breaking: reject a require_approval policy on the OpenAI Agents MCP factory's server #275. Before, it was silently ignored and the server got no_meta. The stateful session never connects such a server. Each route's message names a fix that route can reach:temporal_mcp_server(tool_meta_resolver=...), or on the deprecated providers, settingtool_meta_resolveron the server thatstateless_mcp_server()orstateful_mcp_server()gives the workflow. The Python README and docstrings say so. Both of those Workflow-side routes already worked.API: Caller-breaking. Before, a
toolMetaResolveron the factory's server was skipped and the run completed with no_meta. Now a new run fails at its first list-tools Activity for that server, even when the resolver returns nothing. To upgrade, move the resolver to the newtoolMetaResolveroption. That move is a Workflow change that can reorder parallel tool calls, so guard it withpatched()or let open runs finish first. The new option is additive, and a resolver set on the handle in Workflow code (server.toolMetaResolver = ...) now works too. Python is Caller-breaking the same way: a run whose factory's server setstool_meta_resolverused to complete without_metaand now fails at its first MCP Activity for that server; move the resolver to the Workflow side:temporal_mcp_server(tool_meta_resolver=...), or on the deprecated providersserver.tool_meta_resolver = ...on the serverstateless_mcp_server()orstateful_mcp_server()gives the workflow. Removing it from the factory's server in the same deploy is enough.Replay and rollback: Activity inputs are not compared on replay. The Python refusal runs only in Activities, so recorded results replay as before. The handles add no promise steps to
listTools()orcallTool(), so concurrent work keeps its command order. Histories recorded onmainreplay on this change. A run still open whose factory server has atoolMetaResolverfails at its next list-tools Activity for that server. A stateless run that already listed tools on an older Worker instead gets a tool error, which the model reads, for each call to that server, and keeps going; the README says to remove the resolver from the factory's server before upgrading Workers. Rollback tomain(there is no version gate) is safe only for some Workflows, becausemainignores the new option and doesn't run its resolver. An older version replays a History only if it produces the same commands in the same order:main, and the handles take the same promise steps, so the commands don't change. After a rollback, calls have no_metaagain.mainfails these histories with[TMPRL1100]. Let Workflows that use the option finish before rolling Workers back. The README and the option's doc comment state this.Why?
See #208. The agent builds each call's
_metawith the server'stoolMetaResolverand passes it tocallTool. The plugin's handles dropped that argument, and a resolver on the factory's server never ran, so MCP servers got no_meta. The Python plugin silently ignored atool_meta_resolveron the factory's server the same way.Checklist
Closes [Bug] openai-agents (TypeScript): MCP tool calls get no _meta from a toolMetaResolver #208
How was this tested:
MCP toolMetaResolver sends _meta on stateless and stateful serversinsrc/__tests__/test-openai-agents.ts. The Workflow passes a resolver built from the run context and the tool name; the server records the_metait gets. Withmain's provider and handle code (keeping the new option types so the test compiles), it fails at itst.deepEqual: the server gotundefinedtwice. With this change it gets{ tenant: 'tenant-7', tool: 'echo_meta', server: <name> }from both the stateless and the stateful handle, with the name each was created with. Without the stateful handle's name fix, the stateful call getsserver: 'metaStateful-stateful'.factoryArgument is passed through to MCP activitiesnow checks thatcallToolgets two arguments when there is no resolver. It fails if the handle sendsmeta: {}or the Worker passesmeta ?? {}.StatelessMCPServerProvider refuses a toolMetaResolver without connectinginsrc/__tests__/mcp-provider.test.ts(fix(openai-agents): apply MCP tool filters on the plugin's MCP servers (breaking) #209 adds tests to the same file): the server'sconnect()rejects; both Activities fail with a non-retryableTOOL_META_RESOLVER_UNSUPPORTED_TYPE, andconnect()is never called.Stateful MCP: a factory toolMetaResolver fails the operationsinsrc/__tests__/test-openai-agents.ts: the Workflow'slistTools()andcallTool()each get the non-retryable refusal, andcleanup()succeeds. Without the check ingetServerOrThrow(), both operations succeed and the test fails.make lintpasses (8 existing warnings, none in changed files),make testpasses (254 tests),make buildpacks, andcheck_npm_package.py,smoke.mjsandcheck_conventions.pypass.test_worker_side_tool_meta_resolver_is_rejectedandtest_temporal_mcp_server_sends_tool_meta(the Workflow-side resolver's_metareaches the factory's server) intests/test_mcp_v2.py, and atool_meta_resolvercase in the existingtest_mcp_server_factory_settings_are_rejected(stateless and stateful) intests/test_openai.py. Each fails with its refusal call removed. In Docker,make lintpasses andmake testpasses (451 tests, run with-n 4; with-n autoon a loaded machine, timing-sensitive tracing tests failed on both this branch andmain).62599e6, exits 0 (bug) on 1.24.0 and onmainatdb14ec3. With this change it exits 2: its factory server always setstoolMetaResolver, so its first run fails withMCPToolMetaResolverUnsupported. Showing the fix with it needs the resolver removed from the factory's server; the tests above cover the Workflow-side option.964bc6b, rerun at62599e6againstmainatdb14ec3with the same results) with a local dev server (Temporal CLI 1.9.1), stateless and stateful handles, with no resolver, a resolver set on the handle, and the new option with a synchronous resolver on a single MCP call, on a Worker with no Workflow cache:main's 6 histories (2 still open) replay onmainand on this change; this change's 8 replay on itself and onmain. Open runs carried across a Worker change complete with no failed Workflow Task, frommainto this change and back, and the carried histories replay on both. A control with the MCP server renamed fails all 6 with[TMPRL1100]. Review found option-resolver histories that replay on this change but fail onmainwith[TMPRL1100]: parallel MCP calls with a pure synchronous resolver, resolvers that change the run context, and resolvers that await an Activity or reject. That is why the rollback guidance above doesn't cover the option.CI covers the other Node versions and platforms.
Any docs updates needed?
The README section, included here.
Related: #209 (merged) fixed
toolFilterthe same way; this PR mergedmainafter it, keeping both changes in the sharedMcpServerHandleOptionsinterface, the refusals and the README.A resolver on the factory's server is refused, the same policy #209 uses for a callable
toolFilter.