Skip to main content
Treat model-generated tool arguments as untrusted input.

Safety checklist

  • Keep tool schemas minimal and explicit.
  • Validate parsed arguments before execution.
  • Allowlist tool names; reject unknown tools.
  • Add timeouts and retries for external calls.
  • Log call id, tool name, and validation failures.

Request validation example (TypeScript + Zod)

Failure strategy

If validation fails:
  1. Do not execute the tool.
  2. Return a controlled error payload into the next model turn.
  3. Ask the model to retry with corrected arguments.

Streaming note

Streaming tool calls depend on model and provider support. Accumulate all argument deltas before parsing, validating, or executing a call. See Streaming.
Last modified on October 18, 2026