Site search

Find architecture, research, and terms

Start typing to search the editorial index.

Production patternTechnical

Agents and Tool Execution

Typed tools, permission classes, approval gates, retries, rollback, connector boundaries, and MCP placement in a governed runtime.

A production agent should not move directly from model output to an unrestricted API call. MIR inserts validation, authorization, execution boundaries, observation, and evidence into the loop.

Key takeaways

  • Tools are security boundaries, not convenience callbacks.
  • Permission should describe the side effect, reversibility, scope, and required approval.
  • Retries are safe only when idempotency and partial-result behavior are known.
  1. Observe: read allowed state and tool availability.
  2. Plan: propose a bounded action.
  3. Validate: parse against the tool schema and policy.
  4. Act: execute with scoped credentials and resource limits.
  5. Record: emit results, artifacts, and policy decisions.
  6. Stop: complete, ask, pause, recover, or terminate.

Typed tool contracts

Conceptual tool contract
{
  "toolId": "repository.applyPatch",
  "version": "1.0",
  "permissionClass": "reversible-write",
  "inputSchema": { "type": "object", "required": ["patch"] },
  "sideEffects": ["repository-write"],
  "credentials": { "scope": ["repo:branch:write"], "ttlSeconds": 300 },
  "execution": {
    "timeoutSeconds": 60,
    "idempotency": "required",
    "checkpoint": "before-side-effect",
    "rollback": "delete-branch"
  },
  "policy": { "requiredApprovals": ["merge", "deploy"] },
  "evidence": ["validated-input", "diff", "result", "errors"]
}

A tool contract should describe inputs, outputs, side effects, reversibility, idempotency, timeout, data classes, credential scope, egress, approval policy, and evidence requirements. Natural-language descriptions alone are insufficient for enforcement.

Permission classes

Class Example Default control
Read-only Read repository metadata Scoped source allowlist and logging
Draft Prepare an email without sending Artifact review before external effect
Reversible write Create a branch or update a staging record Checkpoint and rollback or compensation
Irreversible write Send funds, delete data, publish externally Independent approval and strong authentication

Retries, circuit breakers, rollback, and compensation

  • Retry only operations declared idempotent or protected by an idempotency key.
  • Use circuit breakers to stop repeated calls to a degraded dependency.
  • Create a checkpoint before material side effects.
  • Prefer direct rollback when supported; otherwise execute a documented compensating action.
  • Escalate when the runtime cannot establish whether a side effect completed.

Connector trust boundaries

Tool output can contain untrusted instructions as well as data. The runtime should preserve provenance, distinguish data from control, minimize credentials, validate returned types, and enforce outbound network policy. MCP standardizes a connection surface, but it does not replace authorization, consent, tool review, or runtime policy. Source: MCP specification Source: OWASP guidance

Source record

References

Suggest a correction
  1. Model Context Protocol project. Model Context Protocol. Published 2025-11-25; last reviewed 2026-06-24 UTC. Protocol specification.

  2. OWASP Agentic Security Initiative. OWASP. Published Current guidance; last reviewed 2026-06-20 UTC. Security guidance.

  3. OWASP GenAI Security Project. OWASP. Published 2025; last reviewed 2026-06-20 UTC. Security guidance.

  4. National Institute of Standards and Technology. NIST. Published 2023-01-26; last reviewed 2026-06-20 UTC. Government framework.