Tools and function calling
How a model calls your functions: defining a tool, the tool use loop, tool results and errors, the raw JSON on the wire, the SDK's tool runner, and how to write good tools.
AI series 3 of 5. How a model acts in the world. Tools, MCP, agents, workflow patterns, memory and multi-agent systems.
8 parts
How a model calls your functions: defining a tool, the tool use loop, tool results and errors, the raw JSON on the wire, the SDK's tool runner, and how to write good tools.
What MCP is, why it exists, hosts, clients and servers, tools, resources and prompts, the two transports, and a small MCP server in Python.
What makes a system an agent, how it differs from a workflow, when an agent is worth it and when it is not, a minimal agent in Python, and the Claude Agent SDK.
Prompt chaining, routing, parallelization, orchestrator-workers and evaluator-optimizer: the patterns that solve most LLM tasks without a full agent, with short Python for each.
How agents keep working when a task outgrows the context window: context engineering, compaction, clearing tool results, notes and the memory tool, with safe file handling.
When several agents beat one: the orchestrator-subagent design, what Anthropic measured in its research system, the token cost, and subagents in the Claude Agent SDK.
Agents that operate a desktop through screenshots, mouse and keyboard, and skills: folders of instructions and scripts that give an agent expertise only when it needs it.
What WebMCP is and how it relates to MCP: a page registers tools with document.modelContext, forms become tools with two attributes, annotations, iframes, testing in Chrome, and the security risks.