Skip to content

feat(agentkit): add x402Guard action provider for pre-payment trust checks - #1510

Open
enclave402 wants to merge 1 commit into
coinbase:mainfrom
enclave402:feat/x402-guard-action-provider
Open

enclave402 wants to merge 1 commit into
coinbase:mainfrom
enclave402:feat/x402-guard-action-provider

Conversation

@enclave402

Copy link
Copy Markdown

PR: feat(agentkit): add x402Guard action provider for pre-payment trust checks

Target repo: coinbase/agentkit
Target path: typescript/agentkit/src/action-providers/x402Guard/
Closes: #1476


Summary

Adds a new x402Guard action provider that checks whether an x402 seller is safe to pay before the agent sends money. This directly answers #1476 ("How do you handle an unreliable or bad-actor agent today?").

The provider queries a live census oracle that continuously probes every x402 endpoint listed on the Coinbase Bazaar (currently 8,848 endpoints across ~2,000 hosts) and returns a signed verdict:

  • pay (37%) — compliant, real buyer activity
  • caution (30%) — partial compliance
  • avoid (33%) — do not pay

Each verdict is cryptographically signed (EIP-712) so a router or auditor can verify it without trusting the gateway.

Actions

Action Description
check_seller_verdict Takes a URL, returns verdict + score + latency + attestation
get_census_leaderboard Returns top 100 sellers by trust score (free, no payment required)

Usage

import { x402GuardActionProvider } from "@coinbase/agentkit";

const agent = new AgentKit({
  actionProviders: [
    x402GuardActionProvider(),      // trust checks
    x402ActionProvider(),           // payments
  ],
});

The agent calls check_seller_verdict before any x402_http_request. If the verdict is avoid, the agent skips payment. Zero additional dependencies — uses global fetch only.

How it answers #1476

"When an agent built with AgentKit turns out to be unreliable or a bad actor, how do you handle that today?"

Today: nothing. The existing x402 action provider pays any endpoint that returns a 402, with no pre-payment check. This provider adds a census-backed trust layer between "agent wants to pay" and "agent actually pays."

Data source: enclave402.com/census — MIT-licensed, cryptographically signed, continuously updated.
npm package: @enclave402/x402-guard (standalone fetch interceptor, zero deps)

Test plan

  • Unit tests for checkSellerVerdict with mocked responses (pay, caution, avoid, 402, unknown)
  • Unit tests for getCensusLeaderboard with mocked census response
  • Integration test: live call to https://enclave402.com/census returns valid JSON with assessed > 0
  • Verify supportsNetwork returns true for all networks (census is chain-agnostic)

…hecks

Adds a new x402Guard action provider that checks whether an x402 seller
is safe to pay before the agent sends money. Closes coinbase#1476.

- check_seller_verdict: takes a URL, returns verdict + score + attestation
- get_census_leaderboard: returns top 100 sellers by trust score (free)

Each verdict is EIP-712 signed by the census attestor for offline verification.
Live census: 8,848 endpoints across ~2,000 hosts.
@cb-heimdall

Copy link
Copy Markdown

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/2
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 1
Sum 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants