New Tool Radar

AI Agents & Automation

How to Check an Agent Tool Call Arguments Before the Tool Runs

Validate an agent tool call arguments against the tool schema before the tool runs, so bad arguments fail early.

Schematic with three steps: Write the schema the check will use; Check arguments at dispatch, before execution; Test with the known bad call.

Most tool failures are not tool failures: the model called the right tool with the wrong arguments, a missing field, or a value of the wrong type. The fix is to check the arguments against the tool’s schema before the tool executes, and send the error back to the model as an observation so it can correct the call. The ReAct pattern links each tool result back to its call by tool_call_id, so a validation error lands on the exact call that caused it. Add the check once, in the dispatch step, rather than inside every tool.

What you need

  • A tool with a written schema: its argument names, types and required fields
  • One example of a bad call the agent has made before
  • Access to the run log to see tool calls and their arguments

Step 1: Write the schema the check will use

List each argument with its type and whether it is required. Keep the list next to the tool definition so the two cannot drift apart.

Step 2: Check arguments at dispatch, before execution

In the loop that dispatches tool calls, validate the arguments against the schema before running the tool. On failure, return the error as the tool observation so the model can retry with corrected arguments.

Step 3: Test with the known bad call

Replay the known bad call and confirm it is caught by the check instead of running the tool. Then confirm a good call still passes through unchanged.

Worked example: synthetic argument check

The table below is a synthetic example. It shows the expected result of argument validation; no agent was run.

Call Arguments valid? Tool ran?
lookup_order(order_id=A123) Yes Yes
lookup_order(order_id missing) No No – error returned
lookup_order(order_id=123, wrong type) No No – error returned
Corrected retry after error Yes Yes

Expected result (UNTESTED). the two bad calls are caught before the tool runs, the error goes back to the model, and the corrected retry succeeds. This check was not run live; the table shows the expected result for the synthetic example.

Limits

  • Validation checks shape, not meaning: a well-formed but wrong order id still passes.
  • The schema and the tool must stay in sync, or the check rejects good calls.
  • Returning the error as an observation only helps if the model reads it and corrects the call.
  • A tool with no schema cannot be validated this way; write the schema first.

Sources

See all