You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(challenge): emit compatible_clients in 402 agent_instructions
Mirror the node-commerce gain — add a `compatible_clients` field to the 402 body
via build_agent_instructions, derived per-rail from how_to_pay. Same default
client list, same shape, same vendor-override pattern via
BuildAgentInstructionsInput(compatible_clients={...}).
CLAUDE.md gets the symmetric documentation section + structural alignment with
node-commerce/CLAUDE.md (Examples table + peer-dep paragraph + "Every helper lifts
from production code" mantra at the top, matching node-commerce).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|`examples/`| Runnable single-file FastAPI apps for each common scenario |
28
31
|`tests/`| pytest, one file per surface |
29
32
30
-
Every helper lifts from working production code (`agentscore/martin-estate`) — extract from real consumers, not speculation.
33
+
Peer-dep pattern: payment/x402/mppx/stripe modules import lazily at runtime — vendors install only what they use via extras (`pip install agentscore-commerce[fastapi,stripe]` etc.). Underlying packages: `x402[evm,svm]`, `pympp[server,tempo,stripe]`, `stripe`. Missing peer dep raises a guiding `ImportError` with the install command.
34
+
35
+
## Examples
36
+
37
+
`examples/` contains full single-file FastAPI apps for the most common merchant scenarios — copy-paste templates, not frameworks:
38
+
39
+
| Example | Scenario |
40
+
|---|---|
41
+
|`api_provider.py`| Per-call API billing on multiple rails: Tempo MPP + x402 (Base + Solana); no compliance gate |
42
+
|`identity_only.py`| Compliance gate without payment (vendor handles their own) |
43
+
|`multi_rail_merchant.py`| Full agent-commerce: identity + Tempo MPP + x402 + Stripe SPT |
|`variable_cost_merchant.py`| Pay-per-actual-usage on **two protocols**: x402 upto (Permit2 + Settlement-Overrides) AND MPP tempo session (channel + SSE + mid-stream vouchers) |
46
+
|`compliance_merchant.py`| Regulated-goods merchant — full compliance gate + custom `on_denied` composing the denial helpers (`verification_agent_instructions`, `is_fixable_denial`, `build_signer_mismatch_body`, `build_contact_support_next_steps`, `denial_reason_to_body`/`denial_reason_status`) |
31
47
32
48
## Identity model
33
49
@@ -62,6 +78,10 @@ async def purchase(...): ...
62
78
63
79
Anonymous POST flows through to the handler unauthenticated and gets a 402 with all rails + per-order pricing. Identity is verified at settle time on the retry leg (when the agent submits `X-Payment` / `Authorization: Payment`); `create_session_on_missing` still auto-mints a verification session there. The same wrap pattern works identically across all 6 framework adapters (fastapi, flask, django, aiohttp, sanic, middleware/ASGI). See `examples/multi_rail_merchant.py` and `examples/compliance_merchant.py`.
64
80
81
+
### `compatible_clients` field on emitted 402s
82
+
83
+
`build_agent_instructions` emits a `compatible_clients` field in the 402 body, derived automatically from `how_to_pay` — per-rail list of CLIs the AgentScore team has smoke-verified end-to-end. Vendors override with `BuildAgentInstructionsInput(compatible_clients={...})` to add their own tested clients. Set to an empty dict `{}` to suppress the default. Same data is published as `core/docs/integrations/x402-clients.mdx` for human-side rationale + per-rail commands.
0 commit comments