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
{{ message }}
Repository navigation
Example: CrewAI pre-pay check of an x402 endpoint - #4
Adds examples/crewai-prepay-check/: a CrewAI custom tool that runs npx -y @agent402-dev/pay-server check <url> --json and hands the JSON report (fixes, findings, prices) to the agent. The agent's instructions say it must not pay when fixes > 0 — and it has no wallet and no payment tool at all, it only checks and reports. Non-https URLs are refused before the check starts; http is allowed on loopback, the same carve-out the CLI itself makes, so the local test server works.
Files:
tool.py — the CrewAI custom tool.
main.py — one agent, one task: check the URL from the command line, report price, fixes and verdict.
local_broken402.py — a ~20-line server answering a broken 402, for the will-not-pay case.
README.md — install, run, what the tool returns.
requirements.txt — pinned versions.
How I ran it (Python 3.12.3, crewai 1.15.50, Node v24.22.1, @agent402-dev/pay-server 0.15.0 via npx):
Tool against the live endpoint https://agent402-tx-receipts.agent402-ebc.workers.dev/x402/receipts → fixes: 0, price findings "Solana mainnet, 0.05 USDC" and "Base, 0.05 USDC", signedOrPaid: false.
Tool against the local broken-402 server (http://127.0.0.1:8402/paid) → fixes: 1 (header_undecodable).
Tool against http://example.com/paid → refused before the check was started.
Full agent runs completed with a locally served model (Qwen2.5-3B-Instruct via Ollama, CREWAI_MODEL=ollama/qwen2.5-3b-q4): the live-endpoint run printed the price (0.05 USDC) with fixes: 0 and a payable verdict; the broken-402 run printed the agent refusing to pay (fixes: 1). Full outputs are in the follow-up comment on this PR.
One implementation note: the tool runs npx from a neutral temp directory. Inside an npm workspaces repo (like this one), npx would otherwise resolve @agent402-dev/pay-server to the local workspace package instead of the published one.
PAYMENT-REQUIRED is not base64 JSON that @x402/core can decode.
Given that fixes is greater than 0, the endpoint must not be paid. The payment cannot be processed due to the undecodable header.
Both runs exited 0. Nothing was signed or paid in either.
This branch has not been deployed
No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
/claim #2
Adds
examples/crewai-prepay-check/: a CrewAI custom tool that runsnpx -y @agent402-dev/pay-server check <url> --jsonand hands the JSON report (fixes,findings, prices) to the agent. The agent's instructions say it must not pay whenfixes > 0— and it has no wallet and no payment tool at all, it only checks and reports. Non-https URLs are refused before the check starts; http is allowed on loopback, the same carve-out the CLI itself makes, so the local test server works.Files:
tool.py— the CrewAI custom tool.main.py— one agent, one task: check the URL from the command line, report price, fixes and verdict.local_broken402.py— a ~20-line server answering a broken 402, for the will-not-pay case.README.md— install, run, what the tool returns.requirements.txt— pinned versions.How I ran it (Python 3.12.3, crewai 1.15.50, Node v24.22.1,
@agent402-dev/pay-server0.15.0 via npx):https://agent402-tx-receipts.agent402-ebc.workers.dev/x402/receipts→fixes: 0, price findings "Solana mainnet, 0.05 USDC" and "Base, 0.05 USDC",signedOrPaid: false.http://127.0.0.1:8402/paid) →fixes: 1(header_undecodable).http://example.com/paid→ refused before the check was started.CREWAI_MODEL=ollama/qwen2.5-3b-q4): the live-endpoint run printed the price (0.05 USDC) withfixes: 0and a payable verdict; the broken-402 run printed the agent refusing to pay (fixes: 1). Full outputs are in the follow-up comment on this PR.One implementation note: the tool runs
npxfrom a neutral temp directory. Inside an npm workspaces repo (like this one),npxwould otherwise resolve@agent402-dev/pay-serverto the local workspace package instead of the published one.