# Agent Node

### Overview

The Agent Node empowers your flow with decision-making capabilities by creating an AI agent that can use multiple tools to accomplish tasks. It combines a large language model with a set of tools, enabling complex reasoning and multi-step task completion based on the input and available tools.

Usage cost: 2 credits

### Configuration

#### Settings

1. **Model Selection**
   * LLM Model\*: Select the AI model for the agent (the selected model must support tools calling)
   * System Prompt: Initial instructions defining the agent's behavior and context
   * Agent Prompt\*: The main instruction or task for the agent
   * Past Message History: Optional chat history for context
2. **Tools Configuration**
   * Tools\*: Select one or more tools for the agent to use
   * Tools must be provided by previous nodes in the flow
3. **Output format**

   * **Output as JSON** (Toggle):
     * **Off (Default):** The node outputs the model's response as a plain string.
     * **On:** Instructs the model to format its response as JSON and attempts to parse the output string. If parsing succeeds, the `response` output port will contain a JSON object/array. If it fails, `response` will contain the original string.

   *Note:* JSON structure and parsing success depend heavily on the model's ability to follow instructions. Clearly prompting for JSON format is recommended when this is enabled.

#### Output Ports

* `response` (string): The agent's complete response after using tools and reasoning

### Best Practices

1. **Tool Selection**
   * Only provide tools that are relevant to the task
   * Order tools from most to least commonly used
   * Ensure tools have clear, descriptive names
   * Limit the number of tools to prevent confusion
2. **Prompt Engineering**
   * Be specific about what tools should be used
   * Clearly define the expected outcome
3. **Performance Optimization**
   * Keep tool descriptions concise
   * Use appropriate model for complexity
   * Balance between instruction detail and flexibility

### Common Issues

* Tool execution timeouts
* Incorrect tool selection by agent
* Incomplete or unclear tool responses
* Model context length limitations


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.waterflai.ai/studio/studio-builders/flow-components-nodes/agent-node.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
