Skip to content

[Bug] google-adk: GoogleAdkPlugin silently replaces another Activity with the same name #159

Closed

Description

@campoy

What are you really trying to do?

Run GoogleAdkPlugin on a Worker that also has other Activities or plugins, and have each Activity name served by the handler registered for it.

Describe the bug

GoogleAdkPlugin registers Activities named adk-invokeModel and adk-invokeModelStreaming, plus <name>-listTools, <name>-callTool, <name>-listResources and <name>-readResource for each MCP toolset. SimplePlugin.configureWorker merges them into the Worker's Activities with { ...existing, ...param }. When a name is already taken, the plugin's Activity replaces the existing one. Worker.create succeeds, nothing is logged, and Workflows that schedule that name reach a different handler.

These setups lose a handler:

  • a caller Activity with one of these names in the Worker's activities;
  • two GoogleAdkPlugins with different options on one Worker, including one on the NativeConnection and one on the Worker: the last one serves every call;
  • another integration's Activity with the same name, registered before GoogleAdkPlugin. AiSdkPlugin (@temporalio/vercel-ai-sdk) uses the same <server>-listTools and <server>-callTool names for its MCP servers, and has the same bug in the other order: [Bug] vercel-ai-sdk: AiSdkPlugin silently replaces another Activity with the same name #160.

The constructor comment says the object form is there so that registering the plugin twice "is tolerated rather than a crash". That covers the same instance registered twice, whose handlers are identical. It does not cover a different handler.

Minimal Reproduction

One file, no server. It calls configureWorker in order, as Worker.create does. It exits 0 when every case is replaced without an error.

// GoogleAdkPlugin silently replaces a different Activity with the same name.
// No server: this calls configureWorker in order, as Worker.create does.
// Exits 0 when every case is replaced without an error (the bug), 1 otherwise.
const { GoogleAdkPlugin } = require('@temporalio/google-adk');
const { fakeModelProvider } = require('@temporalio/google-adk/testing');

const configure = (plugins, options) => plugins.reduce((o, p) => p.configureWorker(o), options);
const owner = (activities, name, candidates) =>
  Object.entries(candidates).find(([, fn]) => fn === activities[name])?.[0] ?? 'unknown';

const callerFn = async () => 'caller handler';
const a = new GoogleAdkPlugin({ modelProvider: fakeModelProvider() });
const b = new GoogleAdkPlugin({ modelProvider: fakeModelProvider() });
const ownFn = (p, name) => p.options.activities[name];

const cases = [
  ['caller adk-invokeModel + GoogleAdkPlugin', [a], { 'adk-invokeModel': callerFn }, 'adk-invokeModel',
    { caller: callerFn, plugin: ownFn(a, 'adk-invokeModel') }, 'caller'],
  ['GoogleAdkPlugin A then B (different modelProvider)', [a, b], undefined, 'adk-invokeModel',
    { A: ownFn(a, 'adk-invokeModel'), B: ownFn(b, 'adk-invokeModel') }, 'A'],
];
let replaced = 0;
for (const [label, plugins, activities, name, candidates, lost] of cases) {
  try {
    const out = configure(plugins, { taskQueue: 'tq', activities });
    const kept = owner(out.activities, name, candidates);
    console.log(`${label}: Worker keeps ${kept}'s ${name}; ${lost}'s handler is gone, no error`);
    if (kept !== lost) replaced++;
  } catch (e) {
    console.log(`${label}: ${e.name}: ${e.message}`);
  }
}
console.log(replaced === cases.length ? 'BUG: every collision silently replaced a handler' : `${cases.length - replaced} of ${cases.length} collisions were refused`);
process.exit(replaced === cases.length ? 0 : 1);

Output, exit status 0:

caller adk-invokeModel + GoogleAdkPlugin: Worker keeps plugin's adk-invokeModel; caller's handler is gone, no error
GoogleAdkPlugin A then B (different modelProvider): Worker keeps B's adk-invokeModel; A's handler is gone, no error
BUG: every collision silently replaced a handler

The plugin built from main at 5e91c26 gives the same output.

The same setups on real Workers with a local dev server:

  • With a caller adk-invokeModel and GoogleAdkPlugin, a Workflow that calls adk-invokeModel got the plugin's model answer. The caller's handler ran 0 times.
  • With two GoogleAdkPlugins, the last instance's model provider answered every call, in both orders. A default instance on the NativeConnection replaced a custom one on the Worker, because the SDK runs connection plugins after the Worker's.
  • With AiSdkPlugin and then GoogleAdkPlugin sharing one MCP server name, the ADK Workflow reached its own server. The AI SDK Workflow never reached a server and failed every Workflow Task (schema is not a function) until its execution timeout.
  • Controls: each registration alone answers with its own handler, the same plugin instance on the NativeConnection and the Worker works, and distinct MCP server names keep both plugins.

Environment/Versions

  • OS and processor: Linux x86_64 (Docker)
  • @temporalio/google-adk 0.1.0, and main at 5e91c26 (its src/ equals the release tag)
  • @temporalio/plugin and @temporalio/worker 1.24.0, @google/adk 2.0.0, Node v24.22.0
  • Real-Worker runs: Temporal CLI 1.9.1 (Server 1.32.0); the cross-integration run also used @temporalio/vercel-ai-sdk 1.0.0 and ai 7.0.127

Additional context

Expected: Worker.create fails with a clear error when GoogleAdkPlugin would replace a different Activity with the same name. The same instance, or one built from the same options, registered twice should still start, since its handlers do the same thing.

Proposed fix (PR to follow): GoogleAdkPlugin overrides configureWorker. Before calling super.configureWorker, it compares its Activities with the Worker's, and a name taken by a different function throws:

TypeError: Duplicate registration of Activity 'adk-invokeModel': GoogleAdkPlugin would replace a different Activity with this name. Rename or remove the other registration, or give each GoogleAdkPlugin on this Worker the same options.

Each plugin Activity records the operation it was built for and what it was built from, so the same instance twice, or two instances built from one options object, still start.

This is a breaking change for Workers that start today with a collision: they would fail in Worker.create. Activity names, inputs and results don't change, so recorded histories replay unchanged.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions