Curated summary
Writing effective tools for AI agents
Designing Tools for AI Agents
Tools for agents are a different kind of software: they form a contract between deterministic systems and non-deterministic agents, so they must be designed for how agents perceive and act, not simply wrapped around existing functions or APIs. The post argues that effective tools come from an evaluation-driven loop: build a quick prototype, measure it against realistic multi-step tasks, analyze agent transcripts, and iterate, often with agents like Claude Code doing the refactoring themselves.
Building and Evaluating Tools
- Prototype quickly by wrapping tools in a local MCP server or Desktop extension, connecting them to Claude Code (
claude mcp add) or Claude Desktop, or passing them directly into API calls. - Provide LLM-friendly documentation (such as
llms.txtfiles) to Claude when it helps write the tools. - Generate evaluation tasks grounded in realistic data and services, avoiding simplistic sandboxes. Strong tasks often require dozens of tool calls, while weak ones are single lookups.
- Pair each task with a verifiable outcome, using exact matching or an LLM judge, and avoid verifiers that reject correct answers over formatting differences.
- Run evaluations programmatically with simple agentic loops, one per task, and ask agents to output reasoning and feedback before their responses to encourage chain-of-thought behavior.
- Track accuracy alongside runtime, total tool calls, token consumption, and tool errors. Frequent redundant calls can suggest consolidation opportunities.
- Analyze transcripts for confusion, not just final answers, since agents often omit what matters most. Use held-out test sets to avoid overfitting.
Choosing the Right Tools
- Avoid tools that merely mirror API endpoints. Agents have limited context, so a
list_contactstool that dumps everything wastes it, whilesearch_contactsreturns only what's relevant. - Consolidate multi-step workflows into single tools, such as
schedule_eventinstead of separate list and create calls,search_logsinstead ofread_logs, orget_customer_contextinstead of three separate lookups. - Give each tool a clear, distinct purpose, since overlapping tools distract agents from efficient strategies.
Namespacing and Response Design
- Group related tools under prefixes by service and resource (e.g.,
asana_projects_search) so agents can select the right tool. Prefix versus suffix choice affects results and should be tested per model. - Return high-signal fields like
nameorfile_typerather than low-level identifiers likeuuidormime_type. Resolving UUIDs to human-readable identifiers reduced hallucinations in retrieval tasks. - Add a
response_formatenum (e.g.,conciseordetailed) so agents can choose between readable names and technical IDs needed for downstream calls. The post's example shows a 206-token detailed response versus a 72-token concise one. - Response structure (XML, JSON, Markdown) also affects performance, and the best choice varies by task and model.
Token Efficiency and Error Handling
- Use pagination, range selection, filtering, and truncation with sensible defaults. Claude Code caps tool responses at 25,000 tokens by default.
- When truncating, guide agents toward efficient strategies, such as many small targeted searches instead of one broad search.
- Write error messages that state specific, actionable fixes rather than opaque codes or tracebacks.
Prompt-Engineering Tool Descriptions
- Write descriptions as if onboarding a new hire, making implicit context explicit: query formats, niche terminology, and resource relationships.
- Use unambiguous parameter names (
user_idrather thanuser) and enforce inputs and outputs with strict data models. - Small description refinements can yield large gains. The post reports that precise description changes helped Claude Sonnet 3.5 reach state-of-the-art on SWE-bench Verified.
- Tool annotations can disclose whether a tool needs open-world access or makes destructive changes.
Conclusion
Effective agent tools are clearly defined, use context judiciously, combine well across workflows, and let agents solve real tasks intuitively. Because the mechanisms agents use will keep evolving, a systematic, evaluation-driven process is the most reliable way to keep tools improving alongside the models that use them.
Related reading
Continue with another curated summary.