podqast
Machine Learning GuideOCDevelAll episodes

MLA 028 How to Build an AI Agent in 2026

33 min
Next episodeMLA 029 Is OpenClaw Safe? Uses and Alternatives33 min
Get its new episodes on Latest. No account

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

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.

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]

Also about technology and AI
Every episode about Technology & AI
More from Machine Learning Guide