Blog · 5 July 2025 · 4 min read
Your Agent Is Only as Good as Its Tools: A Guide to Crafting High-Quality Instruments for AI
An agent is only as good as its tools: what makes a tool easy for a model to use correctly.
We are in the Cambrian explosion of AI agents. Every day, new frameworks and models emerge, promising more sophisticated reasoning, planning, and autonomous capabilities. But in the race to build smarter agents, we often overlook the most critical component determining their success or failure: the quality of their tools.
Giving a brilliant AI a poorly designed tool is like handing a master watchmaker a rusty, oversized wrench. The potential is there, but the instrument is wrong for the job, leading to frustration, errors, and ultimately, failure. To build truly robust and reliable agents, we must treat tool design as a first-class citizen.
This guide outlines the key principles for crafting exceptional tools for TemplateAgent in kowalski-core, using CSV / data analysis tools as the running example (the old standalone “data agent” crate layout is gone—capabilities are tools + prompts + config now).
The Pillars of Exceptional Tool Design
1. Crystal-Clear Parameters & Descriptions
An LLM is the ultimate literal user. It cannot infer your intent or guess what a vaguely named parameter means. Your tool's function signature and its description are its entire user manual.
- Be Explicit: Use descriptive parameter names (
file_path: String,query: String) instead of cryptic abbreviations (p: String,q: String). - Document Everything: The description passed to the agent must be comprehensive. Explain what the tool does, what each parameter is for, the expected format, and what it returns. The LLM uses this information to decide if and how to use your tool.
Example (data-oriented tool behind TemplateAgent):
Bad: fn analyze(p: String)
Good: fn process_csv(file_path: String)
Description: "Processes a CSV file located at the given file_path. It performs a full statistical analysis of the data, including column types, counts, averages, min/max for numeric columns, and value distributions for categorical columns. Returns a structured JSON object summarizing the analysis."
2. Consistent and Predictable Returns
Agents thrive on structure. A tool that returns a raw string one time and a JSON object another is a recipe for unpredictable behavior. Consistency is key.
- Standardize Your Output: Always return a predictable, structured format like JSON. A great pattern is to include a
statusfield (successorerror) and a correspondingdataorerror_messagefield. - Avoid Ambiguity: The agent shouldn't have to parse a human-readable string to figure out what happened. Give it clean, machine-readable data.
3. First-Class, Actionable Error Handling
When a tool fails, it's an opportunity for the agent to self-correct—but only if it knows why it failed.
- Don't Just Crash: Never let your tool panic or throw an unhandled exception. Catch errors gracefully.
- Provide Specificity: An error message of
"Error"is useless."Error: File not found at path /data/employees.csv"is actionable. The agent can now try a different path or ask the user for the correct location.
4. Context is King: Master Data Relevance
The LLM's context window is its most precious resource. A tool that dumps a gigabyte of raw data into it is committing a cardinal sin. The primary job of many tools is not just to fetch data, but to summarize and condense it.
This is the core function of a well-designed data tool: it does not dump the raw CSV into the model; it returns a compact, statistical summary unless the agent explicitly needs more.
Optional: SQL-oriented paths with DataFusion
For heavier tabular work, operators can attach the optional tableski MCP server (standalone project) so the agent issues SQL against registered files. The pattern is the same: small structured results back into TemplateAgent, not whole files into the prompt.
Example flow (illustrative):
- Agent: needs the average salary for Engineering.
- Tool call: run an aggregate over the dataset (via your CSV tool or MCP SQL tool).
- Tool response:
{"status": "success", "data": [{"avg_salary": 85000.0}]}
That keeps context usage bounded.
5. The Art of Verbalization
Sometimes, even a summary can be too large or complex. A sophisticated tool can offer to verbalize its findings, providing a natural language overview that guides the agent.
Example: Instead of returning a huge JSON summary, the tool could return:
{"status": "success", "verbal_summary": "Successfully analyzed the 10,000-row CSV. Key findings: The 'age' column has an average of 35.5. The 'department' column is dominated by 'Engineering' (65%).", "has_full_summary": true}
This gives the agent the highlights and lets it decide if it needs to request the full JSON for a deeper dive.
More Tips for World-Class Tools
Embrace the Single Responsibility Principle: A tool should do one thing and do it well. Don't create a
process_data_and_email_reporttool. Createprocess_dataandsend_email. This modularity gives the agent far more flexibility.Strive for Idempotency: Where possible, design tools so that calling them multiple times with the same input produces the same result without causing errors.
write_file(which overwrites) is idempotent;append_to_fileis not. Idempotent tools are more resilient to agent retries.Implement a
dry_runMode: For any tool with significant side effects (deleting files, writing to a database, spending money), include adry_run: boolparameter. This allows the agent to formulate a plan and verify its steps ("I will calldelete_fileon 'tmp.txt'") before committing to the action.Provide Progress Indicators: For long-running tasks (like analyzing a massive file), have your tool yield progress updates. This helps prevent timeouts and lets the user (or a supervising agent) know that work is still happening.
Conclusion
Building an AI agent is fundamentally an exercise in API design. The LLM is your user, and the tools are your API endpoints. By investing the time to create clear, consistent, efficient, and robust tools, you are not just improving a single function call; you are fundamentally increasing the intelligence, reliability, and capability of your entire agentic system. The next breakthrough in AI won't just come from a better model; it will come from better tools.