Rightshold™ Sign up

Answers · agent safety

How do I build a full agent audit trail tied to the grant, spend cap, and revocation state at each action?

Last updated

TL;DR: A useful agent audit trail is more than a chat export. For every consequential action, record what ran and the authority snapshot at that moment: which grant (or approval) covered it, which spend cap and remaining budget applied, and whether the credential was unrevoked. Sequence-aware detectors such as Cisco Project Quarry show why order matters — reading credentials then calling an external host is a different finding than either step alone — but detection alone is not a trail unless you persist the grant, cap, and revocation fields beside each event. Keep the trail append-only and outside the agent's editable session; pair set_spend_policy and authorize_spend for money paths, request_human_approval for risky steps, check_revocation before dispatch, and record_ai_run when you need a signed run receipt.

What should I check, step by step?

1. Define the event schema once: action id, time, actor (agent + optional human principal), tool/server, argument hash, outcome, grant_id, policy_version, spend_cap snapshot (per_tx / daily / remaining), revocation_status, and prev_hash for chaining.

  1. On every risky call, load the live grant and spend policy first. Refuse if expired, out of scope, over cap, or revoked — then still write a denied row so the trail shows refusals, not only successes.
  2. For payments and purchases: set_spend_policy on the credential, call authorize_spend (or your issuer's real-time auth) with amount and merchant, and store the allow/deny receipt id on the trail row.
  3. For high-impact non-pay actions: request_human_approval with a hashed action object; verify_human_approval again immediately before the side effect; link approval_id on the same row.
  4. Call check_revocation (credential id, key id, or fingerprint) at dispatch; after an incident use revoke_agent / revoke_agent_credential and confirm later rows show revoked.
  5. Prefer sequence-aware review (tool order across the session), as Quarry-style rules do, on top of per-call rows — single-call allowlists miss "read secrets then exfiltrate" patterns.
  6. Store the trail where the agent cannot UPDATE it (server DB, ledger, SIEM). Keep only ids in session memory.
  7. Retain the full grant's trail after revocation for your compliance window; do not delete history when you kill access.

What "full trail" means for agents

Activity logs answer what the system reported. A full trail also answers what the agent was allowed to do when it acted: grant scope, spend ceiling, and revocation bit at that timestamp.

Wire grant, cap, and revoke into every row

set_spend_policy records per_tx_max_minor, daily_max_minor, allowed domains/categories, and optional expiry on a credential; authorize_spend returns a signed allow/deny against that policy (records only — it never moves money).

What can go wrong?

Trail has tool names but no grant_id or remaining budget, so an auditor cannot tell a $5 allow from a policy that had already been exhausted.

How do I ask Rightshold about this (free, no key)?

Add the MCP server https://www.rightshold.com/mcp to Claude, Cursor, ChatGPT, Grok or VS Code, then ask: “Set a spend policy on this agent credential and show me how to authorize each purchase against it so every allow or deny can sit on our audit trail.”

One-click setup

{
  "tool": "set_spend_policy",
  "arguments": {
    "credential_id": "crd_…",
    "currency": "USD",
    "per_tx_max_minor": 2500,
    "daily_max_minor": 10000,
    "allowed_domains": [
      "api.vendor.example"
    ],
    "allowed_categories": [
      "saas"
    ],
    "expires_at": "2026-11-07T03:00:00Z"
  }
}

Rightshold records spend policies, spend authorizations, human approvals, revocation checks and AI-run receipts for agents that call it. It does not replace your SIEM, run Project Quarry for you, move money, or stop an agent that never asks. Enforce the trail schema and fail-closed checks in your gateway and runners too. Not legal advice.

What are the sources?

Related

Not legal advice. JSON · Markdown · All answers

Get a free API key in one call

No card and no email needed. 100 free credits; the license and policy checks stay free without a key.

curl -s -X POST https://www.rightshold.com/v1/accounts/signup -H "Content-Type: application/json" -d '{"accept_terms":true}'
export RIGHTSHOLD_API_KEY=rs_...   # the api_key from the reply (shown once)
curl -s https://www.rightshold.com/v1/licenses/check -H "Authorization: Bearer $RIGHTSHOLD_API_KEY" \
  -H "Content-Type: application/json" -d '{"license":"MIT","intended_use":{"commercial_use":true}}'