How do I test a tool call without spending much on API calls?
Testing with mocked responses
Write a fake model response that contains a tool request with sample arguments. Feed it into your handler and check that the function runs, validates inputs and returns the right shape. This catches most bugs without any API cost.
Also test bad inputs. Send missing fields, wrong types and unexpected values to confirm your code rejects them safely instead of crashing. Mocked tests also run quickly, which keeps your development loop short.
Saving real calls for final checks
Once the handler works, run a short set of real prompts that cover normal and edge cases. Use a small, inexpensive model for early checks when the provider offers one. Record the tool requests the model produces so you can compare them over time. Keep the number of paid test calls small and planned.
Keep a set of expected outcomes in version control. When you change a description, rerun the same prompts to see whether the model still chooses the right tool.
- Mock model responses for handler tests.
- Test invalid and missing arguments.
- Run a small set of real prompts for final checks.
- Save logs to compare after each change.
Common mistakes
- Running full test suites against a paid model on every code change.
- Skipping edge-case tests because the happy path works.
