The Loop.

Field notes for people building AI agents. In-depth, sourced, and written to be useful on a Tuesday afternoon.

Models · 6 min read

Max output tokens on current models: the cap that cuts your agent off mid-thought

Claude, GPT-6.2, Gemini 4 and DeepSeek all advertise huge context windows, but the output cap is the limit agents actually hit. Here's what each provider allows per response, how thinking eats into it, and how to size the setting.

Read article →
Protocols · 7 min read

AGENTS.md across coding agents: who reads it, which file wins, and where it gets skipped

Codex, Claude Code, Gemini CLI and GitHub Copilot all say they support AGENTS.md, but they find it, merge it and override it in different ways. Here's what each one actually loads, per the official docs.

Read article →
Craft · 7 min read

Rate limits in agent loops: read the headers before the 429 shows up

Claude, OpenAI and Gemini all meter requests and tokens per minute, but they count different tokens, report them in different formats and throw different 429s. Here's how an agent loop should pace itself on each one.

Read article →
Costs · 7 min read

Turning the usage object into dollars: how Claude, OpenAI and Gemini count the tokens you pay for

Every API response tells you what it cost, but Claude, OpenAI and Gemini split cached, written and thinking tokens differently. Read the fields the wrong way and your per-run cost meter is off by 40 percent or more. Here's how to do the math on each.

Read article →
Costs · 9 min read

Output tokens are the pricey side: where an agent's output bill comes from and how to shrink it

On current Claude, OpenAI and Gemini models, output tokens cost five times what input does, and thinking, tool arguments and replies all bill at that rate. Here's how the output side of an agent run adds up on Claude, OpenAI and Gemini as of November 2026, and the settings that actually cut it.

Read article →
Craft · 8 min read

Tool choice for agents: when to force a tool call, when to forbid one, and when to leave it alone

Claude, OpenAI and Gemini all let you force, restrict or block tool calls, but the option names, the thinking trade-offs and the caching side effects differ. Here's how tool_choice actually behaves on each and where it fits in an agent loop.

Read article →
Protocols · 6 min read

Streaming tool calls: how Claude, OpenAI and Gemini send partial arguments, and how to put them back together

All three big APIs stream tool calls as fragments of JSON over server-sent events, but the event names, the indexes and the "it's done" signal differ. Here's what each one actually sends and how to assemble the pieces without running a tool on half an argument.

Read article →
Models · 6 min read

Temperature is gone: what replaced sampling knobs on the models agents use

Claude, GPT-6.2 and Gemini 4 now reject or ignore temperature, top_p and top_k, and OpenAI's newest models drop logprobs too. Here's what each API does with those fields today and what to use in your agent instead.

Read article →
Costs · 6 min read

The 10 percent region tax: what data residency costs an agent

Pinning model inference to the US or EU costs about 10 percent more on Claude, OpenAI and Google Cloud, and an agent pays it on every turn. Here's how each provider bills it and how to keep it off traffic that doesn't need it.

Read article →
Craft · 8 min read

Too many tools: tool search and deferred loading for agents

Once an agent has dozens or hundreds of tools, sending every schema on every turn costs tokens and makes the model pick worse. Here's how Anthropic's and OpenAI's tool search work, where they differ, and the mistakes that get you a 400.

Read article →
Protocols · 8 min read

What an MCP tool should return: content blocks, structuredContent and outputSchema

The MCP spec gives a tool five kinds of content block, a structuredContent field, an outputSchema and an isError flag. Here is what each one is for, what the 2026-07-28 spec actually requires, and how to shape results so the model and your code both get what they need.

Read article →
Models · 6 min read

What a screenshot costs your agent: image tokens on Claude, OpenAI and Gemini

Every screenshot an agent sees becomes input tokens, and each provider counts them differently. Here is the math for a 1920x1080 frame on three APIs, and why a computer-use loop pays for the same picture over and over.

Read article →
Costs · 7 min read

Long-context price steps: the token count where your agent's bill quietly doubles

Several model APIs charge more per token once a single prompt crosses a length threshold, and agent loops cross it without telling you. Here is where the steps sit today at OpenAI, Anthropic, Google and xAI, what they cost, and how to keep a long run under the line.

Read article →
Craft · 8 min read

Stop reasons are your agent loop's control flow: handling every way a model turn ends

Every model response says why it stopped, and that one field decides whether your loop runs a tool, continues, retries or gives up. Here is what Anthropic, OpenAI and Gemini actually return, and a small dispatcher that handles all of it.

Read article →
Protocols · 7 min read

MCP resources and prompts: when your server should expose data and templates instead of tools

Most MCP servers ship nothing but tools. The 2026-07-28 spec gives you two other primitives with a different owner, resources for the app and prompts for the user. Here is how each one works on the wire and how to decide which one a feature belongs in.

Read article →
Models · 7 min read

Model IDs, aliases and deprecations: keeping your agent on the model you tested

Claude, OpenAI and Gemini each name and retire models differently. Here is what a pinned ID actually guarantees on each platform as of November 2026, which retirements land in the next few weeks, and how to catch a model change before your agent does.

Read article →
Costs · 6 min read

Counting tokens before you send: the token counting APIs agent builders should use

How the free token counting endpoints on Claude, the OpenAI Responses API and Gemini work as of November 2026, what they can't count, and how to build a pre-send budget check into an agent loop.

Read article →
Craft · 8 min read

When to split an agent into subagents, and when one loop is better

Multi-agent setups can find answers a single agent misses, but they burn far more tokens and can contradict themselves. Here is how the orchestrator-worker pattern, handoffs and agents-as-tools actually differ, and a practical test for whether your task should be split at all.

Read article →
Protocols · 8 min read

The MCP Registry for agent builders: publishing a server and reading the API

The official MCP Registry stores metadata, not code. Here is how server.json, namespace verification and the read-only REST API work as of November 2026, how to publish a local or remote server, and how an agent platform should consume the registry without hammering it.

Read article →
Models · 7 min read

Picking an embedding model for agent memory and retrieval

Embeddings decide what your agent can find before the LLM ever sees it. Here is how OpenAI's text-embedding-3 models, Google's Gemini Embedding 2 and local Ollama models compare on price, dimensions and query formatting as of November 2026, with storage math and the migration trap that forces a full re-embed.

Read article →
Costs · 8 min read

Flex, Fast and Priority tiers: picking a service tier for each agent call

OpenAI, Google and DeepSeek now sell the same model at several prices depending on how fast and how reliably you want it. Here is how flex, fast, priority and off-peak pricing work as of November 2026, with worked math for an agent loop and the fallback logic that keeps the discount from turning into a bill surprise.

Read article →
Craft · 13 min read

Sandboxing agents that run code: isolation, network policy, and what to let back into context

When an agent writes and runs code, the sandbox is the real security boundary. Here is how hosted containers and self-hosted isolate APIs actually work as of November 2026, and the mistakes that leak files, tokens, or untrusted output.

Read article →
Protocols · 7 min read

Background Responses and webhooks: finishing long agent jobs without holding the socket

How OpenAI Background mode and Standard Webhooks let agent builders run multi-minute Responses jobs without proxy timeouts, with polling, resume cursors, thin event payloads and signature verification as of November 2026.

Read article →
Models · 8 min read

Prompt caching for agent loops: Anthropic, OpenAI and Gemini compared

How prompt and context caching actually works on Claude, the OpenAI Responses API and Gemini as of November 2026, with current write/read prices, TTL options and a worked 12-turn agent example.

Read article →
Costs · 7 min read

Hosted tool fees: what web search, fetch and code execution add to an agent run

Provider-hosted tools like web search, code execution and file search carry their own fees on top of tokens, and the tokens they pull into context often cost more than the fee. Here is how Anthropic, OpenAI and Google price them as of November 2026, with a worked example and the knobs that keep the bill sane.

Read article →
Craft · 8 min read

Agent Skills: how to write a SKILL.md your agent actually loads

Agent Skills package instructions, scripts and reference files so an agent only pulls them in when a task calls for them. Here is how the loading works, how to write a description that triggers, and the portability and security traps to check before you ship one.

Read article →
Protocols · 8 min read

MCP extensions: how the opt-in layer works and which ones are worth adopting

The 2026-07-28 MCP revision made extensions an official part of the protocol and moved tasks out of core. Here is how extensions are negotiated, what the lifecycle stages promise, and how to decide whether your server should use Apps, Tasks, Skills or the auth extensions.

Read article →
Models · 8 min read

Running an agent on a local model: the tool-calling settings that quietly break it

Ollama, vLLM and llama.cpp all speak OpenAI-style tool calling, but each has a default that can wreck an agent loop, from a 4k context window to unconstrained arguments. Here is what to change before you blame the model.

Read article →
Costs · 8 min read

Model routing for agents: when sending easy work to a cheap model actually cuts the bill

Routers, cascades and mid-run model switches, priced on real November 2026 rates, including the prompt-cache penalty that makes switching models inside a loop more expensive than it looks.

Read article →
Craft · 10 min read

Agent memory design: what to remember across sessions, where to keep it, and how to stop it rotting

How Claude's memory tool, OpenAI Agents SDK sessions and LangGraph stores split short-term and long-term memory, and the design decisions they leave to you: what to write, when to write it, who can read it, and when to forget.

Read article →
Protocols · 8 min read

Tracing agent runs with OpenTelemetry: the GenAI span names, attributes and privacy defaults

OpenTelemetry now has a dedicated set of conventions for agents, model calls, tool calls and MCP traffic. Here is how the spans nest, which attributes matter, and why prompts stay out of your traces by default.

Read article →
Models · 10 min read

Parallel tool calls: how OpenAI, Anthropic and Gemini batch them, and how to run the batch safely

All three major model APIs can return several tool calls in one turn. Here is how each one signals a batch, how to turn it off, and how an agent harness should execute and answer the calls without breaking the loop.

Read article →
Costs · 9 min read

Budget caps for agent runs: turn limits, token budgets and provider spend limits

A runaway agent loop can cost ten times a normal run before anyone notices. Here is how to cap a single run with turn limits and token budgets, how provider spend limits behave when you hit them, and why your retry logic needs to know the difference.

Read article →
Protocols · 8 min read

A2A 1.0 for agent builders: when your agent should call another agent instead of a tool

The Agent2Agent protocol reached its first stable release this year. Here is how its Agent Cards, tasks, and update channels work, how it differs from MCP, and when it is worth adding to a system you already run.

Read article →
Craft · 9 min read

Prompt injection in tool results: designing agents that stay safe when they read untrusted text

Filters and stern system prompts don't stop indirect prompt injection. Here is how to reason about the risk with the lethal trifecta, and the design patterns that actually limit what injected text can do.

Read article →
Models · 8 min read

Structured outputs for agents: what the JSON schema guarantee actually covers

OpenAI, Anthropic and Google all offer schema-constrained JSON output. Here is what each one enforces, what it quietly ignores, and the edge cases an agent still has to handle.

Read article →
Costs · 7 min read

Batch APIs for agent workloads: when half price is worth the wait

OpenAI, Anthropic and Google all sell batch inference at 50% off. Here is which agent jobs fit a 24-hour window, which do not, and the details that bite.

Read article →
Protocols · 11 min read

OAuth for remote MCP servers: the 2026-07-28 auth flow

How a remote MCP server advertises its authorization server, how clients register and get audience-bound tokens, and the mistakes the spec forbids.

Read article →
Craft · 9 min read

Evaluating agent tool calls: outcomes, paths and consistency

How to build evals for a tool-using agent: grade outcomes, check only required tool calls, track pass^k, and catch grader bugs.

Read article →
Craft · 9 min read

Approval gates for agent tool calls: where to put the human in the loop

How OpenAI's Agents SDK, the Claude Agent SDK, LangGraph and MCP let an agent pause for a person before risky tool calls, and how to choose which calls need a gate, what the reviewer sees, and how to resume safely.

Read article →
Costs · 8 min read

Context compaction for agent loops: when trimming history actually cuts the bill

Tool result clearing and server-side compaction on Anthropic and OpenAI, with worked cost math showing when shrinking an agent's context saves money, when it costs more, and how it interacts with prompt caching.

Read article →
Models · 8 min read

When reasoning models help (and waste tokens) in agent loops

How Anthropic thinking, OpenAI reasoning effort, and Gemini thinking_level change cost and quality inside multi-turn tool-using agents, and when to keep them off.

Read article →
Protocols · 9 min read

MCP drops sessions: what the 2026-07-28 revision changes for agent builders

The newest Model Context Protocol revision removes the initialize handshake, protocol sessions, and server-initiated requests. Here is what that means for the servers you host, the clients you build, and the migration path in between.

Read article →
Craft · 9 min read

Handling tool errors in agent loops: retries, idempotency, and knowing when to stop

A practical craft guide to the failures that happen between an agent and its tools, how to report them so the model can recover, when your code should retry instead of the model, and how to keep retries from doing damage.

Read article →
Models · 6 min read

How to Choose an LLM for Your AI Agent (October 2026 Edition)

A practical, data-backed guide to picking a model for agent work in October 2026, using Artificial Analysis and LMArena scores plus official list prices.

Read article →
Protocols · 6 min read

What Is an MCP Server? A Plain-English Guide, With a Free One to Try

What the Model Context Protocol is, how MCP servers work under the hood, and how to connect the free Agent Toolbox MCP server to your own agent in a few minutes.

Read article →
Costs · 6 min read

Why Your Agent Costs More Than You Think: A Practical Guide to Tool-Calling Costs

How tool definitions, growing histories, and multi-turn loops drive the cost of AI agents, with a worked example and the caching and batching discounts that actually move the bill.

Read article →
Craft · 7 min read

Writing tool descriptions and schemas that agents use reliably

A practical craft guide to naming tools, writing descriptions, and designing JSON schemas so language models call the right function with the right arguments.

Read article →

Want the short version in your inbox? The Agent Toolbox newsletter is a short daily roundup; The Loop is where we go deep. Subscribe with the form at the bottom of this page.