Skip to content
NEWMarketplace and your team: sell what you build, and get plans and changes that are tested before you see them. See what is new

Library / AI Agents & Assistants

AI Agents & Assistants

Debug AI agent tool calls with OpenRouter, calculator and webhook

When an API call/webhook arrives, it runs an AI agent with OpenRouter and OpenAI / ChatGPT.

What it does

## Debug AI agent tool calls with OpenRouter, Calculator and OpenTelemetry ### Quick overview This workflow gives a support agent a Calculator tool and a simulated order lookup tool, so you can compare a correct calculation, a found order and an empty lookup that still reports success. It is the Exercise 4 template from the n8n Production AI Playbook post on Audit & Trace. Order data is synthetic. ### How it works 1. Receives a POST webhook request with a query. 2. Support Agent, an AI Agent using an OpenRouter chat model, decides which tool to call. 3. Calculator Tool handles arithmetic. Order Lookup Tool returns a simulated order, or an empty string for unknown orders. 4. Respond returns the agent's answer. ### Setup 1. Add an OpenRouter API credential to OpenRouter - Agent. If you change models, choose one that supports tool calling. 2. Optionally enable OpenTelemetry tracing in Settings > OpenTelemetry to see a span for each tool call. 3. Select Execute workflow and POST {"query":"What is 47 times 89?"} to the Webhook Test URL. Repeat with a query about order ORD-1001 and one about ORD-8888. 4. Compare the tool results in the agent logs with each reply to find the empty lookup.

The steps

  1. Webhook - Query
  2. Support Agent
  3. OpenRouter - Agent
  4. Calculator Tool
  5. Order Lookup Tool
  6. Respond

Similar automations