keepcalculator

06 Numbers and Powers

AI Coding Agents: Test Their Tool Use

Card No. 06·17103 · Updated · Standard formula, shown below

This guide helps you evaluate whether an AI coding agent genuinely knows how to use its tools—like file editors, terminal commands, and search—rather than just generating plausible text. You’ll learn a practical, repeatable test you can run in a few minutes, plus what to look for in the agent’s behavior.

What You’ll Need

  • A working installation of the AI coding agent you want to test (CLI, IDE extension, or web interface).
  • A small, disposable project folder with a couple of simple files (e.g., a Python script and a text file).
  • Basic familiarity with the agent’s interface—how to send a prompt and read its output.
  • Permission to run commands in your terminal (for the terminal-based tests).

Step-by-Step

  1. Create a minimal test project. Make a folder with two files: data.txt containing three lines of text (e.g., “apple�, “banana�, “cherry�), and script.py containing a simple function that reads data.txt and prints each line. This gives the agent concrete, verifiable things to do.
  2. Ask it to read a file and summarize. Prompt: “Read data.txt and tell me what fruits are listed.� A capable agent will open the file with its file-reading tool and report the exact contents. A weak one might guess or hallucinate the contents. Check that its answer matches the file exactly.
  3. Ask it to modify a file. Prompt: “Add a line with ‘date’ to data.txt.� Then inspect the file yourself. Did it actually append the line, or did it just show you the code it would use? A real tool user changes the file on disk.
  4. Ask it to run a command. Prompt: “Run script.py and show me the output.� The agent should invoke its terminal tool, execute the Python script, and return the actual output. If it claims to have run it but gives output that doesn’t match what you see when you run it yourself, that’s a red flag.
  5. Ask it to find something. Prompt: “Search the project for the word ‘banana’ and tell me which file contains it.� A good agent will use its search or grep tool. A poor one might just say “it’s in data.txt� without actually searching—verify by checking its reasoning or tool calls.
  6. Give it a multi-step task. Prompt: “Create a new file called output.txt, write the first line of data.txt into it, then run script.py and append its output to output.txt.� This tests sequencing and dependency handling. After it finishes, inspect output.txt to confirm each step was actually performed.
  7. Introduce an error. Rename data.txt to data_backup.txt, then ask the agent to “run script.py.� A competent agent will notice the file is missing, report the error, and perhaps suggest a fix. A weak one might pretend it ran successfully or invent a different error.
  8. Ask it to undo a change. After it has modified a file, prompt: “Undo the last change you made to data.txt.� See if it can revert the file to its previous state. This tests whether it tracks its own actions and can use version control or file history tools.
  9. Check its tool call history. Most agents show you the tool calls they make. Review the log: did it actually call read_file, write_file, run_command, or search? Or did it just output text claiming to have done things? The log is the most direct evidence.
  10. Repeat with a slightly different prompt. Ask the same task in different wording, e.g., “What’s in data.txt?� vs. “Read the file data.txt and list its contents.� Consistency across phrasings suggests the agent understands the tools, not just memorized responses.

Common Mistakes

  • Trusting the agent’s summary. The agent may describe what it would do rather than actually doing it. Always verify the filesystem and command output yourself.
  • Testing only one tool. A model might be great at file editing but terrible at running commands. Test all the tools you care about: file read, file write, terminal, search.
  • Ignoring the tool call log. The log is the ground truth. If the log shows no tool calls but the agent claims to have done something, it’s likely hallucinating.
  • Using a too-simple test. Asking “what is 2+2?â€� doesn’t test tool use at all. Use tasks that require the agent to interact with its environment.
  • Not checking error handling. A tool that works only when everything is perfect is not reliable. Introduce a missing file or a syntax error to see how it copes.

Tips

  • Start small. The first tests should be single-step and unambiguous. Build up to multi-step tasks only after the basics pass.
  • Watch the reasoning. Good agents explain what they’re doing and why. If the agent’s reasoning doesn’t match its tool calls, something is off.
  • Use a clean environment. Run tests in a disposable folder so you don’t accidentally break real work.
  • Time the response. If the agent claims to have run a command but responds instantly, it probably didn’t actually execute anything.
  • Compare with a known-good agent. If you have access to a second agent that you trust, run the same test on both and compare behavior.
  • Test with real-world tasks. Once the basic tests pass, try a task from your actual workflow, like “refactor this function and run the tests.â€�

Troubleshooting

  • The agent says it can’t access files. Check your permissions and the agent’s configuration. Some agents need explicit approval to access the filesystem or run commands. Make sure you’ve granted the necessary permissions.
  • The agent’s tool calls fail with “permission denied.â€� This usually means the agent’s process lacks the right OS permissions. Run the agent from a directory you own, or adjust its configuration to allow the needed operations.
  • The agent produces output that doesn’t match the file contents. This suggests the agent is not actually reading the file, or it’s reading a cached version. Try asking it to re-read the file, or restart the agent session.
  • The agent runs commands but the output is empty or wrong. The command might be failing silently. Ask the agent to show you the full command and its exit code. You can also run the command yourself to see the expected output.
  • The agent gets stuck in a loop. It might keep trying the same failing tool call. Interrupt the session, simplify the task, and try again with clearer instructions.
  • The agent refuses to run a command. Some agents have safety policies that block certain commands. Try rephrasing the task, or check the agent’s documentation for allowed commands.

Frequently Asked Questions

How long does this test take?

About 10–15 minutes if you have the test project ready. The individual steps are quick; the main time cost is reviewing the agent’s tool call logs and verifying the results.

Can I test an agent without a terminal?

Yes. If the agent runs in an IDE or web interface, you can still test file reading, editing, and search. Skip the terminal-specific steps and focus on the file operations.

What if the agent passes all the basic tests?

It means the agent can use its tools for simple, well-defined tasks. That’s a good sign, but it doesn’t guarantee performance on complex, ambiguous real-world codebases. Test with a task from your own project next.

Is it possible for an agent to fake tool use?

Yes. Some models will output text that looks like a tool call without actually invoking it. The tool call log is the only reliable way to tell. If the log shows no calls but the agent claims to have done something, treat it as fake.

Why does my agent pass the tests sometimes but fail other times?

AI agents are probabilistic. They may succeed on a task one day and fail the next, especially with slightly different phrasing. Run the tests a few times with varied wording to get a sense of reliability.

Do these tests work for all AI coding agents?

The general principles apply to any agent that claims to have file and command tools. The exact tool names and interfaces will differ, but the test logic—verify the agent actually changes the filesystem and runs commands—is universal.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →