Better AI Agent

Advanced AI Agent with improved memory management and modern AI SDK (OpenAI Message Format)

Overview

This node implements an advanced AI agent that interacts with a connected language model, memory, tools, and output parsers using a modern AI SDK. It manages conversation history effectively and supports multi-step tool calls to help users accomplish complex tasks through natural language prompts.

Common scenarios where this node is beneficial include:

  • Building conversational AI assistants that can remember context across interactions.
  • Automating workflows that require calling external tools or APIs dynamically during the conversation.
  • Creating AI agents that provide step-by-step reasoning or actions before delivering a final answer.
  • Integrating with webhook endpoints to stream intermediate results for real-time updates.

Practical example:

  • A user sends a question about weather forecasts. The node uses the connected language model to interpret the query, calls a weather API tool if needed, remembers previous conversation context, and returns a detailed response. Intermediate results can be sent to a webhook for live display.

Properties

Name Meaning
Tip: This node uses modern AI SDK with proper tool call memory management Informational notice about the node's capabilities.
Source for Prompt (User Message) Choose the source of the prompt text: either from a connected Chat Trigger node input field named chatInput ("Connected Chat Trigger Node") or define it manually via expression or static text ("Define below").
Prompt (User Message) The actual user message or prompt text sent to the AI agent. When "Connected Chat Trigger Node" is selected, defaults to {{$json.chatInput}}. When "Define below" is selected, allows manual entry or expression.
Options Collection of additional settings:
- System Message Defines the system message that sets the AI assistant’s behavior and instructions. Defaults to a helpful AI assistant prompt.
- Max Steps Maximum number of tool call steps the agent will perform before stopping. Range: 1 to 20, default 5.
- Intermediate Webhook URL If set, the node POSTs every partial reply and tool call as JSON to this URL while the agent runs, enabling real-time monitoring.
- Verbose Logs Enables detailed console logging for debugging purposes when set to true.

Output

The node outputs an array of items, each containing a JSON object with the following structure:

  • output: The final text generated by the AI agent after processing the prompt and any tool calls.
  • steps: An array detailing each step taken by the agent, including text responses, tool calls made, and tool results obtained.
  • totalSteps: The total number of steps executed during the agent run.

If the node is configured with an intermediate webhook URL, partial results are also sent out during execution but not included in the main output.

The node does not output binary data.

Dependencies

  • Requires a connected AI language model node compatible with the AI SDK (e.g., OpenAI, Anthropic, Google Gemini).
  • Optionally connects to memory nodes to maintain conversation history.
  • Optionally connects to tool nodes that represent external APIs or functions callable by the agent.
  • Optionally connects to output parser nodes to process the AI output further.
  • If using the intermediate webhook feature, requires a reachable HTTP endpoint to receive POST requests.
  • Environment variables or credentials must be configured for the connected AI models and tools (e.g., API keys), but these are managed externally and not specified internally here.

Troubleshooting

  • No language model connected: The node throws an error if no AI language model is connected. Ensure you have linked a compatible AI model node.
  • No input text provided: If the prompt text is missing or empty, the node will error. Verify the prompt source and input data.
  • API key missing or invalid: The underlying AI SDK requires valid API keys for OpenAI, Anthropic, or Google Generative AI. Check your credential configurations.
  • Failed to load or save conversation history: Warnings may appear if memory nodes fail; this usually means the memory node is misconfigured or unavailable.
  • Intermediate webhook failures: If the webhook URL is incorrect or unreachable, warnings will be logged but do not stop execution.
  • Verbose logs disabled: Enable verbose logs to get detailed console output for debugging issues.
  • Tool execution errors: If a connected tool fails during execution, the error is logged and may cause the node to fail unless "Continue on Fail" is enabled.

Links and References

Discussion