A model-generated tool call is a request for an action, not authorization to perform it. The application must validate the arguments, verify the current user’s permissions, and decide whether that action is allowed in the current state. This separation is essential when tools can read private data or change external systems.
Keep tools narrow
Expose task-sized functions with strict schemas. Prefer
get_invoice_status(id)Set limits for tool count, wall-clock time, response size, and model retries. Detect repeated calls with the same arguments and stop loops that make no progress. For risky actions—payments, deletion, account changes—require a confirmation step or human approval. Preserve the actor and tool-call audit trail without logging secrets or unnecessary personal data.
Handle uncertainty honestly
A tool can time out or return stale data. Tell the model whether the result is partial, and make the user-facing response distinguish verified facts from a suggestion. If the model refuses or returns malformed arguments, fail closed and offer a recovery path.
Evaluate with a fixed set of representative tasks, including adversarial instructions in retrieved documents, invalid arguments, permission failures, and tool outages. Record success, unsafe-action attempts, latency, and cost by workflow. A production agent is a controlled application workflow with a model in the loop; adding tools alone does not make it reliable.
Keep the boundary between the model and the account
A strict tool schema helps application code understand what the model proposes. In JSON Schema, properties alone does not require their presence, so use required for fields the executor needs. additionalProperties set to false can reject unexpected keys at that object boundary. Field validation still leaves a business question for the server, such as whether a tool should be allowed to read a specific invoice for this account. JSON Schema object validation
Build a local evaluation around four concrete request paths. Use a valid invoice ID belonging to the caller, a valid one belonging to a different account, a malformed ID, and a provider timeout. Assert that the tool is called only for the valid, authorized request. Check that the caller gets a useful error or review path for the rest. A confidence number should influence only a step with a separately evaluated model policy. The example uses a threshold to illustrate routing, and it needs validation on labeled cases before an application uses it.
Worked example
This is an application-owned policy example, not a calibrated production threshold. Tool outputs must satisfy authorization and schema checks before their confidence is considered.
tstype Route = "answer" | "human-review"; function chooseRoute(input: { verified: boolean; confidence: number }): Route { return input.verified && input.confidence >= 0.95 ? "answer" : "human-review"; }




Community
Discussion
Loading comments…