#25499·mastra

[BUG] Inngest agent: call-time clientTools are dropped when the Inngest worker is a different process from the caller

Author: roaminroCreated Sep 29, 2026Updated Sep 30, 2026
LabelsbugAgentscustomer-engimpact:mediumeffort:mediumInngestDurable Agentsstatus: auto-triaged

Describe the Bug

Tools passed at call time with clientTools never reach an Inngest worker running in a different process from the caller. The worker builds the step's tool set from the agent's registered tools only, so the model is never offered the client tool. A separate worker is the normal Inngest deployment topology.

  • With the default toolChoice, the model can't call the tool. It answers in text or calls a different tool.
  • With toolChoice: { type: 'tool', toolName: '<client tool>' }, the provider rejects the request: OpenAI returns 400 Tool choice 'lookup_weather' not found in 'tools' parameter.

The same code works when the worker runs in the calling process, where the in-process run registry still holds the call-time tools. Tools registered on the agent without execute are unaffected in both topologies.

Steps To Reproduce

json
{
  "type": "module",
  "dependencies": {
    "@mastra/core": "1.72.0-alpha.5",
    "@mastra/inngest": "1.10.1-alpha.3",
    "@mastra/libsql": "1.24.0-alpha.1",
    "inngest": "4.21.0",
    "zod": "4.6.5"
  },
  "devDependencies": { "inngest-cli": "1.45.1", "tsx": "4.23.15" }
}

(npm install --legacy-peer-deps is required: npm rejects the @mastra/inngest alpha peer range for a core prerelease.)

reproduce.ts:

typescript
// Terminal 1: npx tsx reproduce.ts worker
// Terminal 2: npx inngest-cli dev -u http://127.0.0.1:4869/api/inngest --port 8969 --no-discovery
// Terminal 3: npx tsx reproduce.ts caller
// Control (worker inside the caller; stop terminal 1 first): npx tsx reproduce.ts same-process
import { createServer } from 'node:http';
import { Agent } from '@mastra/core/agent';
import { Mastra } from '@mastra/core/mastra';
import type { ProcessInputStepArgs } from '@mastra/core/processors';
import { createTool } from '@mastra/core/tools';
import { LibSQLStore } from '@mastra/libsql';
import { createInngestAgent, createServe } from '@mastra/inngest';
import { Inngest } from 'inngest';
import { serve } from 'inngest/node';
import { z } from 'zod';

const inngest = new Inngest({ id: 'client-tools-worker', isDev: true, baseUrl: 'http://127.0.0.1:8969' });

const agent = createInngestAgent({
  inngest,
  agent: new Agent({
    id: 'repro',
    name: 'Repro',
    model: 'openai/gpt-4o-mini',
    instructions: 'Call the tool the user asks for exactly once.',
    tools: {
      // Registered client tool (no execute) — control: this one reaches the worker.
      approve_invoice: createTool({ id: 'approve_invoice', description: 'Ask the user to approve an invoice.', inputSchema: z.object({ invoice: z.string() }) }),
    },
    // Logs which tools each step actually offers the model, and in which process.
    inputProcessors: [{
      id: 'log-tools',
      processInputStep({ tools, stepNumber }: ProcessInputStepArgs) {
        console.log(`[pid ${process.pid}] step ${stepNumber} offers:`, Object.keys(tools ?? {}).sort());
        return {};
      },
    }],
  }),
});

const mastra = new Mastra({ agents: { agent }, storage: new LibSQLStore({ id: 'repro', url: 'file:./repro.db' }) });

const mode = process.argv[2];
if (mode === 'worker' || mode === 'same-process') {
  await new Promise<void>(r => createServer(createServe(serve)({ mastra, inngest })).listen(4869, '127.0.0.1', r));
  console.log(`worker pid ${process.pid} on :4869`);
  // Sync this app with the Inngest dev server and wait until both durable functions are registered.
  await fetch('http://127.0.0.1:4869/api/inngest', { method: 'PUT' });
  for (;;) {
    const r = await fetch('http://127.0.0.1:8969/v0/gql', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ query: '{ apps { functions { name } } }' }) });
    const { data } = await r.json() as { data: { apps: { functions: { name: string }[] }[] } };
    if (data.apps.flatMap(a => a.functions).length >= 2) break;
    await new Promise(r => setTimeout(r, 500));
  }
}
if (mode === 'caller' || mode === 'same-process') {
  console.log(`caller pid ${process.pid}`);
  const lookupWeather = createTool({ id: 'lookup_weather', description: 'Look up the weather for a city. Runs on the client.', inputSchema: z.object({ city: z.string() }) });
  const result = await agent.stream('Look up the weather in Paris with lookup_weather.', {
    clientTools: { lookup_weather: lookupWeather },
    modelSettings: { temperature: 0 },
  });
  const output = await result.output.getFullOutput();
  console.log('finishReason:', output.finishReason);
  console.log('tool calls:', output.toolCalls.map(c => c.payload.toolName));
  result.cleanup();
  process.exit(0);
}

Observed (3 trials each, OPENAI_API_KEY set)

Topology Tools offered at step 0 (logged on the worker) Result
Separate worker (worker + caller) ['approve_invoice'] 3/3 finishReason: stop, no tool calls
Same process (same-process) ['approve_invoice', 'lookup_weather'] 3/3 finishReason: tool-calls, calls lookup_weather

The step ran on the worker's PID, not the caller's, in every separate-worker trial. In a larger harness with the same setup the model instead called the registered approve_invoice for the weather request (3/3), and forcing toolChoice produced the OpenAI 400 above.

Expected Behavior

Call-time clientTools should be offered to the model by whichever process runs the step. A call to one should end the turn with a pending call, as #23612 made it do for the in-process case. If call-time client tools can't be supported on Inngest workers, stream()/generate() should reject them with a clear error instead of silently dropping them.

Likely cause (from source, main f36019c241; not runtime-tested on main)

  • Preparation resolves clientTools into the run's tools (packages/core/src/agent/durable/preparation.ts, getToolsForExecution({ toolsets, clientTools, ... })). The results live only in the calling process's globalRunRegistry.
  • SerializableDurableOptions (packages/core/src/agent/durable/types.ts) has no clientTools or toolsets field, so the trigger event doesn't carry them.
  • On a worker whose registry misses, rebuildRunToolsFromMastra (packages/core/src/agent/durable/utils/resolve-runtime.ts) calls agent.getToolsForExecution({ runId, threadId, resourceId, requestContext, memoryConfig, autoResumeSuspendedTools }) with no clientTools, so only the agent's registered tools come back.

Call-time toolsets probably fail the same way, but I haven't tested that.

Environment

  • @mastra/core 1.72.0-alpha.5, @mastra/inngest 1.10.1-alpha.3, @mastra/libsql 1.24.0-alpha.1
  • inngest 4.21.0, inngest-cli 1.45.1 dev server
  • Node 22, macOS, openai/gpt-4o-mini

Related

  • #23295 / PR #23612: the durable loop stops at a client-executed tool call. This works here when the tool is available to the worker.
  • #21637: server tool results dropped when a client tool is pending in the same step. That isn't reproduced here; mixed steps behave correctly in-process.