Repository navigation
examples: CrewAI agent checks an x402 endpoint before paying - #12
Open
riccardocens-code wants to merge 1 commit into
Open
riccardocens-code wants to merge 1 commit into
riccardocens-code wants to merge 1 commit into
Conversation
|
👀 We've notified the reward creators here. |
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 runnable CrewAI example that checks an x402 endpoint before anything pays it.What it does
tool.py:Check402Tool, a CrewAIBaseToolthat runsnpx -y @agent402-dev/pay-server@0.15.0 check <url> --jsonand returns the CLI's JSON (url,fixes,findingswith thepricefindings,signedOrPaid) to the agent. One request without a payment header; nothing signed or paid, no key read.localhost/127.0.0.1so the local test server can be checked.npxruns from the temp dir, not the example dir, so inside this repo it doesn't resolve the unbuilt workspace@agent402-dev/pay-server(that fails withagent402-pay-server: not found).main.py: the agent and task. The instructions say: do not pay whenfixes > 0. The model is set withMODEL(defaultgemini/gemini-3.5-flash-lite).broken_402_server.py: a 20-line stdlib server that answers 402 with aPAYMENT-REQUIREDheader that is not base64 JSON.test_tool.py: unit test (no LLM key, no npx) showing refused URLs never start the CLI.requirements.txtpinscrewai[google-genai]==1.15.50andgoogle-genai==1.65.0.Run by me (crewai 1.15.50, google-genai 1.65.0, model
gemini/gemini-3.5-flash-lite, Python 3.12.16, Node 24.22.1, npm 11.21.1, pay-server 0.15.0):Live endpoint:
python main.py "https://agent402-check402.agent402-ebc.workers.dev/x402/check402?url=https://example.com"Local broken 402:
python broken_402_server.py & python main.py http://127.0.0.1:4021/paidNon-https:
python main.py http://example.com/paid→ the tool refuses without starting the CLI, and the agent answers "decision: will not pay".python -m unittest test_tool.py→ 2 tests OK.No payment code, rules, keys, wallets or signing are touched; the change is only the new example folder.