Revolution Builds

Agents

Design Safe Agent Tool Execution With Clear Boundaries

Give an AI agent useful capabilities while keeping authorization, validation, retries, and human escalation in deterministic application code.

Written by Shivam Dubey. Published 2026-08-25. Updated 2026-08-25.

A model chooses intent; code grants capability

An agent can suggest a tool call, but it should not decide whether the call is allowed. Put authorization, tenant boundaries, input validation, rate limits, and idempotency in application code. The model provides a proposal inside a constrained interface.

Keep tool definitions narrow. A tool named update_customer_address is easier to validate than a generic database tool. Specific capabilities reduce the chance that a vague request turns into an irreversible action. They also make audit logs easier to read.

Make the tool contract explicit

Every tool needs a typed input shape, a typed result, a timeout, and predictable errors. Validate the model output before execution and return a safe error object rather than an unhandled exception. A model should never need raw credentials, internal connection strings, or unrestricted query access.

Separate planning from action for sensitive operations. The agent may draft a change and show a human what it intends to do. A deterministic approval step can then execute the change with the same validated payload. This makes the boundary visible to both the user and the engineer.

Design for partial failure

Tool calls fail because APIs time out, permissions change, records are missing, and upstream systems behave unexpectedly. Define which failures can retry, how many times, and when the agent should stop. A retry without an idempotency strategy can create duplicate side effects.

Return enough information for the next step to make a safe decision: status, error category, retryability, and a user-safe message. Avoid asking the model to infer whether an opaque stack trace means it should try again.

Observe the workflow as a sequence

Log the user request reference, prompt or graph version, tool selected, validated arguments, authorization outcome, latency, and result category. Do not log sensitive content indiscriminately. The objective is an audit trail that lets a team reconstruct a decision without creating a new privacy problem.

Review traces by failure mode. Tool selection can be correct while the input is invalid; retrieval can be good while the final action is denied. Separating those stages makes evaluation and incident response practical.

Start with a narrow, reversible workflow

The first release should solve one well-defined task with a small tool registry. Prefer read operations, drafts, or reversible updates before broad write access. Add capability only when evaluation shows the existing boundary is reliable and understandable.

A safe agent is not one that never refuses. It is one that can explain its limits, request missing information, and escalate when automation would be irresponsible.

Checklist

  • Authorization and policy checks run outside the model.
  • Tool inputs and outputs are typed and validated.
  • Sensitive actions have an approval boundary.
  • Retries have timeout and idempotency rules.
  • Traces record safe, useful decision context.

Use the Prompt Test Matrix