04 / 16
Agents & Tool Use
When to let the model drive, and how to keep it on the road.
Workflow: your code fixes the path and the LLM fills in steps. Agent: the LLM picks each next step and tool in a loop. Go single call → workflow → agent, climbing only when needed.
The model never runs anything: it emits a tool name plus JSON arguments, your code validates and executes it, and the result goes back as a message so the model can continue.
The canonical agent loop: the model thinks, picks an action, your harness runs it and feeds back the real observation, and it repeats until done or until a cap you set stops it.
Tool names, descriptions, parameters, outputs and errors are prompts the agent reads every call. Expose a few task-shaped tools, return concise results and actionable errors, and tune them on real-task evals.
Split a task into a fixed sequence of LLM calls, each consuming the previous output, with code checks between steps: you trade extra latency for accuracy and per-step debuggability.
Classify each input first, then send it to the prompt, model or pipeline built for that class: each path stays simple, and easy queries stop paying for the expensive model.
Run several LLM calls at once and merge them in code: sectioning splits a task into independent parts, voting runs the same task N times. You trade extra tokens for lower latency or higher confidence.
A central LLM reads the task, decides at runtime which subtasks it needs, delegates each to a worker LLM and synthesizes the results: parallelization where the model, not your code, writes the task list.
One LLM generates, a second evaluates the output against explicit criteria and returns specific feedback, and the generator revises, looping until the output passes or a round limit is hit.
A strong model writes an explicit step-by-step plan first; the steps are executed (often by a cheaper model with tools), and the agent replans only when a step fails or new facts appear.
The context window is short-term memory; long-term memory lives outside the model (facts, past runs, rules) and is written, retrieved, updated and deleted by explicit policies, often exposed to the agent as tools.
An open standard (Anthropic, Nov 2024) for plugging AI apps into tools and data: servers expose tools, resources and prompts over JSON-RPC, so N apps and M integrations need N+M adapters, not N×M.
An open protocol (Google, Apr 2025; v1.0 Mar 2026; now in the Linux Foundation's Agentic AI Foundation) for agents from different vendors to discover each other through an Agent Card and delegate long-running tasks over HTTP. It complements MCP (agent-to-tool).
Split work across several LLM agents, each with its own context and role, to gain parallelism and context isolation — paying ~15× chat tokens and coordination failures. Worth it for broad, parallel, read-heavy tasks.
Agents that operate a GUI like a person: read a screenshot, then click, type and scroll. They reach apps without APIs, but are slow, brittle, costly and open to prompt injection from any page.
Persist the agent's state after every step so it survives crashes, deploys and multi-day human waits: resume from the last checkpoint, retry steps with idempotency keys, never re-run what already succeeded.
Put a human approval gate in front of consequential or irreversible agent actions, tiered by risk, and escalate low-confidence cases — while keeping prompts rare enough that reviewers still read them.
Agents fail by compounding small errors and by looping. Bound every run with step, token, time and dollar budgets, detect repeated calls, feed errors back structurally, checkpoint, and give tools least privilege.