Skip to content

agent

An agent is a system that perceives its environment, selects actions to pursue goals, and closes the loop by observing outcomes to inform future decisions. What sets an agent apart is autonomy: the system itself decides which steps to take and which tools to call, rather than following a path someone hardcoded in advance.

In AI practice, this spans a wide range. Reinforcement learning agents optimize behavior in environments modeled by states, actions, and rewards. Today, though, the term usually means an AI agent: a system that uses a large language model as its decision-making engine to pursue a goal over multiple steps.

The Agent Loop

The defining structure of an LLM-driven agent is a loop. The model reads the goal, reasons about the next step, acts by calling a tool, then observes the result and decides what to do next, repeating until the task is complete or a stopping condition fires. The 2022 ReAct paper formalized this interleaving of reasoning and action.

Step through one debugging run below to watch an agent choose each move and then decide when to stop:

Interactive diagram — enable JavaScript to view.

Most implementations combine four parts:

  • Model: The reasoning engine that selects each action.
  • Tools: The functions, APIs, and environments the agent acts through, reached by function calling or a protocol such as MCP.
  • Memory: State carried across steps, since one context window rarely holds a long run.
  • Planning: Decomposition of the goal into steps, often visible as chain of thought.

Many agents also add a verification step that checks their own output before moving on.

Agents vs Prompts and Workflows

Agents differ from one-off model prompts by operating across multiple steps, interacting with external systems, and adapting their behavior toward a goal. They also differ from fixed workflows, where an LLM and its tools are orchestrated through predefined code paths. In a workflow, the sequence of steps is decided ahead of time. In an agent, the model chooses the next step at runtime.

Coding is the most visible application, where the practice is known as agentic coding. Acting without step-by-step approval widens the blast radius of a mistake, so deployments add guardrails, scoped permissions, and human sign-off on high-impact actions. OWASP’s Top 10 for Agentic Applications, published in December 2025, catalogs the resulting risks, among them goal hijacking, tool misuse, memory and context poisoning, and rogue agents.

PydanticAI: Typed LLM Agents With Structured Outputs

Tutorial

Pydantic AI: Build Type-Safe LLM Agents in Python

Learn how to use Pydantic AI to build type-safe LLM agents in Python with structured outputs, function calling, and dependency injection patterns.

intermediate ai

For additional information on related topics, take a look at the following resources:

Have a question about this? Mentor AI can show you examples, compare related terms, and point you to tutorials.


By Leodanis Pozo Ramos • Updated Sept. 25, 2026