Skip to content
Duoduo Mediaevidence to decision

Package 33 · Section 11.4

Governed Tool Execution

Allow an agent to read from and act on business systems without unauthorized calls, duplicate side effects or unverified success.

Track
I · Agentic decision systems
Level
Advanced
Version
v1.0
Status
In validation · catalog only
Explanation depthDepth

Learning objectives

  • Write tool contracts with schemas, permissions, side-effect class, idempotency, failure policy and audit.
  • Execute side-effecting calls exactly once with stable idempotency keys and confirmation.
  • Design compensation and manual recovery for actions that partially fail.

In brief

Tools are how an agent touches the world. Every tool needs a contract that states purpose, input and output schemas, permissions, side-effect class, idempotency, failure policy and audit. Side-effecting calls execute exactly once, are confirmed against the authoritative system and are always recorded.

Core concepts

33.1The tool contract

A tool has a specific purpose; broad tools such as "run arbitrary command" are excluded. Inputs carry types, allowed values, units and business validation. Outputs carry status, evidence, errors and authoritative identifiers.

Permissions are scoped by principal, tenant, role, resource and action. Side effects are classified as read-only, reversible, compensatable or irreversible.

33.2Safe execution

Governed execution validates arguments, authorizes the principal, checks policy, requires signed approval for irreversible or high-impact calls, derives a stable idempotency key, returns a previously confirmed result if one exists, executes, validates the output, confirms by authoritative ID and records everything.

A timeout is not a failure signal. The external system may have committed, so recovery confirms by idempotency key before any retry.

33.3Compensation

When a multi-step action partially fails, compensatable steps are undone in reverse order. Irreversible steps need a manual recovery path defined before they are allowed at all.

Worked example

Retrying a purchase order after a timeout

Situation: The RFQ API times out after 30 seconds. The agent wants to retry.

  1. 1The idempotency key was derived from case ID, step ID and call fingerprint before the first attempt.
  2. 2Recovery queries the action store and the supplier system by that key.
  3. 3The supplier system reports the RFQ was created; the result is validated and recorded as confirmed.
  4. 4No second call is made.

Outcome: Exactly one RFQ exists and the audit log shows the timeout, the confirmation lookup and the final state.

Decision rules

  • Default to least privilege and typed outputs.
  • Never retry a side-effecting call before checking the idempotency record.
  • Never infer success from a fluent tool response; confirm by authoritative ID.
  • High-impact calls require approval bound to the exact call fingerprint.

Common pitfalls

  • Giving the agent a broad service credential.
  • Retrying writes on timeout.
  • Trusting the model summary of a tool result instead of the structured output.

Key vocabulary

Idempotency
Repeated execution with the same key does not create duplicate side effects.
Side-effect class
Read-only, reversible, compensatable or irreversible.
Compensation
A defined action that reverses the effect of an earlier step.
Circuit breaker
A control that stops calls to a failing tool or provider until it recovers.

Tutorial outline

  1. 33.1The tool contract and why broad tools such as 'run arbitrary command' are excluded.
  2. 33.2Safe execution: validate, authorize, check policy, require approval, deduplicate, execute, validate output, confirm, record.
  3. 33.3Read-only, reversible, compensatable and irreversible side effects.

Required artifacts

Tool contract registry, adversarial test suite and audit log.

Evaluation evidence

Selection accuracy, argument validity, confirmation rate, unauthorized-call rate and duplicate side-effect rate.