n8n - ✅(Solved) Fix AI tool call events not emitted for ToolWorkflow, ToolHttpRequest, and ToolCode — log streaming blind spot [1 pull requests, 2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
n8n-io/n8n#28532Fetched 2026-04-16 07:05:11
View on GitHub
Comments
2
Participants
2
Timeline
5
Reactions
0
Author
Timeline (top)
commented ×2labeled ×1mentioned ×1subscribed ×1

Error Message

  • error: all

PR fix notes

PR #28599: fix(nodes-langchain): emit ai-tool-called log streaming event for ToolWorkflow, ToolCode, and ToolHttpRequest

Description (problem / solution / changelog)

Fixes #28532

Problem

When an AI agent uses the Call n8n Sub-Workflow Tool (toolWorkflow), HTTP Request Tool (toolHttpRequest), or Code Tool (toolCode) as tools, the n8n.ai.tool.called log streaming event is never emitted. External observability systems subscribed to this event receive no signal that these tools were invoked.

Root cause: These three tool types use a manual logging execution pattern where they call addInputData/addOutputData directly. This bypasses the logWrapper proxy from @n8n/ai-utilities, which normally intercepts the LangChain _call method and emits ai-tool-called via logAiEvent. Because these tools never go through logWrapper, logAiEvent is never called.

Solution

Call logAiEvent(ctx, 'ai-tool-called', { query, response }) in the success branch of each tool's handler, consistent with the pattern used by logWrapper for LangChain-native tools:

  • WorkflowToolService.ts (ToolWorkflow v2): added after addOutputData in the manualLogging success branch
  • ToolCode.node.ts: added after addOutputData in the else if (log) success branch
  • ToolHttpRequest/utils.ts (configureToolFunction): added after addOutputData in the else success branch

Testing

Added unit tests in ToolWorkflowV2.test.ts verifying:

  • logAiEvent is called with 'ai-tool-called' and the correct query/response data when manualLogging=true
  • logAiEvent is NOT called when manualLogging=false (engine-called path)

Changed files

  • packages/@n8n/nodes-langchain/nodes/tools/ToolCode/ToolCode.node.ts (modified, +2/-1)
  • packages/@n8n/nodes-langchain/nodes/tools/ToolHttpRequest/utils.ts (modified, +3/-0)
  • packages/@n8n/nodes-langchain/nodes/tools/ToolWorkflow/v2/ToolWorkflowV2.test.ts (modified, +74/-0)
  • packages/@n8n/nodes-langchain/nodes/tools/ToolWorkflow/v2/utils/WorkflowToolService.ts (modified, +2/-1)
RAW_BUFFERClick to expand / collapse

Bug Description

When an AI agent uses the Call n8n Sub-Workflow Tool (toolWorkflow), HTTP Request Tool (toolHttpRequest), or Code Tool (toolCode) as tools, the n8n.ai.tool.called log streaming event is never emitted — not on success, and not on failure. This means external observability systems (webhook destinations, log aggregators, etc.) receive no signal that these tools were invoked at all.

This affects the three tool types that are almost universally used in production AI agent workflows.

To Reproduce

  1. Create an AI agent workflow using a Call n8n Sub-Workflow Tool or HTTP Request Tool
  2. Configure a log streaming webhook destination and subscribe to n8n.ai.tool.called (via the "Tool called" checkbox in the Events tab)
  3. Execute the workflow
  4. Observe that no n8n.ai.tool.called event is received at the destination, even though the tool was invoked and the execution data is visible in the n8n UI

Expected behavior

Every tool invocation — including success and failure — should emit an n8n.ai.tool.called log streaming event, consistent with what the UI already tracks and what the event bus infrastructure already supports.

Debug Info

Debug info

core

  • n8nVersion: 2.16.0
  • platform: docker (self-hosted)
  • nodeJsVersion: 24.14.1
  • nodeEnv: production
  • database: postgres
  • executionMode: scaling (multi-main)
  • concurrency: -1
  • license: enterprise (production)
  • consumerId: 507fd647-278d-418c-8e5b-e4fbfecd6aaf

storage

  • success: all
  • error: all
  • progress: false
  • manual: true
  • binaryMode: s3

pruning

  • enabled: true
  • maxAge: 720 hours
  • maxCount: 75000 executions

client

  • userAgent: mozilla/5.0 (macintosh; intel mac os x 10_15_7) applewebkit/537.36 (khtml, like gecko) chrome/147.0.0.0 safari/537.36
  • isTouchDevice: false

Generated at: 2026-04-15T14:03:26.879Z

Operating System

Ubuntu

n8n Version

2.16.0

Node.js Version

24.14.1

Database

PostgreSQL

Execution mode

queue

Hosting

self hosted

extent analysis

TL;DR

The n8n.ai.tool.called log streaming event is not emitted when using certain tools, such as Call n8n Sub-Workflow Tool, HTTP Request Tool, or Code Tool, which can be fixed by investigating the event emission logic in the n8n workflow engine.

Guidance

  • Verify that the log streaming webhook destination is correctly configured to receive the n8n.ai.tool.called event and that the "Tool called" checkbox is enabled in the Events tab.
  • Check the n8n workflow engine code to ensure that the event emission logic is correctly implemented for the affected tools (Call n8n Sub-Workflow Tool, HTTP Request Tool, and Code Tool).
  • Investigate potential issues with the event bus infrastructure that might be preventing the n8n.ai.tool.called event from being emitted.
  • Review the n8n version (2.16.0) and Node.js version (24.14.1) to ensure that there are no known issues or compatibility problems that could be causing the problem.

Example

No code snippet is provided as the issue is related to the n8n workflow engine and event emission logic, which requires a deeper investigation of the codebase.

Notes

The issue might be specific to the n8n version (2.16.0) or the Node.js version (24.14.1) used, and upgrading to a newer version might resolve the problem. However, without further investigation, it is difficult to determine the root cause of the issue.

Recommendation

Apply a workaround by manually emitting the n8n.ai.tool.called event in the workflow code or by using an alternative logging mechanism until the root cause of the issue is identified and fixed. This is because the issue affects critical tools used in production AI agent workflows, and a workaround can provide temporary relief until a permanent fix is available.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Every tool invocation — including success and failure — should emit an n8n.ai.tool.called log streaming event, consistent with what the UI already tracks and what the event bus infrastructure already supports.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING