Tool calling bug for agents using OpenRouter (various models)

Describe the problem/error/question

I’m finding an issue with tool calling where agents produce empty tool calls when used in a flow.

Flow setup: Schedule trigger node → AI Agent (with openrouter + tool) → Merge node (and others tested)

When executing the AI Agent using the “Execute step” button the tool works perfectly but when executing the node as part of the flow including live production flows, the tool calls fail silently (they don’t appear to even be used by the agent in the UI but they do appear in the logs as empty calls). They sometimes appear empty and sometime appear inside of the AI agents input.

Notes:

  • Various models tested and I ensured they had sufficient token context lengths. I found this issue across at least 6 different tool capable models of different costs.
  • Various tools tested (brave search, gmail, http node) all failed the same way

Does anyone have experience fixing this or is it a bug?

What is the error message (if any)?

No error message but tool calls come back empty when executed as part of a flow

Please share your workflow

Correct: Using “execute step” button
Tool call work well and input and output. The node UI (Not pictured) also lights up green with check marks

Bugged: From within a flow
The tools during run time don’t appear in the logs but magically appear at the end however they are empty calls and seem to do things like inject tool calls into the input.

Example of tool call in AI input
image

Example of tool fail in the UI showing a tool call in the logs but not in the UI

Example of tool running correctly when using "Execute step

Related issue: Tool calling bug for agents using OpenRouter (various models) · Issue #29758 · n8n-io/n8n · GitHub

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

Example when failing
[ { "response": { "generations": [ [ { "text": "I'm sorry, but I could not find any relevant information in the emails I have access to. Was there anything else I could help you with?", "generationInfo": { "finish_reason": "stop" } } ] ] }, "tokenUsage": { "completionTokens": 31, "promptTokens": 607, "totalTokens": 638 } } ]

Information on your n8n setup

  • n8n version: 2.18.7

This is expected. Not all AI models work reliably with tool calls.
What models are you using?
Declaring tool calling schema may improve the reliability of your tool calls.
You need to trial and error

The n8n AI team has already identified this issue, the linked GitHub issue has been marked status:in-linear, and team:ai, which means this issue is currently being worked on.
The problem is related to the way the AI Agent node interacts with context when it is executed step by step versus when executed as part of the complete workflow. When executed as part of the workflow, the OpenRouter input context trigger is either ignored in the tool call schema, or it is embedded in the prompt as is and it cannot perform any function call. This is not an OpenRouter specific issue, this happens because of n8n’s request during the production execution.
Currently the only consistent workaround is to not chain the AI Agent directly after nodes in production, use test with a simple trigger → agent → output setup to isolate it, and keep an eye on the fix in the GitHub issue:

Are you using n8n Cloud, or do you have your own self-hosted with docker? The debug information shows you are using docker (cloud) version 2.18.7 , just checking because the fix will probably be in a patch version, and it will be useful to know when to perform the updates.

Hi Miliaga, thanks for your response! I’ll try and parse the information in a different way for now as a workaround.

I’m using n8n Cloud I’ll keep a lookout for the update.

@ChrisA quick workaround till that fix lands: swap the OpenRouter Chat Model for the OpenAI Chat Model node. In the OpenAI cred, set Base URL to OpenRouter and paste your OpenRouter key. Model name = your slug (e.g. anthropic/claude-3.5-sonnet), then rewire it to the Agent. Going through n8n’s OpenAI path skips the schema bug causing those empty finish_reason: stop calls when the agent fires from a trigger instead of Execute Step.

Great thread, @ChrisA! Good that the n8n team is already tracking this.

Just to add a bit more context on why this happens: the discrepancy between “Execute step” and full flow execution comes from how the execution context is constructed. When you trigger via Execute Step, n8n builds a fresh context for just that node. But in a full flow, the upstream context from the Schedule Trigger gets passed through, and the OpenRouter Chat Model node’s schema handling doesn’t correctly process the finish_reason: stop signal in that scenario, which causes the agent to skip the tool call entirely.

@achamm’s workaround is exactly right - using the OpenAI Chat Model node with Base URL pointing to OpenRouter is currently the most reliable fix because it uses n8n’s native OpenAI code path, which handles the schema correctly.

A couple of other things worth trying while you wait for the official fix:

  • Switch to a model that’s hosted directly on OpenRouter but is known to be OpenAI-compatible in its tool_call schema (like openai/gpt-4o-mini via OpenRouter) to narrow down if it’s a model-specific schema variance
  • Try wrapping just the AI Agent node in its own sub-workflow with a manual trigger to eliminate any upstream context bleed

Hope the patch lands soon on n8n Cloud!