AIF-15Required
Design tools like a small public API
Give each tool one clear job, a verb-noun name, a description of when to use it and a strict input schema. Validate every argument in code before the tool runs.
How to do it
Expose few tools, ideally 20 or fewer per request, because models choose worse among many. Name them like find_order and create_return, never do_action. Describe in one or two sentences what the tool does and when not to use it. Use enums and formats instead of free text. Set strict: true on each tool definition, as the OpenAI and Anthropic APIs both allow. Check the user's rights inside the tool, as least power requires.
Examples
TypeScript example
export const findOrder = {
name: 'find_order',
description: 'Look up one of the signed-in customer\'s orders by its number. Do not use it to search by product name.',
input: z.object({ orderNumber: z.string().regex(/^[A-Z]-\d{4,}$/) }).strict(),
run: async ({ orderNumber }: { orderNumber: string }, user: User) => orders.findForCustomer(orderNumber, user.id),
};
Python example
class FindOrderInput(BaseModel):
model_config = {"extra": "forbid"}
order_number: str = Field(pattern=r"^[A-Z]-\d{4,}$")
def find_order(raw_args: dict, user: User) -> dict:
args = FindOrderInput.model_validate(raw_args)
return orders.find_for_customer(args.order_number, user.id)
find_order.description = "Look up one of the signed-in customer's orders by its number. Do not use it to search by product name."
How to check
A test loads every tool definition. Each has a name matching ^[a-z]+_[a-z_]+$, a description of at least 40 characters, additionalProperties: false and no untyped parameter. A call with a wrong argument type is rejected before the tool body runs.
Sources
Related rules
- APS-85 Give agent tools the least power they need in Application security
- STK-89 Use the Model Context Protocol to give agents your tools in Software choices
- AGT-14 Reject MCP requests whose headers disagree with the body in Agents as users
- AGT-15 Keep the tool list within a token budget in Agents as users
- AGT-23 Run agent calls through the same business rules as the app in Agents as users
- SUP-30 Give the bot no more power than the lowest support tier in Customer support
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/ai-features/structured-output-and-tools/tool-design">Agent Wranglers AI features playbook</a>. In code you write, add a comment next to it with the same link.