Designing APIs for Agents
TL;DR Highlight
Dropping defaults, using specific field names, and writing precise errors help agents misuse your API less.
Who Should Read
A backend developer designing SDKs or internal APIs that agents will call and unsure how many human-friendly conveniences to keep.
Core Mechanics
- Agent API design is the opposite of human design
- Human-first APIs work in fifty lines and reveal other fields through autocomplete.
- Agents read your whole docs in the first prompt and write thousands of lines in seconds.
- So clarity, where reading the code tells you what it does, comes first.
- Defaults are bad, so fill everything in
- Agents can read the docs and fill in sensible starting values for every field.
- The cost of filling many fields has vanished, while the cost of understanding code has gone way up.
- Separate less important fields with comments.
- Errors are good if they are precise
- Coalescing like uppercase-to-lowercase or accepting true, yes, on, 1 hurts agent codebases.
- It makes functions use different values for the same thing and confuses later reviewers.
- In the author's data, 27% of the friction agents hit comes from errors.
- Telling agents to read the docs in the error message helps.
- Use specific field names instead of generic ones
- Ask an agent to use name across ten use cases and it will use it in five different ways.
- Prefer names like displayName, slug, or externalId that carry no shared assumptions.
- Doc comments help lock in the right interpretation.
- An API's value is the facts it provides
- The value is facts you can't replicate internally, such as a bill paid, a message sent, or a VM provisioned.
- Other utilities can be replaced with documentation and guides.
- The author is skeptical of SDKs that do more than map API norms into language patterns.
- Freestyle dropped abstract SDK packages for exec plus guides
- It used to hide complexity behind packages like VmBun, but they weren't configurable enough and agents misused them.
- Months ago it removed every complex SDK package in favor of a guide.
- Now the agent reads the guide and adapts the code to your project's norms.
Community Reactions
- A feedback tool for agents
- One commenter heard of an MCP with a feedback tool whose description tells coding agents to call it whenever they struggle with the rest of the MCP.
- They called it cheap to implement and expected actionable signal.
- Removing defaults hurts human debugging
- One commenter said it makes quick debugging with curl hard.
- They compared it to HTTP/1, where a couple of headers are enough to type a request by hand.
- Another used CreateFile in Win32 to show that filling every parameter makes code harder to read.
- Six tips from someone who built for agents
- A commenter shared text-first output, grep-friendly lines, and short prefixed IDs like cus_abc123.
- They also suggested context-rich list responses, bulk operations, and errors with doc links and hints.
- They applied these in an open-source CRM called crmkit.
- Materializing defaults as a compromise
- One commenter writes extension defaults into the settings file at startup.
- The agent then sees the full settings surface, and new settings appear automatically.
- The downside is the agent can't tell which values were overridden.
- Pushback on the article's examples
- One commenter said the git clone wrapper example has a command injection vulnerability.
- Another argued defaults exist for a reason and CLIs like git shouldn't force every parameter.
How to Apply
- Find and rename vague API fields
- Grep your API schema today for generic fields like name, id, type, and value.
- List replacement candidates such as displayName, slug, and externalId.
- Write allowed characters and ranges for each field in doc comments.
- Put cause and doc links in error responses
- In 4xx errors, say which value is wrong and what is allowed.
- Include the relevant doc URL and a correct example in the body.
- Turn silent corrections like case folding or multiple spellings into errors.
- Add a feedback tool to your agent-facing API
- Add one feedback tool to your MCP or internal tools.
- In its description, tell agents to call it when they can't figure out usage.
- Review the logs to find where agents get stuck and fix the docs.
- Replace a thin wrapper SDK with a guide
- Pick an SDK utility that agents use that a single exec or HTTP call could replace.
- Delete it and move the usage into one guide document.
- Have an agent read the guide and check that it generates correct code.
Try It
// Paste into Claude or ChatGPT (simplified version of the article's principles: agent-facing API audit)
Below is our API schema (OpenAPI or SDK type definitions).
{{API schema}}
Assume a coding agent will use this API, and audit it by these criteria.
1. Find fields like name, id, and type that can be read several ways, and suggest specific replacement names for each.
2. Find fields that rely on defaults and list the values that should be filled in explicitly.
3. Find places that silently coerce bad input (case folding, multiple accepted spellings) and write the error message that should replace each.
4. Write 5 example error messages that include the cause, allowed values, and a doc link.
Present the result as a table.
Next step: give the revised schema to an agent, run the same task 10 times, and compare whether it uses the fields consistently.Terminology
Related Papers
Frostbite: A new CPU architecture discovered, designed and verified by AI
AI agents designed a CPU from scratch, claiming 4.59x perf/W over a traditional core
Restricting AI agents in mobile operating systems platforms from capturing data
Signal now blocks OS-level AI agents from reading its screen on iOS 27 and Android
Actions Speak Louder than Words: Stateful Privacy Sniffing of LLM Agents via Behavioral Covert Channels in Web Interactions
Agents' link choices alone let attackers rebuild user queries at F1 0.89; SOR cuts it to 0.39.
Tracking and Limiting Unsupported Claim Propagation in Multi-Agent LLM Systems: A Provenance-Aware Framework
Passing claims with source, evidence and history kept equivalence at 5 agent stages at 96% versus 31%.
LLM assisted reverse engineering
Pointing an agent at binaries with skills and MD notes made years-long hacks feasible
Metrics-in-the-Loop: Complexity Feedback Reshapes Agent-Written Code
Injecting per-turn complexity reports into coding agents cut code erosion without changing correctness
Why is Gemini 4 Carbon taking so long?
Carbon took nearly an hour on bug fixes that Astra and Opus finished in minutes, mostly from extra unrequested work.
Weight-Space Programming builds neural networks like a 1990s researcher
LLM hand-wrote MNIST weights to 91.3%, using 1990s-style techniques