An agent owns model reasoning for an interaction. It receives messages, applies instructions, chooses whether to call tools, observes tool results, and emits output.
The ReAct loop alternates reasoning and action: the model calls tools, observes results and continues until it can respond.
Characteristics
- Perception: reads messages, system instructions, memory, runtime state, and tool results.
- Reasoning: decides what the next useful step is.
- Action: calls a tool, asks for more information, or emits output.
- Goal direction: works toward the objective expressed by its instructions and the current user message.
- Autonomy: can choose the next step inside the limits of its tools, runtime config, and guardrails.
Loop
The loop has four parts:
The runtime manages the loop. The agent decides whether to call a tool or emit output. Tasks define background work; workflows coordinate steps. Runs record each execution, its status and result. Resources provide readable context.
Boundary
Use an agent when the system needs judgment, language understanding, tool choice, or streamed conversational output. Agents usually pair with tools, memory, and a chat UI. AG-UI is the default streaming surface for interactive agent output.
Do not use an agent for work that a tool, route, task, or workflow can own directly. If the next step is always known, the model should not be in charge of it.
Wrong fit
An agent is the wrong primitive for a fixed HTTP response, a scheduled sync, a single database write, or a multi-step process that needs durable state. Use an app route, task, tool, or workflow for those boundaries.
For implementation steps, see Agents.
Text and structured results
An agent response keeps readable output in text. When you configure
outputSchema, the response also exposes the parsed value in data.
object remains a compatibility alias for the same value. Without a schema,
JSON-looking text remains text.
The local trigger runner and agent-as-tool responses preserve both fields. Streaming exposes them when the final response completes. Schema validation failures use the existing agent error path rather than returning successful data.