Add AgentTollSafetyTool: honeypot/rug checks for a Base token via x402 - #7226
Add AgentTollSafetyTool: honeypot/rug checks for a Base token via x402#7226tevfikefeaydin wants to merge 1 commit into
Conversation
AgentToll (https://agenttoll.app) exposes onchain Base data as pay-per-call HTTP endpoints, settled inline in USDC via x402 -- no API key, no subscription. This wraps its /api/base/safety endpoint (simulated buy and sell, taxes, owner privileges, holder concentration, deployer history) as a BaseTool: lazy import with an actionable ImportError, EVM_PRIVATE_KEY declared via env_vars, errors returned as strings rather than raised. Adds the `x402` optional-dependencies extra (x402[requests,evm]) and unit tests that mock the network layer (no real HTTP calls). Verified locally against this exact checkout (Python 3.12, isolated venv, not the shared workspace uv.lock): - pytest lib/crewai-tools/tests/tools/agenttoll_safety_tool_test.py -- 3 passed - ruff check / ruff format --check -- clean, aside from one BLE001 (blind `except Exception`) that also exists today in arxiv_paper_tool.py's _run, the same error-as-string idiom - mypy -- clean - full `import crewai_tools; crewai_tools.AgentTollSafetyTool` works - the exact x402 API used (x402ClientSync, x402_requests, register_exact_evm_client, EthAccountSigner) was verified against the package's own example in x402-foundation/x402, not just its docs Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Thanks for the pull request. First-time contributors need an associated open issue before we can review a PR.
See the contributing guide. |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughChangesAgentToll safety checks
Sequence Diagram(s)sequenceDiagram
participant Caller
participant AgentTollSafetyTool
participant x402RequestsSession
participant AgentTollAPI
Caller->>AgentTollSafetyTool: run(address)
AgentTollSafetyTool->>x402RequestsSession: create paid session with EVM_PRIVATE_KEY
AgentTollSafetyTool->>x402RequestsSession: GET /api/base/safety/{address}
x402RequestsSession->>AgentTollAPI: paid safety request
AgentTollAPI-->>x402RequestsSession: safety response
x402RequestsSession-->>AgentTollSafetyTool: response text
AgentTollSafetyTool-->>Caller: verdict or error string
Suggested reviewers: ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Adds
AgentTollSafetyTool, wrapping AgentToll's/api/base/safetyendpoint: a simulated buy and sell, buy/sell tax, owner privileges, holder concentration, liquidity risk, and the deployer's own history for a Base (chain id 8453) token contract.AgentToll is a live, open-source (MIT), pay-per-call API settled in USDC on Base via the x402 protocol (HTTP 402) — no API key, no subscription, no signup. This gives CrewAI agents a real safety verdict on an unfamiliar Base token without any onboarding step, paid only on a successful response.
lib/crewai-tools/src/crewai_tools/tools/agenttoll_safety_tool/(agenttoll_safety_tool.py+README.md)env_varsdeclaresEVM_PRIVATE_KEY; lazily importsx402in__init__with an actionableImportErrorif the extra isn't installed_runand returned as a string rather than raised (matchesarxiv_paper_tool.py's_run)x402 = ["x402[requests,evm]>=2.21.0"]inlib/crewai-tools/pyproject.toml__all__) increwai_tools/tools/__init__.pyandcrewai_tools/__init__.pyTest plan
Verified against this exact checkout, Python 3.12, an isolated venv (not the shared workspace
uv.lock— didn't want to touch a file shared by the whole monorepo for one new optional extra):pytest lib/crewai-tools/tests/tools/agenttoll_safety_tool_test.py -vv— 3 passed (env-var requirement, a mocked happy path, error-returned-not-raised; no real network calls)ruff check/ruff format --checkon the new/changed files — clean, aside from oneBLE001(blindexcept Exceptionin_run) that also exists today inarxiv_paper_tool.py's_run, using the same error-as-string patternmypy— cleanimport crewai_tools; crewai_tools.AgentTollSafetyTool— resolves through the full packagex402Python API used (x402ClientSync,x402_requests,register_exact_evm_client,EthAccountSigner) was verified by installingx402[requests,evm]and exercising it against the package's own example inx402-foundation/x402, not just its docs