PromptisePromptise
Docs
GitHub
Promptise - AI Framework LogoPromptise

The foundation layer for agentic intelligence. Build, secure and operate autonomous AI systems with Promptise Foundry.

pip install promptise

[01] Foundry

  • MCPcast
  • The Promptise Agent
  • Reasoning Engine
  • MCP
  • Agent Runtime
  • Prompt Engineering
  • Execution Engine
  • Agent Identity

[02] Resources

  • Documentation
  • GitHub
  • Guides
  • Learning Paths
  • Questions

[03] Company

  • About
  • Terms of Service
  • Privacy Policy
  • Cookie Policy
  • Subprocessors

© 2026 Promptise by Manser Ventures. All rights reserved.

Open source · Python

← Learning paths> Agentic Engineering with Promptise Foundry
Lesson 01 / 71
1%

What Is an AI Agent? Definition, How It Works, Examples

What an AI agent is: a model that calls tools in a loop until a goal is met. How the loop works, a real example, agents vs chatbots and workflows, FAQs.

Beginner7 minAgent LoopTool Calling
All 71 lessons↓
  1. 01What Is an AI Agent? Definition, How It Works, Examples
  2. 02How to Build an AI Agent in Python (2026 Guide)
  3. 03What Is an Agent Harness? Parts and How to Build One
  4. 04System Prompt Best Practices for AI Agents in Python
  5. 05Best LLM for AI Agents: Test and Switch Models in Python
  6. 06AI Agent YAML: Define and Run an Agent From a Config File
  7. 07Streaming LLM Responses with FastAPI: Tokens and Tool Calls
  8. 08Claude AI Agent with MCP: Use Anthropic Models in Promptise
  9. 09Gemini AI Agent with MCP: Use Google Models in Promptise
  10. 10Azure OpenAI Agent with MCP: Use Deployments in Promptise
  11. 11OpenRouter AI Agent with MCP: Many Models in Promptise
  12. 12Ollama AI Agent with MCP: Run Local Models in Promptise
  13. 13LLM Semantic Cache and Model Fallback in Python
  14. 14What Is MCP (Model Context Protocol)? A Developer's Guide
  15. 15What Is Tool Calling? LLM Function Calling Explained
  16. 16MCP Tools vs Resources vs Prompts (With Python Examples)
  17. 17How to Connect MCP Servers to Your AI Agent in Python
  18. 18Build a Production MCP Server in Python (Step by Step)
  19. 19MCP Transports: stdio vs Streamable HTTP vs SSE (Python)
  20. 20FastAPI MCP Server: Turn Your FastAPI App into MCP Tools
  21. 21OpenAPI to MCP: Turn Any REST API into an MCP Server
  22. 22MCP Authentication in Python: API Keys, JWT and OAuth
  23. 23Build an Authenticated MCP Server for Your AI Agent (Python)
  24. 24MCP Security Best Practices: A Checklist for MCP Servers
  25. 25Testing MCP Servers in Python: pytest Without a Live Server
  26. 26Too Many MCP Tools? LLM Tool Selection, Measured
  27. 27MCP Server Caching, Timeouts and Circuit Breakers in Python
  28. 28MCP vs CLI for AI Agents: Tokens, Security, When to Use Each
  29. 29AI Agent Audit Logging: Tamper-Evident Logs in Python
  30. 30AI Agent Human in the Loop: Approve Tool Calls in Python
  31. 31AI Agent Prompt Injection: How to Defend Against It
  32. 32Build a Multi-Agent System in Python (and When Not To)
  33. 33Context Engineering for AI Agents: Context Window Management
  34. 34How to Deploy an AI Agent with Docker (2026 Guide)
  35. 35LLM Tool Rate Limiting: Per-Client Limits for MCP Servers
  36. 36MCP Long-Running Tasks: Background Jobs in Python
  37. 37MCP Server Monitoring: Prometheus, OpenTelemetry and Logs
  38. 38Python AI Agent Frameworks Compared: Which to Choose (2026)
  39. 39Self-Improving AI Agent: Learn From Tool Failures in Python
  40. 40AI Agent Identity: Authenticate Agents to MCP Servers
  41. 41Code-Action Agents in Python: One Program vs 37 Tool Calls
  42. 42Multi-Tenant AI Agents: Keep Each Customer's Data Apart
  43. 43What Is Agentic RAG? How It Differs from Classic RAG
  44. 44AI Agent Memory in Python: Short-Term and Long-Term
  45. 45Agentic RAG in Python: Give Your AI Agent a Search Tool
  46. 46AI Agent Reasoning Patterns in Python: 9 Patterns Tested
  47. 47Plan-and-Execute Agents in Python: Beyond the ReAct Loop
  48. 48Self-Modifying AI Agent in Python: Open Mode & Limits
  49. 49CrewAI Alternatives: 7 Options and How to Migrate (2026)
  50. 50Migrate from AutoGen: Agent Framework, Promptise and More
  51. 51What Is an LLM Guardrail? Types, Examples and Limits
  52. 52AI Agent Guardrails in Python: Block Injection, Redact PII
  53. 53AI Agent Code Execution Sandbox: Run LLM Code Safely
  54. 54AI Agent Production Checklist: What to Check Before Launch
  55. 55Approval Fatigue: Auto-Approve Safe AI Agent Actions
  56. 56What Is Human in the Loop AI? Approvals for AI Agents
  57. 57AI Agent Notifications: Webhook and Slack Alerts in Python
  58. 58AI Agent Observability: Trace Tool Calls, Tokens and Cost
  59. 59AI Agent Stuck in a Loop? How to Detect and Stop It
  60. 60How to Run, Debug and Deploy an AI Agent in Python
  61. 61AI Agent Cost Tracking: Tokens and Cost per Run and User
  62. 62How to Evaluate AI Agents: Evals, LLM Judges and pass^k
  63. 63AI Agent Cost Control: Budgets That Stop Runaway Spend
  64. 64How to Test LLM Prompts and AI Agents in Python
  65. 65AI Agent Evals in CI: Run Them on Every Pull Request
  66. 66Autonomous AI Agent Runtime: Budgets, Crash Recovery, API
  67. 67Event-Driven AI Agents: Webhook, Cron and File Triggers
  68. 68Durable AI Agents: Crash Recovery and Safe Resume
  69. 69Deploy AI Agents in Production: Long-Running Python Agents
  70. 70What Is an AI Agent Framework? When You Need One
  71. 71LangGraph Alternatives: 7 Options and How to Migrate (2026)

Lessons in this path

  1. 01What Is an AI Agent? Definition, How It Works, Examples
  2. 02How to Build an AI Agent in Python (2026 Guide)
  3. 03What Is an Agent Harness? Parts and How to Build One
  4. 04System Prompt Best Practices for AI Agents in Python
  5. 05Best LLM for AI Agents: Test and Switch Models in Python
  6. 06AI Agent YAML: Define and Run an Agent From a Config File
  7. 07Streaming LLM Responses with FastAPI: Tokens and Tool Calls
  8. 08Claude AI Agent with MCP: Use Anthropic Models in Promptise
  9. 09Gemini AI Agent with MCP: Use Google Models in Promptise
  10. 10Azure OpenAI Agent with MCP: Use Deployments in Promptise
  11. 11OpenRouter AI Agent with MCP: Many Models in Promptise
  12. 12Ollama AI Agent with MCP: Run Local Models in Promptise
  13. 13LLM Semantic Cache and Model Fallback in Python
  14. 14What Is MCP (Model Context Protocol)? A Developer's Guide
  15. 15What Is Tool Calling? LLM Function Calling Explained
  16. 16MCP Tools vs Resources vs Prompts (With Python Examples)
  17. 17How to Connect MCP Servers to Your AI Agent in Python
  18. 18Build a Production MCP Server in Python (Step by Step)
  19. 19MCP Transports: stdio vs Streamable HTTP vs SSE (Python)
  20. 20FastAPI MCP Server: Turn Your FastAPI App into MCP Tools
  21. 21OpenAPI to MCP: Turn Any REST API into an MCP Server
  22. 22MCP Authentication in Python: API Keys, JWT and OAuth
  23. 23Build an Authenticated MCP Server for Your AI Agent (Python)
  24. 24MCP Security Best Practices: A Checklist for MCP Servers
  25. 25Testing MCP Servers in Python: pytest Without a Live Server
  26. 26Too Many MCP Tools? LLM Tool Selection, Measured
  27. 27MCP Server Caching, Timeouts and Circuit Breakers in Python
  28. 28MCP vs CLI for AI Agents: Tokens, Security, When to Use Each
  29. 29AI Agent Audit Logging: Tamper-Evident Logs in Python
  30. 30AI Agent Human in the Loop: Approve Tool Calls in Python
  31. 31AI Agent Prompt Injection: How to Defend Against It
  32. 32Build a Multi-Agent System in Python (and When Not To)
  33. 33Context Engineering for AI Agents: Context Window Management
  34. 34How to Deploy an AI Agent with Docker (2026 Guide)
  35. 35LLM Tool Rate Limiting: Per-Client Limits for MCP Servers
  36. 36MCP Long-Running Tasks: Background Jobs in Python
  37. 37MCP Server Monitoring: Prometheus, OpenTelemetry and Logs
  38. 38Python AI Agent Frameworks Compared: Which to Choose (2026)
  39. 39Self-Improving AI Agent: Learn From Tool Failures in Python
  40. 40AI Agent Identity: Authenticate Agents to MCP Servers
  41. 41Code-Action Agents in Python: One Program vs 37 Tool Calls
  42. 42Multi-Tenant AI Agents: Keep Each Customer's Data Apart
  43. 43What Is Agentic RAG? How It Differs from Classic RAG
  44. 44AI Agent Memory in Python: Short-Term and Long-Term
  45. 45Agentic RAG in Python: Give Your AI Agent a Search Tool
  46. 46AI Agent Reasoning Patterns in Python: 9 Patterns Tested
  47. 47Plan-and-Execute Agents in Python: Beyond the ReAct Loop
  48. 48Self-Modifying AI Agent in Python: Open Mode & Limits
  49. 49CrewAI Alternatives: 7 Options and How to Migrate (2026)
  50. 50Migrate from AutoGen: Agent Framework, Promptise and More
  51. 51What Is an LLM Guardrail? Types, Examples and Limits
  52. 52AI Agent Guardrails in Python: Block Injection, Redact PII
  53. 53AI Agent Code Execution Sandbox: Run LLM Code Safely
  54. 54AI Agent Production Checklist: What to Check Before Launch
  55. 55Approval Fatigue: Auto-Approve Safe AI Agent Actions
  56. 56What Is Human in the Loop AI? Approvals for AI Agents
  57. 57AI Agent Notifications: Webhook and Slack Alerts in Python
  58. 58AI Agent Observability: Trace Tool Calls, Tokens and Cost
  59. 59AI Agent Stuck in a Loop? How to Detect and Stop It
  60. 60How to Run, Debug and Deploy an AI Agent in Python
  61. 61AI Agent Cost Tracking: Tokens and Cost per Run and User
  62. 62How to Evaluate AI Agents: Evals, LLM Judges and pass^k
  63. 63AI Agent Cost Control: Budgets That Stop Runaway Spend
  64. 64How to Test LLM Prompts and AI Agents in Python
  65. 65AI Agent Evals in CI: Run Them on Every Pull Request
  66. 66Autonomous AI Agent Runtime: Budgets, Crash Recovery, API
  67. 67Event-Driven AI Agents: Webhook, Cron and File Triggers
  68. 68Durable AI Agents: Crash Recovery and Safe Resume
  69. 69Deploy AI Agents in Production: Long-Running Python Agents
  70. 70What Is an AI Agent Framework? When You Need One
  71. 71LangGraph Alternatives: 7 Options and How to Migrate (2026)
← Path overview

"AI agent" can mean a chatbot, a workflow tool or a fully autonomous system, depending on who is selling it. This glossary page gives developers a precise definition of an AI agent, shows how the agent loop works, walks through one real run, and compares agents with chatbots, workflows and assistants. At the end you will know what makes a program an agent and where to go to build one.

[01]

What is an AI agent?

An AI agent is a program in which a large language model (LLM) decides, step by step, what to do to reach a goal. It calls tools such as APIs, databases or code, reads each result, and picks the next step until it can answer or hits a limit. The model chooses the actions; your code runs them.

Key takeaways:

  • The loop is what makes it an agent. A single model call is a completion. A model that keeps choosing tools until the task is done is an agent.

  • The model never runs anything. It writes a structured request ("call get_order with A-1042"). Your application executes it and sends back the result.

  • Agents trade control for flexibility. A workflow follows a path you wrote. An agent picks its own path, which handles messy tasks better and fails in less predictable ways.

  • Limits are part of the design. Every agent needs a cap on rounds, time or cost, and a human check before risky actions.

Anthropic's Building effective agents draws the same line: workflows run LLMs and tools "through predefined code paths", while agents are systems where LLMs "dynamically direct their own processes and tool usage". Simon Willison's shorter version is that an LLM agent "runs tools in a loop to achieve a goal".


[02]

How does an AI agent work?

Every agent is built from four parts:

  • A model that reads the conversation and decides the next step.

  • Instructions (the system prompt) that set the goal, the rules and the tone.

  • Tools: functions the model may ask for, each described by a name, a description and a JSON schema for its arguments.

  • A loop in your code that sends the model's tool requests to the right function, adds each result to the conversation, and calls the model again.

Text
1
2
3
4
5
6
7
8
9
10
11
12
13
 user goal
     │
     ▼
┌──────────────┐  "call get_order(A-1042)"  ┌──────────────────┐
│    model     │ ─────────────────────────▶ │ your code runs   │
│ (decides the │                            │ the tool         │
│  next step)  │ ◀───────────────────────── │                  │
└──────────────┘     tool result added      └──────────────────┘
     │                to the conversation
     │  repeats until the model answers,
     │  or a limit (rounds, time, cost) stops it
     ▼
 final answer

Most agents add three more things as they grow. Memory keeps facts across conversations. Retrieval gives the agent a search tool over your documents (see agentic RAG). Guardrails and approvals check inputs, outputs and risky tool calls. The code around the model that handles all of this, from the loop to limits and context management, is often called the agent harness.

The loop pattern is older than today's chat models. The ReAct paper (Yao et al., 2022) showed that interleaving reasoning steps with actions improved results on question answering and interactive tasks. Modern tool calling APIs build that pattern into the model's output format. AI agent reasoning patterns covers ReAct and its successors.


[03]

An AI agent example

Here is a support agent with two tools, built with Promptise Foundry. To answer "When will order A-1042 arrive?" it needs two steps, and only the first result tells it what the second step is.

Pythonagent.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import asyncio

from langchain_core.tools import tool
from promptise import build_agent

ORDERS = {"A-1042": {"status": "shipped", "carrier": "UPS", "tracking": "1Z999"}}
TRACKING = {"1Z999": "Out for delivery, expected today by 6 pm"}


@tool
def get_order(order_id: str) -> dict:
    """Look up an order by its ID."""
    return ORDERS.get(order_id, {"error": f"No order {order_id}"})


@tool
def track_package(tracking_number: str) -> str:
    """Get the latest carrier update for a tracking number."""
    return TRACKING.get(tracking_number, "Unknown tracking number")


async def main():
    agent = await build_agent(
        model="openai:gpt-5-mini",
        instructions="You are a support agent. Use your tools, then answer in one sentence.",
        extra_tools=[get_order, track_package],
        max_agent_iterations=10,
    )
    try:
        result = await agent.ainvoke(
            {"messages": [{"role": "user", "content": "When will order A-1042 arrive?"}]}
        )
        for msg in result["messages"][1:]:  # skip the user's message
            for call in getattr(msg, "tool_calls", None) or []:
                print(f"model asks for  {call['name']}({call['args']})")
            if msg.type == "tool":
                print(f"tool returns    {msg.content}")
            elif msg.content:
                print(f"final answer    {msg.content}")
    finally:
        await agent.shutdown()


asyncio.run(main())

Real output from one run with gpt-5-mini:

Output
model asks for  get_order({'order_id': 'A-1042'})
tool returns    {"status": "shipped", "carrier": "UPS", "tracking": "1Z999"}
model asks for  track_package({'tracking_number': '1Z999'})
tool returns    Out for delivery, expected today by 6 pm
final answer    Your order A-1042 is out for delivery and is expected to arrive today by 6 PM.

Nobody told the agent to call track_package. The first tool result contained a tracking number, and the model decided that the next step was to look it up. That decision is what separates an agent from a script. The max_agent_iterations=10 argument is the limit from the diagram: if the model kept calling tools, the run would stop.

The tools here are plain functions. In a real system they would often live in an MCP server, so the same tools work across agents and apps; What is MCP explains how. To build a complete agent step by step, follow How to build an AI agent in Python.


[04]

AI agent vs chatbot, workflow and assistant

Term

Who decides the steps

Uses tools

Example

---|---|---|---

Chatbot

Nobody: one model reply per message

Usually not

A FAQ bot answering from its training data

LLM workflow

You, in code (fixed path)

Yes, at fixed points

Classify a ticket, then route it, then draft a reply

AI assistant

The user, turn by turn

Sometimes

A chat app that searches the web when asked

AI agent

The model, within limits you set

Yes, in a loop

A support agent that looks up an order, tracks it and answers

Multi-agent system

Several agents, one delegating to others

Yes

A coordinator that hands research to one agent and writing to another

The lines blur in products. A chat assistant that calls several tools in a row is running an agent loop inside each turn. A workflow can contain an agent as one of its steps. The useful question is not "is it an agent?" but "who decides the next step, and what stops it?". For several agents working together, see multi-agent systems.


[05]

Common misconceptions about AI agents

"An agent is a smarter model." The model is the same one you use for chat. The agent is the loop, the tools and the limits around it. A better model makes better decisions inside the loop, but it doesn't create the loop.

"Agents work on their own, so you don't need to watch them." Agents get stuck repeating a call, misread a tool result or take an action nobody intended. Production agents need a cap on rounds and cost, traces of every tool call, and a human approval step for actions such as refunds or deletes. AI agent stuck in a loop shows what happens without them.

"More tools make a more capable agent." Each tool's schema is sent to the model on every call. Dozens of similar tools cost tokens and make the model pick the wrong one more often. A few clear tools beat many vague ones.

"Every LLM feature should be an agent." If you can write the steps down in advance, a workflow is cheaper, faster and easier to test. Use an agent when the next step depends on what the previous one found.


[06]

Frequently asked questions

What is an AI agent in simple terms?

An AI agent is a program that uses a language model to decide which actions to take, such as looking up an order or searching documents, and keeps going until the task is done. The model chooses each step, and ordinary code carries it out and reports back what happened.

What is the difference between an AI agent and a chatbot?

A chatbot answers each message with one model reply. An AI agent can take several actions before it answers: it calls tools, reads their results and decides what to do next. A chatbot that can look things up and act on them, in a loop, is an agent.

Do AI agents run the tools themselves?

No. The model only writes a structured request with a tool name and arguments. Your application, or the agent framework you use, runs the function and sends the result back to the model. That is why you can check, approve or block every action before it happens.

What are examples of AI agents?

Common examples are support agents that look up orders and issue refunds, coding agents that read files, run tests and edit code, research agents that search and summarize sources, and operations agents that check monitoring data and open tickets. Each one combines a model, a few tools and a loop.

Do I need a framework to build an AI agent?

No. A minimal agent loop is about 30 lines of code against a model API. A framework helps once you need tool servers, retries, limits, approvals, tracing and memory, because you would otherwise write and maintain all of that yourself. Python AI agent frameworks compared helps you choose.

Are AI agents safe to use in production?

They can be, with the right controls: least-privilege tools, a cap on rounds and spending, guardrails on inputs and outputs, traces of every call, and human approval for actions that are expensive or hard to undo. Treat every tool result as untrusted input, because it can contain instructions aimed at the model.


[07]

Next steps

  • Build one: How to build an AI agent in Python.

  • Understand the code around the model: What is an agent harness?

  • Give it tools: What is MCP?

  • Keep a human in charge of risky actions: AI agent human in the loop.

  • All guides on the topic: the AI agents hub.

  • Reference: Building agents in the Promptise docs.

Next lesson →How to Build an AI Agent in Python (2026 Guide)