Repository navigation
Description
What happens
OpenAIAgentsPlugin (@temporalio/openai-agents) passes its Activities to SimplePlugin, whose
configureWorker merges them into the Worker's activities with { ...existing, ...param }.
When the Worker already has an Activity with one of the plugin's names, the plugin's function
replaces it. Worker.create succeeds, nothing is logged, and Workflows that call that name run
the plugin's handler instead of the caller's.
The plugin registers invokeModelActivity and invokeModelStreamActivity, and for each provider
Activities named after the provider: <name>-stateless-list-tools and
<name>-stateless-call-tool for a stateless MCP provider, <name>-stateful-server-session for a
stateful one, and 24 <name>-sandbox-... Activities for a sandbox client provider. SimplePlugin
documents plugin Activities as "appended", and the plugin README describes them as additions.
Reproduction
One file, no server. It calls the plugin's configureWorker, as Worker.create does. It exits 0
when both caller Activities are replaced without an error.
// issue_repro.js
const { OpenAIProvider } = require('@openai/agents-openai');
const { OpenAIAgentsPlugin, StatelessMCPServerProvider } = require('@temporalio/openai-agents');
const caller = async () => 'caller handler';
const plugin = new OpenAIAgentsPlugin({
modelProvider: new OpenAIProvider({ apiKey: 'unused' }),
mcpServerProviders: [new StatelessMCPServerProvider('docs', () => { throw new Error('not called'); })],
});
let replaced = 0;
for (const name of ['invokeModelActivity', 'docs-stateless-call-tool']) {
try {
const { activities } = plugin.configureWorker({ taskQueue: 'tq', activities: { [name]: caller } });
const kept = activities[name] === caller;
console.log(`${name}: Worker options built; the caller's handler was ${kept ? 'kept' : "replaced by the plugin's"}`);
if (!kept) replaced += 1;
} catch (err) {
console.log(`${name}: ${err.name}: ${err.message}`);
}
}
process.exit(replaced === 2 ? 0 : 1);With @temporalio/openai-agents 1.24.0 (npm) and with the package built from this repository's
main (5e91c26), both with @temporalio/* 1.24.0, @openai/agents-openai 0.14.3 and Node 24.22:
$ node issue_repro.js
invokeModelActivity: Worker options built; the caller's handler was replaced by the plugin's
docs-stateless-call-tool: Worker options built; the caller's handler was replaced by the plugin's
exit=0
On a real Worker and dev server, the same setup gives:
- a Workflow calling the caller's
docs-stateless-call-toolgets
[{"type":"text","text":"plugin MCP handler"}]and completes; the caller's handler ran 0 times; - a Workflow calling the caller's
invokeModelActivityruns the plugin's model handler, which
fails withCannot read properties of undefined (reading 'systemInstructions'); - a caller
docs-stateful-server-sessionand a callerbox-sandbox-client-createnever run; the
plugin's handlers call the stateful server factory and the sandbox client'screate().
Controls: on a Worker without the plugin, each caller Activity runs its own handler. A plugin
with distinct provider names runs each provider's handler.
Expected
The caller's Activity runs, or Worker.create refuses the duplicate name with a clear error.
The Temporal Python and Go SDKs refuse a second Activity with the same name.
Impact
A silent wrong result: the Workflow gets the plugin's answer for a call to the caller's own
Activity, with no error or warning. The trigger needs a caller Activity with one of the plugin's
names, which is uncommon.
Proposed fix
In OpenAIAgentsPlugin.configureWorker, before calling super.configureWorker, throw a
TypeError when options.activities already has one of the plugin's Activity names with a
function that no OpenAIAgentsPlugin built:
Duplicate registration of Activity '<name>': OpenAIAgentsPlugin would replace a different Activity with this name. Rename or remove the other registration.
Functions that an OpenAIAgentsPlugin built stay replaceable, as before. This is a compatibility
choice for setups that start today with a prebuilt Workflow bundle: one instance on both the
NativeConnection and the Worker (where configureWorker runs twice), and two instances on one
Worker, where the last one's Activities serve the calls. No document promises these Worker setups:
the README's "the last config header wins" is about the Client plugin's header, and it asks for one
instance per Client or Connection configuration. With workflowsPath both setups already fail at
Worker.create with a webpack duplicate-entry error, a separate issue. Activity names, inputs and
History do not change.
This is a breaking change for Workers that start today with a colliding Activity: they now fail
at Worker.create and must rename or remove that Activity.
A branch with the fix, a unit test and a README note is ready:
fix/openai-agents-typescript-same-name-activities-replaced.
Related: #159 reports the same bug in GoogleAdkPlugin (@temporalio/google-adk).
Activity