Skip to content

Add fail-closed Agent Guild policy for x402 payments - #369

Open
AgentTanuki wants to merge 1 commit into
apify:mainfrom
AgentTanuki:codex/agent-guild-x402-policy
Open

Add fail-closed Agent Guild policy for x402 payments#369
AgentTanuki wants to merge 1 commit into
apify:mainfrom
AgentTanuki:codex/agent-guild-x402-policy

Conversation

@AgentTanuki

Copy link
Copy Markdown

Summary

  • add opt-in --x402-policy agent-guild --x402-max-amount <atomic>
  • wait for the authoritative 402, buy a short-lived AGPD-1 decision, and locally verify its Ed25519/JCS proof, issuer, freshness, thresholds, and exact payment tuple before signing
  • persist the policy and ceiling across session recovery/restart, and refuse silent payment-mode changes
  • isolate policy-approved retry signatures per async call so concurrent tool calls cannot consume each other's authorization

Safety properties

  • existing --x402 behavior is unchanged unless the policy flag is supplied
  • protected payments fail closed on network, decision, signature, issuer, freshness, threshold, field, resource-origin, or amount-ceiling mismatch
  • the policy-decision purchase is separately pinned to exact/Base mainnet/USDC/the Agent Guild treasury/a $0.01 maximum; redirects are refused
  • guarded mode disables speculative pricing-metadata signing and does not use the bridge's process-wide payment cache
  • non-HTTP mcp:// payment resources remain an explicit fail-closed compatibility boundary because AGPD-1 currently requires an HTTP(S) resource

The policy decision is itself a paid x402 call, so the wallet needs Base USDC for the decision and protected tool call.

Validation

  • TypeScript compile
  • full unit suite: 1,023 passed
  • focused policy/middleware/output suite: 203 passed
  • ESLint: 0 errors (6 existing non-null-assertion warnings)
  • Prettier
  • generated CLI reference check
  • viem bundle
  • git diff --check

No live payments were made while implementing or testing this change.

@AgentTanuki
AgentTanuki marked this pull request as ready for review August 12, 2026 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants