Dynamic AI Agent

Dynamic AI Agent with flexible message configuration, multi-role support and YAML compatibility

Overview

The Dynamic AI Agent node enables flexible interaction with AI agents by allowing users to configure multi-role messages either individually or via a YAML array. It supports system, user, and assistant roles in conversations, making it suitable for complex dialogue scenarios. The node also integrates seamlessly with external tools and supports streaming responses, iteration limits, and timeout controls.

This node is beneficial when you want to:

  • Build conversational AI workflows with precise control over message roles.
  • Use YAML formatting for complex or multiline message inputs.
  • Integrate AI agents that can call external tools during execution.
  • Stream AI responses in real-time.
  • Control the number of iterations and execution time for agent responses.

Practical examples:

  • Creating a customer support chatbot that uses system messages to set context, user messages as input, and assistant messages as AI replies.
  • Feeding a YAML script of conversation history to an AI model for context-aware responses.
  • Running an AI agent that calls APIs or tools dynamically during its reasoning process, with control over tool usage limits.

Properties

Name Meaning
Welcome to Dynamic AI Agent! This node provides enhanced flexibility with multi-role messages, YAML support, and seamless tool integration. Informational notice displayed at the top of the node UI.
Message Configuration Mode Choose how to configure messages:
- Individual Messages: Add messages one by one with specific roles (system, user, assistant).
- YAML Array: Provide a complete YAML array of messages supporting multiline and special characters.
Messages When using Individual Messages mode, configure multiple messages specifying:
- Role: System, User, or Assistant.
- Content: Text content of the message.
Messages YAML Array When using YAML Array mode, enter a YAML-formatted array of messages. Each message must have role and content properties. Supports multiline text, quotes, backticks, and special characters without escaping.
Options Collection of advanced options:
- Enable Streaming (boolean): Enable real-time streaming of AI responses.
- Max Iterations (number): Max number of iterations the agent performs (1–50).
- Return Intermediate Steps (boolean): Include intermediate reasoning steps.
- Timeout (Seconds) (number): Max wait time for agent response (10–300 seconds).
- Tool Execution Options:
- Max Tool Iterations (number): Max number of tool calls allowed (1–50).
- Return Tool Steps (boolean): Return detailed info about tool execution steps.

Output

The node outputs data on the main output channel with the following structure:

  • json: Contains the AI agent's response data, including:

    • Final answer or message generated by the AI.
    • Optionally, intermediate reasoning steps if enabled.
    • Details about tool executions if connected and enabled.
    • Error information if execution fails (only if "Continue On Fail" is enabled).
  • binary: If applicable, binary data related to the AI response or tool outputs may be included (e.g., files returned by tools), but this depends on connected tools and integrations.

Dependencies

  • Requires an API key credential or authentication token for the underlying AI service (not specified explicitly).
  • May require additional credentials or configurations for any integrated external tools.
  • No internal credential names are exposed; users must provide appropriate API keys or tokens as per their environment.
  • The node relies on bundled utility modules for execution logic (./utils/execute and ./utils/node-inputs).

Troubleshooting

  • Common issues:

    • Invalid YAML syntax in the "Messages YAML Array" property can cause parsing errors.
    • Exceeding max iterations or timeout limits may result in incomplete responses.
    • Missing or invalid API credentials will cause authentication failures.
    • Tool execution limits reached may stop further tool calls prematurely.
  • Error messages:

    • Errors thrown during execution are caught and can be output as JSON error objects if "Continue On Fail" is enabled.
    • Typical errors include parsing errors, network/authentication failures, or runtime exceptions from the AI service.
  • Resolutions:

    • Validate YAML syntax carefully when using YAML mode.
    • Adjust iteration and timeout settings according to expected workload.
    • Ensure all required API keys and tokens are correctly configured in n8n credentials.
    • Monitor tool usage limits and increase if necessary.

Links and References

Discussion