14 cards
Three levels
Single call → workflow (code controls the steps) → agent (the model decides the steps in a tool loop); start from the simplest level.
4 questions before building an agent
Complex enough? Worth the cost? Is Claude good at this task? Can errors be detected and recovered from?
Tool Runner vs Agent SDK
Tool Runner is a beta helper in the API SDK that runs the loop for tools you define; Agent SDK is a separate package wrapping Claude Code's engine with built-in tools.
Managed Agents
An option (beta) where Anthropic hosts both the agent loop and the execution sandbox.
Install the Agent SDK
`npm install @anthropic-ai/claude-agent-sdk`; `pip install claude-agent-sdk`; uses an API key, does not read `.env` by itself.
`allowedTools` in the Agent SDK
Only a list of auto-approved tools; a read-only agent also needs `permissionMode: "dontAsk"` or `disallowedTools` so other tools are denied.
Good tool description
What it does, when to use it, what it returns, its limits, whether it has side effects; name in verb + object form.
Tool errors with guidance
Return `is_error: true` with the reason and how to fix it so the model adjusts instead of looping.
Tools with side effects
Separate read/write, confirmation outside the model, idempotency keys, limits in code, least privilege.
Where business and security rules belong
In the tool's code, not only in the prompt, because prompts can be misread or injected.
Starter eval set
30–100 well-labeled cases, including hard cases and production failures; keep a separate final test set to avoid overfitting.
Three ways to grade evals
Code when there is a clear answer; LLM-as-judge with a rubric for open-ended output; humans to define "good" and calibrate the judge.
LLM-as-judge is more reliable when
Criteria are binary, it gives reasons, agreement with humans is measured, it is separate from the system being graded, sources are hidden when comparing.
Debugging a broken agent
Get the transcript, find the first turn that went wrong, classify (prompt/tool/data/model), fix at the right layer, add the case to the eval.