Skip to content

Agent node (v3.1) loses upstream execution context when delegating to sub-agents or other agent workflows #24414

@alejandrosnz

Description

@alejandrosnz

Describe the problem

When using the AI Agent node version 3.1 (Latest), upstream execution context is lost when the Agent either:

  • delegates to a sub-agent, or
  • calls another workflow that contains an Agent

As a result, expressions referencing upstream nodes (e.g. a Telegram Trigger) stop working, even though the workflow structure remains visually unchanged.

This behavior did not occur with Agent node version 2.x, where upstream node expressions continued to work reliably.


Expected behavior

Expressions referencing upstream nodes (for example:

{{ $('Telegram Trigger').item.json.message.chat.id }}

) should behave consistently regardless of whether the Agent:

  • answers directly,
  • uses a sub-agent, or
  • calls another workflow containing an Agent.

If this behavior is expected due to execution boundaries, the UI should clearly warn about it or document it explicitly.


Actual behavior

Workflow structure:

Telegram Trigger
 → Agent (v3.1, may use sub-agent OR call another workflow with an Agent)
 → Telegram Send Message

Observed behavior:

  • If the Agent does NOT delegate, the expression works correctly.
  • If the Agent uses a sub-agent, the expression evaluates to undefined.
  • If the Agent calls another workflow that contains an Agent, the expression also evaluates to undefined.

This causes the Telegram Send node to fail due to a missing Chat ID.

No warning or error explains why the upstream node context is no longer available.


Why this is problematic

  • The workflow is visually linear but behaves differently at runtime.
  • The failure is non-deterministic, depending on LLM decisions.
  • The same expression works or fails depending on Agent behavior.
  • There is no UI indication that Agent v3 introduces execution boundaries.
  • This represents a behavior change/regression compared to Agent v2.x.

From a user perspective, this breaks the expected mental model of how expressions and node context work in n8n.


Reproduction steps

  1. Create a workflow:

    • Telegram Trigger
    • AI Agent node (version 3.1, Latest)
    • Telegram Send Message
  2. Configure the Agent so it may:

    • use a sub-agent, or
    • call another workflow that contains an Agent
  3. In the Telegram Send node, set Chat ID to:

    {{ $('Telegram Trigger').item.json.message.chat.id }}
  4. Send a message to the bot:

    • Case A: Agent answers directly → message is sent successfully.
    • Case B: Agent delegates (sub-agent or workflow with Agent) → Chat ID is undefined and message fails.

Environment

  • n8n version: 2.3.5
  • AI Agent node version: 3.1 (Latest)
  • Deployment: Docker
  • OS: Linux (Docker host)
  • Trigger: Telegram Trigger

Screenshots

The last node has the chat_id value when no sub-agent or workflow is called by the Main Agent:

Image

The last node does not have the chat_id value when a sub-workflow was called:

Image

The last node does not have the chat_id value when a sub-agent was called:

Image

With AI Agent node version 2.x, the execution context appeared to be preserved when calling a workflow

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions