Skip to content

AI Agents

An agent is an LLM that decides and acts in a loop โ€” choosing tools, taking steps, and reacting to results โ€” instead of answering once. This section shows how to build them well, and when not to.

Overview

Most LLM features are a single request and response. An agent is different: given a goal, it reasons about what to do, uses tools to act, observes the results, and repeats until the goal is met. This unlocks tasks that need multiple steps, external data, and adaptation โ€” research, coding, workflow automation โ€” but it also introduces new failure modes, cost, and risk. Building agents well is as much about constraints as capabilities.

Learning Objectives

By the end of this section you will be able to:

  • Define what an agent is and recognize when one is (and isn't) the right tool.
  • Build a basic agent loop with planning and reflection.
  • Give an agent memory that persists across steps and sessions.
  • Design multi-agent systems and know their trade-offs.
  • Connect agents to tools and data with MCP.

What is an agent, really?

flowchart TB
    G[Goal] --> T[Think:<br/>what should I do next?]
    T --> A[Act:<br/>use a tool]
    A --> O[Observe:<br/>tool result]
    O --> D{Goal met?}
    D -->|no| T
    D -->|yes| F[Final answer]
    style T fill:#F5A623,stroke:#c77d00,color:#000

That Think โ†’ Act โ†’ Observe loop is the essence of every agent. It's the tool-calling loop you already met, given autonomy over how many steps to take and which tools to use.

What you'll learn

  • Agent Fundamentals


    The loop, planning, and reflection โ€” build a working agent and understand its anatomy.

  • Memory


    Short-term, long-term, and semantic memory so agents remember within and across sessions.

  • Multi-Agent Systems


    Orchestratorโ€“worker and other patterns โ€” and when multiple agents help vs. hurt.

  • Model Context Protocol (MCP)


    An open standard for connecting agents to tools and data through one interface.

When to build an agent

[!IMPORTANT] Prefer the simplest thing that works. Agents are powerful but harder to make reliable, more expensive, and riskier. Reach for a plain prompt, structured output, or a fixed tool-calling workflow first.

An agent fits whenโ€ฆ Avoid an agent whenโ€ฆ
The steps aren't known in advance A fixed sequence always works โ†’ hard-code it
The task needs to adapt to intermediate results The task is one call โ†’ just prompt
Multiple tools must be combined dynamically Latency/cost/determinism are critical

Frameworks

You can build agents from scratch (recommended for learning โ€” see Fundamentals) or use a framework: LangGraph (graph-based, controllable), CrewAI (role-based multi-agent), and others. Bee teaches the principles first so any framework makes sense; framework-specific guides are marked [WANTED] for contributors.

Prerequisites

Read Function & Tool Calling first โ€” the agent loop is built directly on it.