The knowledge base

Build agents that hold up.

Practical patterns for agent loops, tools, memory, evaluation, safety, and production infrastructure—distilled for builders.

59 field notes1 episodeAsk the library →

Knowledge base

Field notes

59 of 59

Token budgets

Cost control and token economics

Measure cost per completed task, not cost per model call, because cheap models can become expensive when they cause retries or long trajectories. Reduce repeated input with prompt caching,…

Useful?
anthropic.comsource ↗
Memory

Deploying agents on serverless infrastructure

Treat serverless agent workers as stateless and persist conversation state, plans, checkpoints, idempotency records, and pending approvals in durable services because instances can disappear…

Useful?
docs.aws.amazon.comsource ↗
Evaluation

Agent evaluation pitfalls

Agent evaluations should separate model quality from scaffold, tool, and environment failures. Single-run pass rates hide nondeterminism, while overly short time or token limits can…

Useful?
anthropic.comsource ↗
Safety

Agent identity and secret management

Give each agent workload a distinct identity and short-lived, task-scoped credentials instead of placing broad API keys in prompts, tool output, logs, or persistent memory. A trusted…

Useful?
csrc.nist.govsource ↗
Foundations

What an agent loop is

An agent loop repeatedly reads the current state, chooses an action, uses a tool, observes the result, and corrects its plan. The model is only one component: reliable agents also need…

Useful?
anthropic.comsource ↗
Memory

Short-term and long-term agent memory

Short-term memory is the working context supplied on each model call: recent messages, the current plan, tool results, and task-local state; it is bounded by the context window and…

Useful?
arxiv.orgsource ↗
Safety

Tracing and replay for agents

Represent each agent run as a trace with spans for model calls, retrieval, tool execution, guardrails, handoffs, and human approvals, linked by stable run and parent identifiers. Log model…

Useful?
opentelemetry.iosource ↗
Safety

AI agent security: the complete map

Pillar hub mapping the four agent attack surfaces — input (prompt injection), memory (poisoning), execution (sandboxing), authority (guardrails/approval gates) — with links to the deep-dive…

Useful?
agent-loop.xyzsource ↗
Safety

Production coding agents

Coding agents should work in isolated, least-privilege sandboxes with repository-scoped credentials, network controls, resource limits, and explicit approval for destructive commands, secret…

Useful?
arxiv.orgsource ↗
Memory

Context management and compaction

Manage context as a budget: retain the system policy, current objective, unresolved constraints, recent actions, exact error messages, and identifiers needed for future tool calls, while…

Useful?
anthropic.comsource ↗
Memory

What is context rot, and how do you prevent it?

Context rot is the degradation of agent performance as the context window fills — long before the technical token limit — because attention favors the start and end of the window and buries…

Useful?
research.trychroma.comsource ↗
Safety

Production customer support agents

A support agent can deflect repetitive requests by answering from versioned help-center content and resolving low-risk tasks such as checking delivery status, but it should cite the…

Useful?
anthropic.comsource ↗
Retrieval

Determinism and reproducibility

Lower temperature can reduce sampling variation for extraction and routing, but it does not make a hosted model or a multi-step agent deterministic because model revisions, parallel tools,…

Useful?
thinkingmachines.aisource ↗
Orchestration

Durable execution and checkpointing

Long-running agents should execute as resumable state machines whose durable checkpoint records the current step, validated state, completed side effects, pending approvals, retry counters,…

Useful?
docs.temporal.iosource ↗
Retrieval

Production e-commerce agents

E-commerce agents should combine lexical and semantic product retrieval with hard filters for inventory, locale, compatibility, price, and fulfillment, and clearly label sponsored or…

Useful?
agenticcommerce.devsource ↗
artificialintelligenceact.eu

Does the EU AI Act apply to my AI agent?

Article 50 of the EU AI Act has been enforceable since 2 August 2026 and applies to agents regardless of high-risk status — the Annex III high-risk regime was separately deferred to 2…

Useful?
artificialintelligenceact.eusource ↗
Evaluation

Offline and online agent evaluation

Offline evals provide repeatable pre-release regression tests over representative tasks, adversarial cases, tool failures, and multi-step trajectories; online evals measure real completion,…

Useful?
anthropic.comsource ↗
Use cases

Production agents in finance

Finance agents need data minimization, field-level protection for PII, least-privilege access, immutable audit trails, retention controls, and jurisdiction-specific compliance review. Keep…

Useful?
nist.govsource ↗
Safety

Layered guardrails for agent actions

Guardrails should be enforced in code around the model: validate inputs and outputs, authorize every tool call against the user and task, constrain arguments with allow-lists, and run code…

Useful?
nist.govsource ↗
Use cases

Production agents in healthcare

Healthcare agents handling protected health information require HIPAA-aligned administrative, physical, and technical safeguards, minimum-necessary data access, vendor agreements where…

Useful?
hhs.govsource ↗
Safety

Human approval gates for high-stakes actions

Place approval gates immediately before consequential actions such as sending messages, moving money, changing production, deleting data, or releasing regulated decisions, rather than asking…

Useful?
anthropic.comsource ↗
Evaluation

Latency and streaming agent results

Optimize both time to first useful feedback and total task time: stream text or structured progress, acknowledge long-running work immediately, and expose tool status without leaking private…

Useful?
developers.openai.comsource ↗
Retrieval

Production agents for legal work

Legal agents should retrieve from authoritative, jurisdiction- and date-filtered corpora and preserve court, reporter, docket, pinpoint citation, precedential status, and source text for…

Useful?
hai.stanford.edusource ↗
Token budgets

Unbounded work will exhaust the system

In 2019 a single regular expression with catastrophic backtracking consumed CPU globally and took Cloudflare offline. Lesson: any operation without an explicit bound can consume all…

Useful?
blog.cloudflare.comsource ↗
Memory

Test your recovery, not just your backups

In 2017 GitLab lost production data when a tired engineer removed a directory on the wrong host, then discovered that five separate backup/replication methods had silently been failing.…

Useful?
about.gitlab.comsource ↗
netflix.github.io

Inject failure deliberately to build resilience

Netflix's Chaos Monkey randomly kills production instances so the system is forced to tolerate failure as a normal condition rather than a rare emergency. Lesson: resilience comes from…

Useful?
netflix.github.iosource ↗
Tools

Model Context Protocol

The Model Context Protocol is an open standard for connecting AI applications to external tools and data. MCP uses a client-server architecture: servers expose resources, prompts, and…

Useful?
modelcontextprotocol.iosource ↗
Tools

MCP went stateless: the 2026-07-28 spec revision

The largest MCP revision since launch makes the protocol stateless: the initialize handshake and sessions are gone, every tool call is a self-contained HTTP request, and server-initiated…

Useful?
modelcontextprotocol.iosource ↗
Retrieval

Choosing models, prompting, RAG, and fine-tuning

Choose the smallest model that meets measured quality, tool-use, context, latency, modality, privacy, and reliability requirements on your own task distribution, then route exceptional cases…

Useful?
docs.claude.comsource ↗
Orchestration

Multi-agent orchestration tradeoffs

Use multiple agents when subtasks are genuinely independent, require distinct tools or context, or benefit from parallel search or review; a single agent is usually cheaper, faster, and…

Useful?
anthropic.comsource ↗
Use cases

Production back-office agents

Back-office agents are useful when documents vary and judgment is needed, while deterministic RPA remains preferable for stable screens and fixed rules; combine them by letting the model…

Useful?
uipath.comsource ↗
Orchestration

Planning and task decomposition

ReAct interleaves reasoning, actions, and observations so the agent can revise its approach from environmental feedback; plan-then-execute first creates a task graph and is better when…

Useful?
arxiv.orgsource ↗
Token budgets

Prompt caching and context reuse

Prompt caching reduces latency and input cost when many calls share a long stable prefix such as system instructions, tool definitions, examples, or reference documents. Put stable content…

Useful?
platform.claude.comsource ↗
Safety

Defending against prompt injection

Treat retrieved pages, emails, documents, tool outputs, and user-uploaded files as untrusted data, even when they contain text claiming to be system instructions. Keep instructions and data…

Useful?
ncsc.gov.uksource ↗
Retrieval

Retrieval-augmented generation basics

Retrieval-augmented generation embeds a question, retrieves semantically similar passages from a knowledge base, and places those passages in the model context. Good RAG systems preserve…

Useful?
learn.microsoft.comsource ↗
Memory

Rate limiting and backpressure

Model providers can limit requests, input tokens, output tokens, or concurrent work, so admission control must estimate token load rather than count requests alone. Use per-tenant quotas,…

Useful?
developers.openai.comsource ↗
Retrieval

Chunking, hybrid retrieval, and reranking

Chunk along semantic boundaries and keep headings, source URL, timestamps, permissions, and neighboring relationships; chunks should be small enough to isolate an answer but large enough to…

Useful?
learn.microsoft.comsource ↗
Use cases

Production sales and GTM agents

Sales agents should personalize from consented, relevant data, respect suppression lists and communication rules, and avoid inferring sensitive traits or fabricating customer facts. CRM…

Useful?
salesforce.comsource ↗
firecracker-microvm.github.io

How do you sandbox AI agent code execution?

Treat every line of LLM-generated code as hostile: run it in a microVM (Firecracker) or user-space kernel (gVisor) rather than a plain shared-kernel container, and lock down network egress,…

Useful?
firecracker-microvm.github.iosource ↗
Tools

Structured outputs with JSON Schema

Use schema-constrained generation when downstream code needs machine-readable output: define required fields, closed enums, bounds, and disallow unexpected properties where the provider's…

Useful?
developers.openai.comsource ↗
anthropic.com

When should you use subagents?

A subagent is a specialized worker with its own isolated context window and restricted tools; the orchestrator hands off a bounded task and only the result flows back. Use subagents when…

Useful?
anthropic.comsource ↗
Evaluation

Token budgets change agent capability

UK AI Security Institute evaluations found that increasing an agent's token budget from 1 million to 10 million tokens improved success on software-engineering tasks by roughly 25 percent.…

Useful?
aisi.gov.uksource ↗
Reliability

Retries, timeouts, and idempotent tools

Give every networked tool a connection timeout, an overall deadline, and a bounded retry policy using exponential backoff with jitter only for transient failures such as throttling or…

Useful?
aws.amazon.comsource ↗
Tools

Function and tool schema design

Expose narrow, intent-level tools with unambiguous names and descriptions, explicit required fields, typed enums and bounds, and no overlapping functions that differ only subtly. Do not…

Useful?
developers.openai.comsource ↗
Tools

Reliable tool use

Tool-using agents work best with narrow tools, explicit schemas, actionable error messages, and observable results. Validate arguments before execution, use idempotency keys for side…

Useful?
platform.openai.comsource ↗

Watch the loop

Episodes