Tool Use and Function Calling for LLM Agents — Best Practices Guide
Design reliable tool schemas for LLM agents — naming, descriptions, error handling, and why fewer, clearer tools beat a large tool catalog.

Tool use is where most LLM agent reliability problems actually live — not in the model's reasoning, but in ambiguous tool schemas, unhelpful error messages, and tools that compound mistakes when retried. Here's how to design tools that hold up under real agent loops.
Step 1: Write Tool Descriptions as Decision-Time Prompts
The model reads a tool's name and description every time it decides whether to call it — a vague description causes wrong-tool selection even when the implementation behind it is correct.
Explicitly stating when not to use a tool (for open-ended exploration... use explore_codebase instead) resolves ambiguity at decision time instead of leaving the model to guess between two similar-sounding tools.
Step 2: Keep the Toolset Small and Non-Overlapping
Every additional tool with a similar purpose to an existing one increases the chance of the model picking the wrong one. Consolidating overlapping capabilities into a single, well-parameterized tool is usually better than adding a new tool for every variation.
Step 3: Use Constrained Types Over Free-Text Strings
An enum is validated before the tool implementation ever runs, catching an invalid value immediately with a clear schema error — a free-text status field invites typos and casing inconsistencies ("Closed" vs "closed") that only surface as a bug deep inside the tool's logic.
Step 4: Return Actionable Errors, Not Just "Error"
A specific error message that names what's wrong and hints at the correct path forward lets the model self-correct on the very next turn. A bare "error": true response tends to produce either an identical retry of the same failing call or the model giving up on the task entirely.
Step 5: Design Tools to Be Idempotent Where Possible
Agent loops sometimes retry a tool call after a timeout or an ambiguous response. If the underlying action isn't idempotent, that retry can silently duplicate a side effect — sending a duplicate email, double-charging a payment, or incrementing a counter twice for one logical action.
Step 6: Scope Tool Availability to the Current Task Phase
Rather than exposing the full tool catalog on every single turn, restricting it to what's relevant for the current phase of a task reduces the chance of an irrelevant tool being selected simply because it was available.
Key Takeaways
Tool descriptions function as decision-time prompts and need to be specific enough to disambiguate from similar tools, constrained parameter types catch invalid input before it reaches the implementation, actionable error messages let a model self-correct instead of retrying blindly, and idempotent tool design prevents a retried call from silently compounding a side effect.






