Agentic AI

A model that loops: it observes, decides, calls something outside itself, reads the result, and decides again. Autonomy is a dial, not a category — and every notch costs predictability.

Contents
  1. Agent, workflow, chatbot: three different things
  2. The loop
  3. The four capabilities
  4. Orchestration patterns
  5. Designing tools the model can use
  6. Memory and context
  7. Why long tasks fail
  8. Guardrails and authority
  9. Observability and evaluation
  10. Economics and latency
  11. Production checklist
  12. Sources

1. Agent, workflow, chatbot: three different things

ChatbotWorkflowAgent
Control flowHuman writes every turnCode decides the pathModel decides the next step
Number of model callsOne per messageFixed, known in advanceVariable, bounded by a budget
Failure surfaceBad answerBrittle branchLoops, drift, side effects
Best forConversation, draftingRepeatable business processOpen-ended goals over tools
TestabilityPrompt evalsDeterministic unit testsTrajectory evals plus budgets
Default to the workflow. If you can draw the decision tree, do not let a model guess it. Agency is worth paying for only when the path genuinely depends on what the tools return.

Autonomy ladder

LevelWho decidesExampleRisk
L0 — suggestedHumanDraft a replyAlmost none
L1 — assistedHuman, model retrievesSearch and propose a fixBad evidence
L2 — approve each actionModel proposes, human confirmsCreate a ticket after reviewConfirmation fatigue
L3 — bounded autonomyModel, inside limitsRefund up to a thresholdSilent accumulation of small errors
L4 — unsupervisedModelNightly reconciliation with escalationBlast radius

2. The loop

Goal Plan Act — tool call Observe result Reflect / verify Answer
Dashed path: the loop repeats with the observation added to context. The exit must be a budget, not a hope.

The canonical formulation is ReAct: interleave a short reasoning trace with an action, feed the observation back, repeat. Modern implementations add an explicit verification step before the exit.

while budget.remaining() and steps < MAX_STEPS:
    thought  = model.reason(goal, history, tools)
    if thought.is_final: break
    action   = thought.tool_call            # validated against schema
    result   = registry.invoke(action, timeout=..., idempotency_key=...)
    history += [thought, action, truncate(result)]
verify(history)                             # own call, own criteria
return answer_or_escalation(history)

3. The four capabilities

CapabilityQuestion it answersImplemented by
PlanningWhat sequence of steps reaches the goal?Decomposition prompt, plan-and-execute, tree search
Tool useHow do I affect the world or read live data?Typed function calling, MCP servers, HTTP APIs
MemoryWhat must survive the next turn?Scratchpad, summary, vector store, structured state
ReflectionIs the result good enough to ship?Self-critique, verifier model, executable checks
Reflection with a checker beats reflection by opinion. A test that runs, a schema that validates, or a diff that applies gives the agent ground truth. "Are you sure?" gives it a second guess.

4. Orchestration patterns

PatternShapeUse whenCost
Single agent + toolsOne loop, many toolsMost tasks; start hereLow
RouterClassify, then dispatch to a specialist promptDistinct intents with different contractsLow
SupervisorManager agent delegates to workers, merges resultsParallelisable sub-tasksMedium
Pipeline / chainFixed sequence of agentsStages with clean hand-offsLow, deterministic
HierarchicalSupervisors of supervisorsLarge tool surfacesHigh, hard to debug
Swarm / handoffPeers pass controlSupport triage with specialismsMedium, unbounded
Multi-agent is not free accuracy. Every hand-off loses context and adds a place for errors to hide. Add an agent only when it removes a tool-selection conflict or isolates a permission boundary.

5. Designing tools the model can use

RuleWhy
One verb per tool; no boolean mode flagsThe model picks tools by description, not by branching inside a call
Descriptions state when not to use itPrevents the most common wrong selection
Schema validated before executionTurns a malformed call into a clear error the model can fix
Errors are structured and actionable{"error":"not_found","hint":"use search_orders first"}
Writes require an idempotency keyRetries are normal in agent loops
Hard timeout and page-size limitsA single slow call can end the whole task
Results truncated to what mattersTool output is the main driver of context growth
Permissions scoped per tool, per tenantThe agent must not inherit the user's full authority
{
  "name": "get_order_status",
  "description": "Return status for one order. Use only when the user supplies an order id; use search_orders when they describe the order instead.",
  "inputSchema": { "type": "object", "properties": { "order_id": { "type": "string", "pattern": "^[A-Z]{2}-\\d{6}$" } }, "required": ["order_id"] },
  "outputSchema": { "type": "object", "properties": { "status": { "enum": ["placed","shipped","delivered","cancelled"] }, "eta_days": { "type": "integer" } } }
}

6. Memory and context

LayerContentsLifetimeFailure if misused
Working contextGoal, recent steps, tool resultsOne taskOverflow, lost early instructions
ScratchpadPlan, open questions, decisionsOne taskStale plan followed blindly
Episodic storePast tasks, outcomes, correctionsWeeksRetrieving irrelevant precedent
Semantic storeDomain knowledge, documentsLongOutdated or poisoned content
Structured stateEntities, ids, statusesLongDivergence from the system of record
Summarise, do not accumulate. Compaction — replacing old turns with a structured summary — keeps the instruction at the top of the window and the cost flat. Keep the raw transcript outside the prompt for audit.

7. Why long tasks fail

P(task succeeds) = pn    (p = per-step reliability, n = steps)

At 99% per step, a 50-step task succeeds 60% of the time. At 95%, it succeeds 8% of the time. Autonomy multiplies error, which is why budgets and checkpoints matter more than model choice.

Failure modeSymptomControl
LoopSame tool called with the same argumentsRepeat detection, max steps, forced replan
Goal driftAnswers a nearby questionRestate the goal every N steps
Context rotIgnores early instructionsCompaction, pinned system block
OverreachDeletes or sends more than askedLeast privilege, dry-run mode, approvals
False completionClaims success without evidenceVerifier with executable checks
Cascading bad dataA wrong id propagatesValidate entities against the source before use

8. Guardrails and authority

ControlImplementationBlocks
Least privilegePer-tool, per-tenant credentials, no wildcard scopesFull-account damage
Human in the loopApproval gate for irreversible actionsSilent destructive writes
SandboxContainer, no network by default, read-only mountsCode execution escapes
BudgetsTokens, steps, money, wall-clock per taskRunaway cost
Allow-listDomains, tables, repositories the agent may touchScope creep
Dry runProduce the diff or the payload, apply on approvalIrreversible mistakes
Audit logEvery call with arguments, result hash, actorUnexplainable outcomes
Prompt injection is the agent's main attack surface. Any text the agent reads — a web page, an email, a PDF, a tool description — is a potential instruction. Keep retrieved content in a clearly delimited, untrusted block and never let it authorise a tool call.

9. Observability and evaluation

SignalWhy it matters
Trajectory (steps, tools, arguments, results)The only way to explain a wrong outcome
Steps and tokens per taskLeading indicator of loops and cost drift
Tool error rate by toolFinds bad schemas faster than prompt tweaks
Escalation and abstention rateDistinguishes "confident" from "correct"
Outcome evals on frozen scenariosCompares versions on end state, not wording
Replay of failed trajectoriesTurns incidents into regression tests

Evaluate on three levels: final answer correctness, trajectory efficiency (did it take the short path?), and safety (did it stay inside its permissions?). A single end-to-end score hides all three.

10. Economics and latency

task cost ≈ ∑steps (inputt × pin + outputt × pout) + tool cost
PatternStepsRelative costWhen it pays
Single call with tools listed1–21×Simple lookup or classification
ReAct loop3–103–8×Multi-source research, remediation
Supervisor + 3 workers6–155–12×Independent sub-tasks in parallel
Plan + verify + repair4–124–10×Anything that must be right

11. Production checklist

12. Sources