MLA 028 How to Build an AI Agent in 2026
An AI agent is a model running tools in a loop toward a goal, and you build one in order: one call, then tools, the loop and evals. Also: frameworks, MCP vs A2A, memory, multi-agent patterns, prompt injection and cost. Links Notes and resources at ocdevel.com/mlg/mla-28 Join the free MLG group: listen to my other AI shows, ask me questions, and talk with other listeners What is an AI agent? A model running tools in a loop toward a goal: model + tools + loop + stop condition (done, turn cap, budget cap, or a human). In a workflow your code decides the next step; in an agent the model does. Coding agents specifically: MLA 22 to MLA 24. AI agent vs workflow If you can write the steps down, build a workflow. The patterns from Anthropic's Building Effective Agents: prompt chaining, routing, parallelization, orchestrator-workers, evaluator-optimizer. Errors compound: at 95% per step, a 20-step task succeeds about 36% of the time. 0.95 ^ 20 ≈ 0.36 How to build an AI agent One model call against ~20 realistic inputs. If it works, stop. Add tools: name, description, argument schema. Your code runs each call and can refuse. Add the loop, with turn and spend caps. Add a verifier the agent must pass, and an eval suite. Tool rules: few task-sized tools, namespaced names, readable values over IDs, capped output, descriptions written like a new hire's brief. API first, then page structure, screenshots last. AI agent frameworks Simple or learning: write the loop. Operates a computer or codebase: Claude Agent SDK. Light handoffs between agents: OpenAI Agents SDK. Durable runs with human approval: LangGraph. Google or Microsoft stack: ADK or Microsoft Agent Framework. No code: n8n's AI Agent node, Zapier Agents. OpenAI's Agent Builder shuts down November 30, 2026. MCP vs A2A MCP connects an agent to tools; A2A connects agents across organizations. Both sit in the Linux Foundation's Agentic AI Foundation. The 2026-07-28 MCP revision is stateless (no handshake or session), moves long jobs into a tasks extension, and deprecates roots, sampling and logging. MCP's context cost: MLA 23. AI agent memory types Working (the context window), episodic (past runs), semantic (facts), procedural (instructions, skills). Manage working memory with compaction, context editing and notes; start the rest as files. Multi-agent architecture patterns Parallelize independent, read-mostly work; keep one writer. Anthropic's research system beat a single agent by 90% at about 15× chat tokens. Cognition's 2026 update: extra agents contribute intelligence, not actions. How to evaluate an AI agent From Demystifying Evals for AI Agents: start with 20–50 tasks from real failures; code graders first, calibrated LLM judges second; grade outcomes, plus trajectory checks for forbidden steps; isolate trials; read transcripts. Tracing tools: MLA 14. pass@k = P(at least 1 of k succeeds) pass^k = P(all k succeed) 0.75^3 ≈ 0.42 Prompt injection and the lethal trifecta No session should hold all three of the lethal trifecta: private data, untrusted content, external communication or state changes. When a task needs all three, a human approves side effects. Design patterns: plan-then-execute, dual LLM and four more in this paper. Cutting agent cost Route easy steps to a small model → cache a stable prompt prefix → cap context and tool output → stop early. Hosting and batch pricing: MLA 14. The full course on this topic is Gnothi's Agentic AI Course, next to Claude Code, at ocdevel.com/courses. More in the resources. Next: MLA 29, on OpenClaw and personal agents.
Embed this episode
No transcript yet.