Skip to main content

What is an AI agent?

An AI agent is a software program that uses a large language model (LLM) to perceive inputs, reason about them, and take actions — including calling external tools, writing code, or querying databases — in a loop until it achieves a goal. Unlike a single LLM call, an agent can complete multi-step tasks autonomously by deciding which actions to take based on intermediate results.

The term "agent" has been used broadly in AI research since the 1990s, but in 2024–2026 it has come to specifically mean LLM-powered programs that can use tools and maintain state across multiple steps.

The core loop

Every AI agent runs some version of this loop:

  1. Perceive — receive a user message or environment observation
  2. Reason — the LLM decides what to do next
  3. Act — call a tool, write a file, query a database, or respond
  4. Observe — get the result of the action
  5. Repeat — or stop if the goal is met

The most widely used implementation of this loop is the ReAct pattern (Reason + Act), introduced by Yao et al. (2022). See What is a ReAct agent? for details.

What makes something an "agent" vs a chatbot

CharacteristicChatbotAI agent
Can call toolsNoYes
Runs in a loopNo — single LLM callYes — until goal is met
Maintains task stateNoYes
Takes actions in the worldNoYes
Can spawn sub-tasksNoYes (multi-agent)

A chatbot responds to one message with one LLM call. An agent may make dozens of LLM calls and tool calls before returning an answer.

How to build an AI agent in Python

AgentFlow provides a prebuilt ReactAgent that implements the full agent loop. You supply the tools; the framework handles routing, tool execution, and state.

from agentflow.prebuilt.agent import ReactAgent
from agentflow.core.state import AgentState, Message

def search_web(query: str) -> str:
"""Search the web and return a summary of results."""
# Replace with a real search API call
return f"Top results for '{query}': [result 1], [result 2]"

def get_weather(city: str) -> str:
"""Get current weather for a city."""
return f"Weather in {city}: 22°C, sunny"

agent = ReactAgent(
model="google/gemini-2.5-flash",
system_prompt=[{"role": "system", "content": "You are a helpful assistant. Use tools when they help."}],
tools=[search_web, get_weather],
)

app = agent.compile()

result = app.invoke(
{"messages": [Message.text_message("What is the weather in Tokyo and latest AI news?")]},
config={"thread_id": "demo-1"},
)
print(result["messages"][-1].text())

The agent will call get_weather for Tokyo, call search_web for the news query, then compose a final answer — all automatically.

Serving an AI agent as an API

Once you have a compiled agent, one command starts a production HTTP server:

pip install 10xscale-agentflow-cli
agentflow init
agentflow api

This gives you POST /v1/graph/invoke, POST /v1/graph/stream (SSE), and GET /v1/graph/threads/{id} — no extra FastAPI code required.

Types of AI agents

Agent typeDescriptionAgentFlow prebuilt
ReAct agentReason and Act in a loop with toolsReactAgent
RAG agentRetrieves documents before answeringRAGAgent
Supervisor agentRoutes tasks to specialist sub-agentsSupervisorTeamAgent
Swarm agentPeer agents hand off to each otherSwarmAgent
Plan-act-reflectPlans, executes, reflects, revisesPlanActReflectAgent
Structured outputReturns typed, validated responsesStructuredOutputAgent

Why agents need more than a raw LLM call

A raw LLM call returns text. For production AI agents, you also need:

  • Persistent threads — conversations that survive server restarts
  • Tool execution — call functions, APIs, databases in parallel
  • Streaming — send tokens to a frontend as they generate
  • Auth and rate limiting — control who can call the agent and how often
  • Observability — traces, metrics, error tracking

AgentFlow ships all of these as part of the framework. See Get Started for the full stack.

Frequently asked questions

What is the difference between an AI agent and an LLM?
An LLM is a model that generates text given a prompt. An AI agent is a program built on top of an LLM that can also call tools, maintain state across multiple steps, and take actions in a loop until it completes a goal. An LLM is a component inside an AI agent, not the agent itself.
What programming language is best for building AI agents?
Python is the dominant language for AI agent development because all major LLM provider SDKs (OpenAI, Anthropic, Google) have first-class Python support and most agent frameworks (AgentFlow, LangGraph, CrewAI, AutoGen) are Python-native. TypeScript is used for frontend agent clients and increasingly for Node.js agent runtimes.
How do AI agents use tools?
The LLM inside an agent can request tool calls by returning a structured response that names the tool and provides the arguments. The agent runtime executes the tool (a Python function), sends the result back to the LLM, and the LLM continues reasoning. AgentFlow's ToolNode executes multiple tool calls in parallel via asyncio.gather.
What is the difference between an AI agent and a workflow?
A workflow has fixed, pre-determined steps. An AI agent decides dynamically which steps to take based on the LLM's reasoning. In practice, most production systems use both: deterministic graph structure (workflow) with LLM-powered decision points (agent) at nodes where human-like reasoning is needed.
Can AI agents remember previous conversations?
Yes, with the right persistence layer. AgentFlow uses a thread ID system — each conversation gets a thread ID, and the full message history is stored in Redis (hot) and Postgres (durable). When you invoke the agent again with the same thread ID, it has access to the full conversation history.

Next steps