Prompt & Context Engineering·Question 19 of 68IntermediateAI-75

How do you design good tool/function definitions for an LLM? What makes tool calling fail?

Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.

Model answer: the part to lead with

Treat tool definitions as prompts - they are read by the model, verbatim, on every request. The quality bar is "a new hire could use this tool correctly from the description alone, without asking questions."

Full worked answer

Treat tool definitions as prompts - they are read by the model, verbatim, on every request. The quality bar is "a new hire could use this tool correctly from the description alone, without asking questions."

Design rules:

  • Description says what, when, and when not. Not just "Searches orders" but "Search the customer's order history by keyword or date range. Use for questions about past purchases. For shipping status of a known order, use get_order_status instead." Disambiguation between overlapping tools is the single highest-value line, because tool selection is where most failures happen.
  • Parameter descriptions carry format and defaults: "date_range: ISO-8601 dates, e.g. 2026-01-01..2026-03-31. Defaults to last 90 days." Enums beat free strings wherever possible. Fewer parameters beat more; make the common case require minimal arguments.
  • Unambiguous names (search_orders, not query2), consistent naming conventions across the toolset, and no two tools whose descriptions a reasonable reader could confuse.
  • Design return values for the model, not for a program: concise, token-efficient, self-describing. Errors should be instructive - "customer_id not found; call lookup_customer with an email first" turns a dead end into a recovery path. Truncate or paginate large results; a 50k-token JSON dump is context pollution.

Why tool calling fails, roughly in order of frequency: overlapping tools confuse selection; vague parameter specs produce malformed or guessed arguments (models will fabricate a plausible customer_id rather than ask); too many tools in context (dozens of schemas burn tokens and degrade selection - filter to the relevant subset per request, or let the model search a tool catalogue and load definitions on demand, which some providers and MCP clients now support); raw error strings the model can't act on; and descriptions that drift out of sync with actual API behaviour.

Also state the eval discipline: tool descriptions deserve their own tests - a set of user utterances with expected tool + argument assertions, run on every description change. Provider tool-use guidance (Anthropic's most explicitly) treats description quality as the biggest single lever on tool-use performance.

What a good answer covers

  • Treat tool definitions as prompts - they are read by the model, verbatim, on every request
  • The quality bar is "a new hire could use this tool correctly from the description alone, without asking…
  • Description says what, when, and when not
  • Parameter descriptions carry format and defaults: "date_range: ISO-8601 dates, e.g
  • Unambiguous names (search_orders, not query2), consistent naming conventions across the toolset, and no…

Key terms: Unambiguous names

Interviewer follow-ups to expect

  1. An agent keeps picking the wrong one of two similar tools - what are your first three fixes?

  2. How do you handle a tool that returns 100k tokens of JSON?

  3. When should the model ask a clarifying question instead of calling a tool with guessed arguments?

Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep