AI Agents

LLM-driven systems that plan, use tools, maintain memory, and complete multi-step tasks autonomously.

What an Agent Is

An agent wraps an LLM in a control loop: observe state, decide an action, execute tools, update memory, repeat until the task completes or limits hit. Unlike single-shot chat, agents pursue goals over multiple steps with environment feedback (API responses, SQL results, browser state).

Agents are not magic autonomy. Reliability comes from tight tool schemas, permission boundaries, eval coverage, and human checkpoints for irreversible actions.

Tool Use

Tools are functions exposed to the model via JSON schemas (name, parameters, description). The model emits structured tool calls; the runtime executes them and returns results as new messages. Good tool design:

tools = [{
    "type": "function",
    "function": {
        "name": "search_docs",
        "description": "Search internal docs. Use for factual product questions.",
        "parameters": {
            "type": "object",
            "properties": {
                "query": {"type": "string"},
                "max_results": {"type": "integer", "default": 5},
            },
            "required": ["query"],
        },
    },
}]

Parallel tool calls reduce latency when actions are independent (fetch weather and calendar simultaneously).

ReAct and Planning Patterns

ReAct (Reason + Act)

Interleaves natural language reasoning traces with tool actions. The trace helps debugging and can improve multi-step accuracy versus silent tool-only loops.

Plan-and-execute

A planner model drafts steps; a worker model executes each with narrower context. Separates strategic planning from tactical tool calls.

Reflection

After outputs, a critic step checks success criteria and triggers retries or alternate tools.

Loop limits: Always cap max iterations, tool calls per request, and wall-clock time. Unbounded loops are a top production incident category.

Memory

Agents need context beyond one window:

Memory writes should be gated: not every chat line belongs in permanent storage. PII policies apply to agent memory same as primary logs.

Multi-Agent Systems

Multiple specialized agents collaborate: researcher, coder, reviewer, or customer-facing agent plus internal specialist. Coordination patterns include supervisor routing, message buses, and shared blackboard state. Costs multiply with agent count; use multi-agent only when specialization clearly beats one well-tooled agent.

Failure modes: infinite delegation, contradictory instructions between agents, and duplicated tool side effects without transactional guards.

Reliability and Eval

Evaluate trajectories, not only final strings: correct tools called, order sensible, no unauthorized actions, task success on labeled scenarios. Simulation environments and recorded API mocks enable CI testing without live side effects.

Human-in-the-loop approval gates belong on payments, deletes, external emails, and production config changes regardless of model confidence.

Framework Landscape

LangGraph, CrewAI, AutoGen, and vendor SDKs (OpenAI Assistants, Anthropic tool use) provide orchestration primitives. Framework choice is less important than clear state machines, observability, and idempotent tool implementations you own.