Skip to content

Agent-side x402 client: detect 402 → policy check → pay → retry #208

Description

@hellno

Standalone; sequenced after #34 (x402 phase 2) and the build-shape spike. The $5/day recipe consumes this.

Why: this is the hands of the paying agent — it turns "402 Payment Required" into a policy-checked purchase without the agent ever touching a key.

Scope

The agent-side HTTP wrapper (transport is deliberately agent-side per the #32/#34 decision — the daemon signs, it never speaks HTTP):

  1. Perform the request; on 402 parse the payment requirements (v2 PAYMENT-REQUIRED header, v1 JSON-body fallback).
  2. Ask the daemon to authorize + sign via x402 phase 2: exact/EIP-3009 payments on the Ethereum reference path, fully local demo loop #34's wire; the daemon's policy/budget decision happens here.
  3. Retry with PAYMENT-SIGNATURE (v2) / X-PAYMENT (v1); surface the receipt/response to the agent.

Shape: lean toward a deckard_fetch_paid MCP tool (keeps the pay loop visible in deckard_status and Activity) over a bare CLI helper — decide in-issue.

Invariants:

Tests

Acceptance

An agent (Claude over MCP) fetches a paid resource end-to-end on the local fixture stack, with the payment visible in Activity; DoD green.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions