Agentic Intelligence — Technologies & Tricks
Updated July 2026 with 2025–2026 SOTA additions — new entries marked ★. Algorithm names link to their papers (arXiv / project page).
July 2026 • Updated Edition Algorithm names link to their original papers (arXiv / project page).
Contents
- What Is an Agent?
- The Core Agent Loop
- Tool Use Mechanics
- Memory Systems
- Planning
- Reflection and Self-Critique
- Multi-Agent Systems
- Tool Ecosystems
- Computer Use and GUI Agents
- Code Agents
- Browser / Web Agents
- RAG and Retrieval for Agents
- Agent Frameworks
- Safety and Guardrails
- Evaluation of Agents
- Common Failure Modes
- State Management Patterns
- Cost and Latency Engineering
- Context Engineering for Agents
- Multimodal Agents
- Long-Horizon Agentic Tasks
- Production Patterns
- 2026 Production Stack
Appendix A: Twenty-Five Things to Know
Appendix B: Decision Tree — "Which Agent Pattern?"
Appendix C: Year-by-Year Agentic Milestones
1. What Is an Agent?
1.1 Working definition
An agent is an LLM-driven system that:
- Pursues a user-specified goal, not just answers a query.
- Decides its own next action from a tool palette.
- Maintains state across many steps.
- Iterates until done (or budget exhausted).
1.2 Agent vs assistant vs chatbot
| Chatbot | Assistant (RAG) | Agent | |
|---|---|---|---|
| Goal-driven | no | some | yes |
| Multi-step | no | sometimes | yes |
| Tool use | no | sometimes | yes |
| State across turns | shallow | shallow | deep |
| Self-correction | no | no | yes |
1.3 Levels of agency
- L0 — Pure chat. No tools, no state.
- L1 — Tool-augmented. Single tool call per turn.
- L2 — Multi-step tool use. ReAct-style loops.
- L3 — Planning + execution. Decompose, then execute.
- L4 — Self-improving. Reflection across runs, skill libraries.
- L5 — Multi-agent. Specialists collaborate.
1.4 When to use an agent (vs simpler patterns)
- Use an agent when the task has variable structure, requires tools, has unknown duration, and benefits from self-correction.
- Don't use an agent when a single well-prompted LLM call works; when latency matters more than completeness; when failure modes are unbounded.
Watch out
The single biggest mistake in 2024–25 agent products: using an agent loop where a single structured LLM call (with one or zero tool calls) would work. Agents add latency, cost, and unpredictability; reach for them only when the value justifies it.
2. The Core Agent Loop
2.1 Sense \(\to\) Plan \(\to\) Act \(\to\) Observe \(\to\) Reflect
The fundamental cycle:
- Sense: read the current state (user message, tool result, environment).
- Plan: decide what to do next (often implicit in next-token).
- Act: emit a tool call (or final response).
- Observe: receive the tool result.
- Reflect: optionally critique progress; revise plan.
- Loop until terminal action or budget exhausted.
2.2 ReAct (Yao et al. 2022)
Interleave Thought and Action tokens:
Thought: I need the current weather.
Action: weather_api(city="San Francisco")
18°C
Thought: Got it; reply to user.
18°C
The thought channel exposes reasoning; action channel emits structured calls. Standard baseline.
2.3 Plan-and-Execute
Two LLM passes:
- Planner: produces an explicit ordered plan (sub-tasks).
- Executor: handles each sub-task, possibly with its own ReAct loop.
More predictable than pure ReAct; better for long-horizon tasks.
2.4 Plan-Act-Reflect (PAR)
- Plan: decompose into ordered steps.
- Act: execute one step via tools.
- Reflect: did this step succeed? Revise plan if not.
- Repeat until done.
Works well for structured tasks (coding, research, data analysis).
2.5 Tree of Thoughts for agents
Branch the action space; evaluate each branch with a critic; backtrack on failure. Useful when multiple plausible actions exist.
2.6 Modern variants
- Reflexion: episodic reflection stored in memory; informs future runs.
- Voyager: skill library + auto-curriculum.
- LATS (Language Agent Tree Search): MCTS over LLM actions.
- LLM-Compiler / ReWOO: parallel tool calls when independence allows.
3. Tool Use Mechanics
3.1 Function calling / structured output
Modern LLMs (GPT-4o, Claude, Gemini, open frontier) support native function calling: the model emits a JSON object matching a tool schema.
tools = [{
"name": "search_web",
"description": "Search the web and return top results.",
"input_schema": {
"type": "object",
"properties": {
"query": {"type": "string"}
},
"required": ["query"]
}
}]3.2 JSON Schema patterns
- Required fields explicit; non-required fields described with defaults.
- Use enum for closed sets (more reliable than free-form).
- Group related parameters under nested objects.
- Avoid deeply nested or recursive schemas (model accuracy drops).
- Provide one or two example calls in the description.
3.3 Tool description engineering
The description is the model's only signal for when to use the tool. Best practices:
- State the when clearly: "Use when the user asks about current events."
- State the what concretely: "Returns up to 10 web results with title, snippet, URL."
- Note constraints: "Rate limit 100/hour; do not call for cached information."
- Bad example \(\to\) good example: 1–2 contrastive examples per tool.
- For ambiguous tool selection, add a meta-tool description.
3.4 Tool result integration
- Tool result becomes a new conversation turn: role=tool.
- Truncate or summarize long results before injecting.
- Highlight schema-deviation cases explicitly.
- For binary tool results (success / fail), include the why.
3.5 Tool error handling
- Return structured errors: {error type, message, suggestion}.
- Let the model retry once with different args before escalating.
- Cap retries; circuit-break repeating errors.
- Surface auth / quota errors as user-facing.
3.6 Composition
- Sequential: ToolA \(\to\) ToolB(result of A).
- Parallel: ToolA, ToolB at once when independent.
- Conditional: branching tool calls based on result.
- Recursive: tool that itself calls an agent (sub-agents).
3.7 Toolformer-style self-supervision
The model learns when to call tools by inserting tool-call tokens during pretraining; loss filtered by whether the call helped. Used in some open frontier models for native tool fluency.
★ 2026 SOTA update — Agentic RL for tool use
- Search-R1: RL trains LLMs to interleave search and reasoning.
- ReTool: RL for strategic code/tool use in long-form reasoning.
- SWE-RL: RL on open software evolution data (Llama3-SWE-RL-70B).
4. Memory Systems
4.1 The four memory types (cognitive analogy)
- Working memory: current context window. Large but finite.
- Episodic memory: past episodes / sessions. Retrieved by similarity.
- Semantic memory: facts about user / world. Curated, structured.
- Procedural memory: learned skills / patterns. Often baked into prompts or fine-tuning.
4.2 Working memory management
- Limit context to recent K turns.
- Summarize older turns into a rolling summary.
- Sliding window + sink tokens for very long sessions.
- Selectively keep tool results that future turns will need.
4.3 Episodic memory
- Store conversation summaries with metadata (date, user, topic).
- Embed; retrieve by query similarity.
- Decay weighting: more recent / more accessed memories prioritized.
- Periodic consolidation: merge / dedupe redundant memories.
4.4 Semantic memory (the user model)
- Curated facts: "user prefers Python."
- Updated via explicit learning \((\to \text{store})\) or implicit \((\to \text{embed})\).
- Schema-validated; not free-form to avoid drift.
- Surfaced in system prompt or retrieved on demand.
4.5 MemGPT and OS-level memory
Treat the LLM as the CPU; separate main memory (in-context) from external memory (vector store). The agent can call read/write tools to swap between them. Mimics OS paging.
4.6 Anthropic's memory tool, OpenAI memory
Modern frontier APIs ship structured memory features:
- User-scoped persistent storage.
- Read/write via function calls.
- Consent + transparency controls.
- Decay / explicit-delete options.
4.7 Conversation summarization patterns
- Summarize every N turns into a running summary.
- Hierarchical: per-turn \(\to\) per-session \(\to\) per-week.
- Preserve named entities, decisions, open questions.
- Compute summary asynchronously (don't block user).
4.8 Skill library (Voyager pattern)
- Store successful sub-routines as named skills.
- Skill = (description, arguments, body, dependencies).
- Retrieved by query similarity to current sub-task.
- Composes: skills can call other skills.
4.9 Memory failure modes
- Leakage: information from one user surfaces to another (privacy bug).
- Pollution: bad facts persist and corrupt future behavior.
- Contradiction: conflicting facts; unclear which wins.
- Bloat: too many memories; retrieval quality degrades.
★ 2026 SOTA update — Long-term agent memory (2025)
- Mem0: production long-term memory; ~90% lower cost vs full context.
- A-MEM: Zettelkasten-style dynamically linked agentic memory.
5. Planning
5.1 Implicit vs explicit planning
Implicit: model plans inside CoT before each action. Cheap, less robust. Explicit: separate planning step produces a plan object the executor follows. More predictable, better for long horizons.
5.2 Hierarchical planning
- Top-level: high-level goals ("ship feature X").
- Mid-level: sub-tasks ("write spec", "implement", "test").
- Low-level: atomic actions (specific tool calls).
- Replan at each level on failure / new info.
5.3 LLM as planner
Strong base for free-form tasks. Limitations: planning errors propagate; long plans drift. Mitigations: bound plan depth, validate plan structure, allow incremental commitment.
5.4 Hybrid: LLM + classical planner
- LLM translates natural language \(\to\) PDDL (Planning Domain Definition Language).
- Classical planner (Fast Downward, Z3) returns optimal plan.
- LLM translates plan steps \(\to\) tool calls.
- Strong for combinatorial / constraint-heavy tasks.
5.5 Recursive task decomposition
- "If task is atomic, execute. Else, decompose and recurse."
- Bound recursion depth.
- Cache decompositions for similar sub-tasks.
5.6 HTN (Hierarchical Task Networks)
Tasks decomposed into method instantiations; methods themselves contain tasks. Classical AI primitive that maps cleanly onto LLM agents.
5.7 Plan validation and revision
- Pre-execution: check plan for obvious errors (missing dependencies, contradictory steps).
- Mid-execution: monitor progress; revise if reality diverges.
- Post-execution: post-mortem; update planner heuristics.
6. Reflection and Self-Critique
6.1 Reflexion (Shinn et al. 2023)
After each episode, the model writes a reflection on what went wrong, stored in episodic memory. Future episodes prepend recent reflections.
6.2 Self-Refine
Generate \(\to\) critique \(\to\) revise loop, single-episode. Effective for writing, code, structured tasks.
6.3 Critic models
- Separate critic LLM scores actions / outputs.
- Cheaper to fine-tune than the policy itself.
- LLM-as-judge with rubric.
- Process reward model for step-level critique.
6.4 Outcome-based vs process-based feedback
Outcome: evaluate only the final result. Cleaner; can mask reasoning errors. Process: evaluate each step. Catches errors earlier; needs PRM-style data.
6.5 Multi-turn refinement
- Round 1: draft.
- Round 2: critique.
- Round 3: revise based on critique.
- Diminishing returns after 2–3 rounds.
7. Multi-Agent Systems
7.1 When to use multiple agents
- Specialized expertise (planner, coder, reviewer).
- Parallel sub-tasks that don't share state.
- Adversarial / debate setups.
- Human-like role-playing (negotiation, conversation).
Counter-warning: for most tasks, a single well-designed agent beats a multi-agent ensemble. Multi-agent adds coordination overhead.
7.2 Manager-worker pattern
- Manager: decomposes task, assigns sub-tasks to workers.
- Workers: handle one sub-task each, return result.
- Manager: aggregates, escalates on failure.
Standard in CrewAI, AutoGen.
7.3 Multi-Agent Debate (Du et al.)
N agents propose answers; iteratively critique each other; converge. Beats single-agent on factual / logical tasks.
7.4 LLM-as-judge panel
Multiple judge LLMs evaluate; majority vote. Higher reliability than single judge; debiases position / self-preference.
7.5 Society of Mind (MetaGPT, ChatDev)
Specialized roles: PM, architect, coder, QA. Each has a persona prompt + tool palette. Effective for software engineering.
7.6 Adversarial agents
- Red-team agent tries to break the system.
- Safety auditor reviews actions.
- Devil's advocate finds plan weaknesses.
7.7 Coordination mechanisms
- Shared blackboard (common state).
- Message passing (typed channels).
- Mediator agent (sequencing, conflict resolution).
- Broadcast vs unicast.
7.8 Common failure modes
- Echo chamber (all agents converge prematurely).
- Endless debate (no convergence).
- Specialization gone wrong (agents ignore their role).
- Coordination overhead > value added.
8. Tool Ecosystems
8.1 Code execution
- Python sandbox (Code Interpreter, Jupyter, Pyodide).
- Bash sandbox (Anthropic Computer Use, Claude Code).
- JavaScript / TypeScript runtime.
- Sandboxed VMs (Docker containers, microVMs, gVisor).
- Capability-restricted (no network, FS subset, time-limited).
8.2 File system
- Read / Write / Edit / List / Search.
- Mount user-selected directories.
- Diff display before write.
- Glob / regex search.
- Granular permissions per path.
8.3 Web browsing
- Headless browser (Chromium via Playwright / Puppeteer).
- Read-only fetch (server-side).
- Search engines (Google, Bing, Brave, Tavily, SerperAPI).
- Scraping services (Firecrawl, Jina Reader, ScrapeGraph, Browserless).
8.4 Database / SQL
- Read-only by default; explicit writes gated.
- Schema-aware: feed schema to system prompt.
- Query validation before execution.
- Result truncation for long outputs.
8.5 Productivity APIs
- Email (Gmail, Outlook), Calendar.
- Slack, Teams, Discord.
- GitHub / GitLab.
- Jira, Linear, Asana.
- Notion, Confluence, Google Drive.
- All increasingly available via MCP servers.
8.6 MCP (Model Context Protocol, Anthropic)
Open standard for connecting LLMs to tools. Server-client architecture: each external system runs an MCP server exposing tools/resources/prompts; agent client discovers and calls them. Standardizes:
- Tool discovery (tools/list).
- Tool invocation (tools/call).
- Resource browsing.
- Prompt templates.
Major implementations: Claude Desktop, Claude Code, Cursor, Cline, OpenAI Apps SDK.
8.7 Plugin / extension models
- OpenAI Apps SDK: structured plugins.
- Claude Code skills + plugins.
- Cursor / Cline extensions.
- LangChain tool integrations (1000+).
9. Computer Use and GUI Agents
9.1 Why GUI agents?
The web / desktop is the universal API. Agents that can use a screen + keyboard can interact with anything humans can, no API integration needed.
9.2 Claude Computer Use (Anthropic 2024)
- Tools: screenshot, mouse move, click, type, key, scroll, cursor position.
- VLM reasons over screenshots.
- Actions executed via OS automation (xdotool / pyautogui).
- Beta product; sandboxed VM recommended.
9.3 OpenAI Operator
Browser-only autonomous agent with separate browser-control tool layer; multi-turn task completion.
9.4 Anthropic Claude in Chrome / Browser Tool
First-class browser actions with screenshot + DOM-aware grounding.
9.5 Open computer-use models
- OS-Atlas (Anthropic + UCSD): screen-grounded VLM.
- ShowUI: visual + textual UI grounding.
- UI-TARS (ByteDance): general computer agent.
- CogAgent, SeeAct, AppAgent, Mobile-Agent, AutoGUI.
- NaviX, AgentS2: open frameworks.
9.6 Set-of-Mark (SoM) prompting
Annotate screenshot with numbered marks on actionable elements; agent refers to them by number. Improves click accuracy dramatically.
9.7 Action grounding
- Pixel-coordinate clicks (most general; brittle to rendering).
- DOM-element clicks (when available; more reliable for web).
- Accessibility tree (best for desktop apps).
- Semantic descriptions resolved by VLM ("the blue submit button").
9.8 Failure modes for GUI agents
- Misclick (inaccurate coordinates).
- Stale screenshot (action took effect but agent doesn't refresh).
- Auth pages, captchas.
- Modal dialogs intercepted unexpectedly.
- Slow page loads not waited for.
- Mitigations: explicit wait actions, screenshot-after-each-action, bounded retries.
★ 2026 SOTA update — Frontier computer-use agents (2025)
- OpenCUA: open framework and AgentNet dataset for computer-use agents.
- Gemini 2.5 Computer Use: Google UI-control model (Oct 2025).
10. Code Agents
10.1 Cursor / Aider / Cline / Continue
IDE-integrated coding agents with file editing, command execution, codebase awareness. Common patterns:
- Whole-file edits vs diff edits.
- Git-aware: branch / commit / PR.
- Live linting / test feedback.
- Tab-complete and chat modes.
10.2 Devin / Cognition / Replit Agent
Autonomous SWE agents that take a ticket and produce a PR.
- Long-running (minutes to hours).
- Self-spawning sub-tasks.
- Browser-augmented for documentation lookup.
- Async result delivery.
10.3 SWE-agent / SWE-Gym
Open framework with structured action space (file ops, search, edit). Strong on SWE-bench.
10.4 Codex CLI / Claude Code
- Codex CLI: OpenAI's local agent for code tasks.
- Claude Code: Anthropic's local agent with bash + file + skills + plugins + MCP.
- Both offer hooks, custom commands, sub-agents, scriptability.
10.5 GitHub Copilot Workspace
Agent-native IDE: spec \(\to\) plan \(\to\) implementation \(\to\) review, all assisted.
10.6 Code agent best practices
Recipe — Building a code agent.
- Tools: read, write, edit (diff-based), bash, grep, glob.
- Always read before editing (avoid clobbering).
- Run tests after changes; iterate on failures.
- Show diffs to user before applying.
- Sandbox by default; explicit elevation for installs / network.
- Persistent context per repo (CLAUDE.md / AGENTS.md).
- Skill / plugin system for repo-specific routines.
11. Browser / Web Agents
11.1 Categories
- Read-only research agents: gather + summarize. Lower risk.
- Form-filling agents: book, schedule, purchase. Higher risk; need confirmation.
- Stateful workflow agents: long-running multi-page workflows.
11.2 Open frameworks
- Browser-Use (open): playwright + LLM glue.
- Skyvern: visual workflow agents.
- Stagehand (Browserbase): TypeScript browser agent SDK.
- LangChain / LangGraph browser tools.
11.3 Web evaluation benchmarks
- WebArena: 4 domains (shopping, gitlab, reddit, maps).
- VisualWebArena: visual reasoning over web.
- WebVoyager: real-world websites.
- WebShop, Mind2Web.
- OSWorld: full-OS task benchmark.
- GAIA: general AI assistant tasks.
11.4 Anti-bot considerations
- Cloudflare / hCaptcha: many sites block automation.
- Use official APIs when available.
- Respect robots.txt.
- Real-browser sessions (Browserbase) to evade detection.
- Be a good web citizen: rate-limit; identify clearly.
12. RAG and Retrieval for Agents
12.1 Naive RAG
Embed query \(\to\) retrieve top-k chunks \(\to\) stuff into prompt \(\to\) generate. Standard baseline.
12.2 Self-RAG
Model decides when to retrieve, what to retrieve, and whether to use the result. Trained with reflection tokens ([Retrieve], [Relevant]).
12.3 Adaptive RAG
Classify query difficulty; route easy queries to direct LLM, medium to single-step RAG, hard to multi-step / agentic RAG.
12.4 Corrective RAG (CRAG)
Critic evaluates retrieved chunks; if low quality, expand search (web) or rewrite query.
12.5 GraphRAG (Microsoft)
Build a knowledge graph from corpus (entities + relations); retrieve sub-graphs by query similarity; inject as context. Better for multi-hop reasoning over structured knowledge.
12.6 Agentic RAG
RAG inside an agent loop: retrieve \(\to\) read \(\to\) if need more \(\to\) retrieve again. Multi-hop without explicit planning.
12.7 Query-rewriting and HyDE
- Query rewrite: LLM expands user query into multiple search queries.
- HyDE (Hypothetical Doc Embedding): model writes a fake answer; embed it; retrieve real docs similar to fake answer. Often better than embedding the question.
- Sub-question decomposition: break multi-hop into atomic queries.
12.8 Multi-vector / late interaction (ColBERT, ColPali)
Per-token vectors; max-similarity per query token. Better for fine-grained matching, especially document images (ColPali).
12.9 Re-ranking
Cross-encoder reranks top-k for higher precision; filters retrieval noise. Cohere Rerank, BGE-Reranker, OpenAI / Voyage reranker APIs.
12.10 Long-context vs RAG
- Long-context wins for cohesive reasoning.
- RAG wins for huge corpora and freshness.
- Hybrid: RAG to fetch candidates; long-context to reason.
13. Agent Frameworks
13.1 The 2026 landscape
| Framework | Maintainer | Notes |
|---|---|---|
| LangChain | LangChain | Largest tool ecosystem; battle-tested; complex |
| LangGraph | LangChain | Stateful graph-based agents; production-ready |
| LlamaIndex | LlamaIndex | RAG-first; data ingestion strong |
| CrewAI | CrewAI | Multi-agent role-playing |
| AutoGen | Microsoft | Conversational multi-agent |
| OpenAI Agents SDK | OpenAI | Lightweight; native tool use |
| OpenAI Swarm | OpenAI | Earlier multi-agent; superseded by Agents SDK |
| Claude Agent SDK | Anthropic | Agent loop on Claude; subagents, hooks |
| DSPy | Stanford | Declarative; auto prompt-optimization |
| Pydantic AI | Pydantic team | Type-safe; structured outputs first |
| Smol Agents | HuggingFace | Minimal; code-as-actions |
| Mastra | Mastra | TypeScript native |
| Semantic Kernel | Microsoft | .NET / C# friendly |
| Letta (MemGPT) | Letta | Memory-augmented agents |
| TaskWeaver | Microsoft | Code-first agents |
13.2 LangChain vs LangGraph
LangChain: tool integrations, chains, retrievers. Rich ecosystem; can be heavy. LangGraph: graph state machines on top; better for explicit control flow, persistence, human-in-loop.
13.3 CrewAI vs AutoGen
CrewAI: roles + tasks + crews; declarative, fast prototyping. AutoGen: conversational agents that talk to each other; flexible.
13.4 When to pick what
- Quick research agent: Smol Agents or Pydantic AI.
- Production agent with persistence: LangGraph.
- Multi-agent role play: CrewAI.
- RAG-heavy: LlamaIndex.
- Optimization-driven: DSPy.
- Single-vendor LLM: native SDK (OpenAI Agents SDK or Claude Agent SDK).
- Memory-first: Letta.
★ 2026 SOTA update — Agent frameworks and protocols (2025)
- Google ADK: open code-first Agent Development Kit.
- A2A: Agent2Agent interoperability protocol (now Linux Foundation).
- Strands Agents: AWS model-driven open agent SDK.
14. Safety and Guardrails
14.1 Sandboxing
- Process isolation: subprocess with restricted env.
- Container isolation: Docker / gVisor / Firecracker microVMs.
- Network isolation: outbound allowlist / proxy.
- Filesystem: read-only or per-path permissions.
- Time / memory / CPU limits.
14.2 Permission models
- Allowlist: only pre-approved actions permitted.
- Confirm-on-irreversible: pause for user confirmation before destructive actions.
- Per-tool budget: limit calls / spend per tool.
- Granular per-domain: read X, write Y, no Z.
- Permission elevation: temporary elevated permissions with audit log.
14.3 Approval gates
- Auto: low-risk + sandbox.
- Confirm: medium-risk; show preview + diff.
- Block: high-risk; require human approval (n-eyes for critical).
14.4 Output filtering
- PII redaction.
- Toxicity / NSFW classifier.
- Format-validation (JSON, schema).
- Pre-emit safety classifier.
14.5 Cost / spend controls
- Per-session token budget.
- Per-day spend cap.
- Per-tool call cap.
- Escalating warnings (50% / 75% / 100% of budget).
- Auto-pause at threshold.
14.6 Prompt injection defenses
- Treat tool outputs as untrusted (do not follow instructions in them).
- Separate "trusted" system prompt from "user / data" content.
- Output classifier to flag injection attempts.
- Privilege separation: planning agent cannot directly execute; executor only follows planner's calls.
- Spotlighting: mark tool results with delimiters.
14.7 Constitutional AI for agents
Apply constitutional principles to action selection; refuse actions that violate. Especially relevant for browser / OS agents.
15. Evaluation of Agents
15.1 Benchmarks
| Benchmark | Domain | Notes |
|---|---|---|
| SWE-bench / SWE-bench-Verified | software eng | GitHub issues |
| WebArena, VisualWebArena | web tasks | 4 domains, multi-turn |
| WebVoyager | real websites | 600+ tasks |
| OSWorld | full OS | multimodal |
| AgentBench | general agent | 8 environments |
| GAIA | general assistant | 466 questions; 3 levels |
| ToolBench | tool use | 16k tools |
| TAU-Bench | customer service | multi-turn |
| MLE-bench | ML engineering | 75 Kaggle-like tasks |
15.2 Trajectory evaluation
Beyond final-success, evaluate the trajectory:
- Step efficiency (number of actions).
- Tool-call accuracy (right tool, right args).
- Reasoning quality (CoT coherence).
- Cost ($ per task).
- Recovery from errors.
15.3 LLM-as-judge for agents
Use a strong LLM to evaluate trajectories. Best practices:
- Provide clear rubric.
- Multiple judge runs + aggregation.
- Calibrate against human eval on a subset.
- Watch for self-preference (judge favors same model).
15.4 Human eval
- Gold-standard; expensive.
- Rubric-based; calibrated annotators.
- Pairwise comparison preferred over absolute.
- Hold-out a small set; use as ground truth for LLM-judge calibration.
15.5 Online metrics (production)
- Task completion rate.
- Time to complete.
- Cost per task.
- User satisfaction (CSAT, thumbs).
- Tool-call error rate.
- Escalation rate.
- Retention / repeat use.
★ 2026 SOTA update — Frontier agent benchmarks (2025)
- BrowseComp: 1,266 hard-to-find web-research tasks for browsing agents.
- Humanity's Last Exam: 2,500 expert-frontier closed-ended questions.
- SWE-Lancer: $1M of real Upwork freelance software-engineering tasks.
- τ²-Bench: dual-control tool-agent-user telecom benchmark.
16. Common Failure Modes
16.1 Doom loops
Agent retries the same failing action repeatedly. Fix: detect loops (last N actions identical), back off / replan.
16.2 Context explosion
Conversation history grows unboundedly. Fix: rolling summary, sliding window with sink, drop irrelevant tool results.
16.3 Hallucinated tools
Model invents a tool name that doesn't exist. Fix: strict tool schema validation; reject + nudge to existing tools.
16.4 Off-task wandering
Agent forgets the original goal in a long episode. Fix: re-state goal periodically; maintain a goal-anchor in system prompt.
16.5 Premature commitment
Agent picks a wrong path early and won't backtrack. Fix: budget exploration vs commitment; explicit "consider alternatives" prompts.
16.6 Error compounding
Each step has a small error rate; trajectory accuracy decays exponentially. Fix: per-step verification; rollback / replan.
16.7 Goal drift
Agent gradually shifts the goal toward something easier or different. Fix: periodic goal-grounding; explicit task-completion criteria.
16.8 Stuck on subgoal
Agent fixates on one sub-task it can't solve, ignoring alternatives. Fix: max-attempts per sub-task; mark and move on; reflect after.
16.9 Tool result misreading
Agent misinterprets the tool result and proceeds wrongly. Fix: structured outputs; validation; explicit re-read step.
16.10 Authentication / quota wall
Agent hits a wall and doesn't surface to user. Fix: detect auth-error patterns; auto-escalate.
17. State Management Patterns
17.1 Conversation state
- Append-only message log.
- Summarize on overflow.
- Pin critical messages (system prompt, original goal, key facts).
17.2 Plan tracking
- TodoList / task tracker as a tool the agent updates.
- Status per item (pending / in-progress / done / blocked).
- Visible to user for transparency.
17.3 Working memory tools
- "Notes" tool: agent writes scratchpad notes; reads back later.
- Variable store: structured key-value the agent maintains.
- Tool result cache: avoid re-fetching same data.
17.4 Session checkpointing
- Save full session state every N steps or at milestones.
- Allow resume on disconnect / crash.
- Persistent across user sessions (with consent).
17.5 LangGraph state pattern
Typed state object; nodes mutate via reducers; transitions via edges. Production-friendly: visualize, replay, time-travel.
18. Cost and Latency Engineering
18.1 Model routing
- Tiered: cheap model for simple tasks; escalate on uncertainty.
- Specialist: code task \(\to\) code model; vision \(\to\) VLM.
- Difficulty estimator (small LLM) decides tier.
18.2 Cascades
- Try cheap model; if confidence high, return.
- Else try medium, then expensive.
- Calibrate confidence thresholds per domain.
18.3 Parallel tool calls
When tools are independent (LLM-Compiler / ReWOO), call in parallel. Reduces wall-time without increasing token cost.
18.4 Speculative execution
Pre-execute likely next tool calls speculatively while LLM is generating. Risk: wasted compute on rejected paths.
18.5 Prefix caching
Cache the system-prompt + tool-schema KV; reused across requests. Anthropic prompt cache: up to 90% cost savings on cached prefix.
18.6 Tool result caching
Same tool call with same args within a window \(\to\) return cached result. Fingerprint by tool name + canonicalized args.
18.7 Batching
- Batch user requests to a single LLM call when latency permits.
- Continuous batching at the inference server for shared prefix.
18.8 Streaming
Stream LLM output to user; parallel tool execution while later text streams.
19. Context Engineering for Agents
19.1 System prompt design
- Identity / role.
- Top-level goal.
- Capabilities (tools available, summarize don't list).
- Behavioral guardrails.
- Output format spec.
- Example interactions (1–3 brief).
Aim for < 2000 tokens; bloat hurts quality and cost.
19.2 Tool description engineering
Already covered in §3. Each tool's description is its own surface; iterate.
19.3 Few-shot examples
- 1–3 examples per pattern.
- Diverse: cover edge cases.
- Match output format exactly.
- Avoid stale references (tool names, dates).
19.4 Output format specs
- Structured JSON / Pydantic models for downstream consumption.
- Markdown for human-facing.
- Mixed: agent emits JSON + human summary.
19.5 Context compression
- Summarize old turns.
- Drop tool results no longer relevant.
- Hierarchical: recent verbatim, older summarized.
- LLMLingua-style prompt compression for very long contexts.
19.6 Persistent context (CLAUDE.md / AGENTS.md)
Per-project context file with:
- Codebase / project overview.
- Coding conventions.
- Tools / commands.
- Key files / directories.
- Known issues / TODOs.
Auto-loaded by the agent in every session.
20. Multimodal Agents
20.1 Vision + tool use
VLMs that can see screenshots + use tools. Standard for computer-use, visual data analysis, document agents.
20.2 Document / PDF agents
- OCR / layout (Donut, Pix2Struct, ColPali).
- Table extraction.
- Multi-page understanding.
- RAG over document collections.
- Examples: Anthropic's PDF tool, OpenAI's Files API, Adobe's PDF tools.
20.3 Spreadsheet / Excel agents
- Read / write XLSX (openpyxl, libreoffice).
- Formula generation.
- Chart creation.
- Data analysis.
- Examples: Claude in Excel, GPT-4 Code Interpreter on spreadsheets.
20.4 Video analysis agents
- Frame sampling.
- Long-form video VLM (Qwen2.5-VL, Gemini 2.5).
- Caption-then-reason for very long videos.
- Multi-modal grounding (Sa2VA).
20.5 Voice agents
- ASR (Whisper) \(\to\) LLM \(\to\) TTS pipeline.
- Native audio (GPT-4o, Gemini 2.5).
- Real-time voice (low-latency).
- Examples: ChatGPT voice mode, Gemini Live, Sesame, Character.AI.
21. Long-Horizon Agentic Tasks
21.1 Defining "long-horizon"
\(\ge 10\text{–}100+\) steps; minutes to hours of execution. Software engineering, research, content creation, data pipelines.
21.2 Subgoal tracking
- Maintain explicit task list throughout.
- Mark progress visibly.
- Re-anchor every N steps to original goal.
21.3 Memory across episodes
Reflexion-style: each completed episode produces lessons stored in episodic memory. Future runs prepend / retrieve relevant lessons.
21.4 Skill library + curriculum
Voyager-pattern: store successful sub-routines as named skills. Auto-curriculum: agent picks next learning goal based on current capabilities.
21.5 Bounded budget pattern
Recipe — Bounded long-horizon agent.
- Total token budget.
- Total time budget.
- Total tool-call budget.
- Per-subgoal budget.
- On budget exceeded: surface partial result + ask user.
21.6 Deep Research agent pattern (OpenAI / Anthropic)
Long-form research: query expansion \(\to\) multi-source web search \(\to\) synthesis \(\to\) citations. Often 10–60+ minute runs. ChatGPT Deep Research, Gemini Deep Research, Perplexity Pro.
★ 2026 SOTA update — Deep research agents (2025)
- WebThinker: LRM autonomously searches, navigates, and drafts reports.
- DeepResearcher: end-to-end RL deep research in real web environments.
22. Production Patterns
22.1 Deployment topologies
- Sync: user waits for agent response. Latency-sensitive.
- Async: agent runs in background; deliver result via push (email, slack).
- Scheduled: cron-style; daily digest, periodic monitoring.
- Webhook-triggered: respond to events (PR opened, ticket filed).
22.2 Human-in-the-loop
- Approval before irreversible actions.
- Mid-task check-ins for clarification.
- Final-result review.
- Escalation on low-confidence.
22.3 Background agents
Long-running async agents. Deliver via:
- Email summary.
- Slack DM.
- Push notification.
- Status page / dashboard.
22.4 Observability
- Per-step trace (action, args, result, latency).
- Token usage per step.
- Cost per task.
- Tool error rates.
- Replayable logs.
- Tools: LangSmith, Helicone, Langfuse, Phoenix, Honeycomb.
22.5 Versioning + rollback
- Version system prompts, tool schemas, model choices.
- Canary / shadow traffic for new versions.
- Quick rollback path.
- A/B testing with statistical eval.
22.6 Multi-tenancy
- Per-user / per-org isolation.
- Per-tenant rate limits and budgets.
- Memory partitioning.
- Audit log per tenant.
23. 2026 Production Stack
| Use case | Default stack | Notes |
|---|---|---|
| Code agent (IDE) | Cursor / Cline / Continue + GPT / Claude | Real-time pair-programming |
| SWE autonomous | Devin / SWE-agent / Claude Code | Long-horizon ticket-to-PR |
| Research agent | ChatGPT Deep Research / Perplexity Pro / Gemini DR | Multi-source synthesis |
| Computer use | Claude Computer Use + sandboxed VM | Full desktop control |
| Browser agent | Browser-Use / Stagehand / OpenAI Operator | Web tasks |
| Customer support | Crew/Mastra agent + RAG + escalation | Tier 1 automation |
| Background research | LangGraph + cron + Slack delivery | Async patterns |
| Multi-agent systems | CrewAI / AutoGen / Claude agents SDK subagents | Specialist roles |
| Document agents | ColPali + LlamaIndex + GPT/Claude | Multi-page docs |
| Voice agents | Realtime API (OpenAI / Gemini Live) + tools | Low-latency conversation |
| Tool-rich apps | MCP servers + Claude / Cursor / VSCode | Standard protocol |
| Stateful workflows | LangGraph + checkpoint + human-in-loop | Production-ready |
Appendix A: Twenty-Five Things to Know
- ReAct loop: Thought \(\to\) Action \(\to\) Observation.
- Plan-and-Execute beats pure ReAct on long horizons.
- Reflexion: episodic reflection in memory.
- Tool description quality > tool implementation quality (model uses what it understands).
- JSON schema: prefer enums, shallow nesting, required fields.
- Always sandbox code execution; never assume safety.
- Treat tool outputs as untrusted (prompt injection defense).
- MCP standardizes tool discovery + invocation.
- Set-of-Mark prompting improves GUI click accuracy dramatically.
- Anthropic prompt caching: up to 90% cost savings on prefix.
- Continuous batching: per-token, not per-request, kernel batching.
- Re-rank with cross-encoder after vector retrieval.
- HyDE often beats raw question embedding for retrieval.
- GraphRAG wins for multi-hop on structured knowledge.
- Multi-agent only when single agent demonstrably worse.
- LangGraph for stateful production agents.
- DSPy for declarative, optimization-driven flows.
- Voyager skill library + auto-curriculum for open-ended learning.
- Always log per-step traces; replay-able trajectories.
- Doom loops: detect N-step repetition; back off / replan.
- Model routing: cheap-first cascade saves \(\sim 70\%\) cost.
- OSWorld / WebArena / SWE-bench for cross-domain agent eval.
- Human-in-loop for irreversible / high-stakes actions.
- CLAUDE.md / AGENTS.md for persistent project context.
- Don't use an agent when one well-prompted call suffices.
Appendix B: Decision Tree — "Which Agent Pattern?"
- Single tool call solves it? \(\to\) Function calling, no loop. Fastest, cheapest.
- Sequential multi-step but predictable? \(\to\) Plan-and-Execute with explicit plan.
- Variable structure, exploratory? \(\to\) ReAct loop.
- Long horizon (\(>10\) steps)? \(\to\) PAR + reflection + bounded budget.
- Specialized expertise needed? \(\to\) Multi-agent (manager-worker or society of mind).
- Web / GUI tasks? \(\to\) Computer-use VLM + Set-of-Mark + sandboxed VM.
- Code-heavy? \(\to\) Code agent (Aider / Cursor / Cline / Devin pattern).
- Research / synthesis? \(\to\) Deep Research pattern (multi-source + synthesis + citations).
- Persistent across sessions? \(\to\) LangGraph + memory + checkpointing.
- Real-time conversation? \(\to\) Realtime voice API + minimal tool palette.
Appendix C: Year-by-Year Agentic Milestones
- 2022: ReAct, Toolformer, AutoGPT (early autonomous), LangChain v0.
- 2023: Voyager, Reflexion, MetaGPT/ChatDev, Self-Refine, GPT-4 with Code Interpreter, function calling becomes standard.
- 2024: Devin (Cognition), MCP launch (Anthropic), Claude Computer Use, OpenAI Swarm/Agents SDK, AutoGen 0.4, LangGraph maturation, Cursor / Aider / Cline mainstream.
- 2025: Frontier reasoning agents (R1-style + tools), Operator (OpenAI), Claude Code at scale, OpenAI Apps SDK, native multimodal agents (Gemini 2.5), Browser-Use mainstream, MLE-bench.
- 2026: Agents in production across SWE, research, customer support, ops; MCP ecosystem; multimodal computer use mainstream; long-horizon agents (hours, not minutes) reliable.