AI Agent
An autonomous AI agent that runs a ReAct (Reasoning + Acting) loop — it processes a required message input, calls connected tools, optionally reads conversation memory, and returns a response in OpenAI Chat Completion format.
Use AI Agent when you need an LLM to reason about inputs and dynamically decide which tools to call:
- Building a chatbot or conversational assistant
- Creating a customer support agent that searches knowledge bases and calls APIs
- Orchestrating multi-step tasks where the LLM decides the next action
- Processing unstructured data with natural language understanding
| Handle | Type | Description |
|---|---|---|
message | any | Required. The input message or data for the agent to process. Typically a user's chat message from an API trigger, or a structured payload from an upstream node. Accepts a string, a chat message object with role and content fields, or any JSON-serializable value. |
Tools | dynamic | Connect any action node (HTTP Request, Code, MCP Server, Subworkflow, etc.) to give the agent callable tools. Up to 20 tools can be connected — each appears as a new handle slot on the agent's bottom edge. |
Memory | memory | Connect a memory plugin (Window Memory or Qdrant Memory) to provide conversation history across requests. One memory provider per agent. |
| Handle | Type | Description |
|---|---|---|
response | object | The agent's final response in OpenAI Chat Completion format. Access via the emit alias ai_agent. |
The response output follows the OpenAI Chat Completion spec. Access the agent's answer with {{ ai_agent.choices[0].message.content }}.
{
"id": "chatcmpl-a1b2c3d4e5f6",
"object": "chat.completion",
"created": 1719043200,
"model": "gpt-4o",
"choices": [{
"index": 0,
"message": { "role": "assistant", "content": "The answer is..." },
"finish_reason": "stop"
}],
"usage": {
"prompt_tokens": 150,
"completion_tokens": 42,
"total_tokens": 192
},
"_tensorify": {
"tool_calls": [
{ "name": "http_request", "status": "success", "data": {} }
],
"iterations": 2
}
}
| Field | Type | Description |
|---|---|---|
id | string | Unique completion ID (prefixed chatcmpl-). |
object | string | Always "chat.completion". |
created | number | Unix timestamp when the completion was generated. |
model | string | The model used for this completion. |
choices[0].message.content | string | The agent's final text response. |
choices[0].finish_reason | string | "stop" for normal completion, "length" if maxIterations was reached. |
usage.prompt_tokens | number | Total prompt tokens consumed across all iterations. |
usage.completion_tokens | number | Total completion tokens consumed across all iterations. |
usage.total_tokens | number | Sum of prompt and completion tokens. |
_tensorify.tool_calls | array | Tool calls made during reasoning. Each entry has name, status ("success" or "error"), and data or error. |
_tensorify.iterations | number | How many reasoning iterations the agent performed. |
The AI Agent always outputs this OpenAI Chat Completion shape. For SDK compatibility, use an API Endpoint trigger with protocol: openai-chat — see Deploy as OpenAI Endpoint. For other trigger types, the completion is available in output.body. See Choosing a Trigger for guidance.
| Setting | Type | Default | Description |
|---|---|---|---|
provider | select | openai | LLM provider: OpenAI, Anthropic, or Custom (any OpenAI-compatible endpoint like Ollama, DeepSeek, Together AI). |
model | string | gpt-4o | Model identifier (e.g. gpt-4o, claude-sonnet-4-20250514). Supports {{ }} bindings for dynamic model selection. |
customBaseUrl | string | — | Base URL for custom providers (e.g. http://localhost:11434/v1). Only shown when provider is Custom. Supports bindings. |
temperature | number | 0.7 | Sampling temperature. 0 = deterministic, 2 = creative. |
| Setting | Type | Default | Description |
|---|---|---|---|
systemPrompt | code-editor (text) | You are a helpful assistant. | System prompt defining the agent's role and instructions. Supports {{ }} bindings. |
maxIterations | number | 10 | Maximum tool-use iterations before forcing a final answer. |
retryCount | number | 3 | Retries for transient LLM API errors (429, 500). |
| Setting | Type | Default | Description |
|---|---|---|---|
sessionKey | string | — | Key for scoping memory per user or thread. Use bindings like user:{{ input.body.user_id }}. When empty and memory is connected, falls back to a workflow-scoped default key. |
| Setting | Type | Default | Description |
|---|---|---|---|
outputSchema | code-editor (json) | — | JSON Schema for structured output. When set, the agent validates its final answer against this schema. Skipped when tools are connected or streaming is enabled. |
streaming | boolean | true | Stream tokens and tool events in real-time via SSE. Required for the Playground chat mode. |
| Environment Variable | Provider | When Required |
|---|---|---|
OPENAI_API_KEY | OpenAI | When provider is openai |
ANTHROPIC_API_KEY | Anthropic | When provider is anthropic |
CUSTOM_API_KEY | Custom | When provider is custom |
Build a simple Q&A agent with web search:
- Add an API Endpoint trigger with
protocol: openai-chat(for SDK compatibility — see Choosing a Trigger) - Add an AI Agent node and connect the trigger's output to the agent's message input (required)
- Add an HTTP Request node configured to call a search API — connect it to the agent's Tools handle
- Add a Return node and connect the agent's response output to it
- Set systemPrompt:
"You are a research assistant. Use the search tool to find accurate information before answering." - Set provider and model (e.g. OpenAI / gpt-4o)
The agent receives a user question, decides whether to search, calls the HTTP Request tool if needed, and returns a grounded answer in OpenAI Chat Completion format.
Optional: connect Window Memory to the agent's Memory handle and set a sessionKey binding to scope conversation history per user.
import manual_trigger from @tensorify/manual-trigger:4.0.0
import ai_agent from @tensorify/ai-agent:1.0.0
import http_request from @tensorify/http-request:3.0.0
import return_node from @tensorify/return:3.0.0
node trigger @tensorify/manual-trigger:4.0.0 {
mockPayload = """{"message": "What is the weather in NYC?"}"""
}
node agent @tensorify/ai-agent:1.0.0 {
provider = "openai"
model = "gpt-4o"
systemPrompt = "You are a research assistant. Use the search tool to find accurate information before answering."
maxIterations = 10
}
node search @tensorify/http-request:3.0.0 {
method = "GET"
url = "https://api.example.com/search"
}
node respond @tensorify/return:3.0.0 {}
trigger.payload -> agent.message
agent.tools -> search.body
agent.response -> respond.input
The agent has a control output handle On Error. Enable it via the "Error output handle" toggle at the bottom of the settings panel.
The error branch fires when the LLM API call fails after all retries — for example, invalid API key, model not found, or rate limit exhausted. Execution routes through this handle instead of response. Connect it to a Return node to send a custom error response, or to a notification action to alert your team.
When streaming is enabled, an error event is also written to the SSE stream before the branch fires.
- Message input is required: The agent will not run without a wired
messageinput. Always connect a trigger or upstream node before deploying. - API keys: Set the provider's API key in your team's Environment Variables (e.g.
OPENAI_API_KEY). The agent reads it at runtime. - Tool descriptions matter: The agent uses tool names and descriptions to decide which tool to call. Vague names lead to unreliable tool selection.
- Max iterations: If the agent hits
maxIterations, it returns its best answer so far withfinish_reason: "length". Increase the limit for complex multi-step tasks. - Streaming requires OpenAI Chat protocol: SSE streaming works through the API Endpoint trigger with
protocol: openai-chat. The Playground's Chat mode consumes this stream automatically. Manual Trigger does not support streaming. - Tool limit: Up to 20 tool connections per agent. If you need more, use MCP Server nodes which bundle multiple tools from a single connection.
- Default session key: When no
sessionKeyis set and memory is connected, the agent falls back toagent_memory:{workflow_id}. All users share one conversation buffer — always set a session key in production. - Output schema + tools/streaming: When tools are connected or streaming is enabled,
outputSchemavalidation is skipped. The agent returns free-form text instead.
- Window Memory — conversation history with a sliding window
- Qdrant Memory — semantic search over long-term conversation history
- MCP Server — connect external tool servers
- Build an AI Agent — step-by-step guide
- Agent Memory Guide — choosing and configuring memory
