Skip to content

Add AgentTollSafetyTool: honeypot/rug checks for a Base token via x402 - #7226

Closed
tevfikefeaydin wants to merge 1 commit into
crewAIInc:mainfrom
tevfikefeaydin:add-agenttoll-safety-tool
Closed

Add AgentTollSafetyTool: honeypot/rug checks for a Base token via x402#7226
tevfikefeaydin wants to merge 1 commit into
crewAIInc:mainfrom
tevfikefeaydin:add-agenttoll-safety-tool

Conversation

@tevfikefeaydin

@tevfikefeaydin tevfikefeaydin commented Sep 2, 2026

Copy link
Copy Markdown

Summary

Adds AgentTollSafetyTool, wrapping AgentToll's /api/base/safety endpoint: 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.

  • New folder: lib/crewai-tools/src/crewai_tools/tools/agenttoll_safety_tool/ (agenttoll_safety_tool.py + README.md)
  • env_vars declares EVM_PRIVATE_KEY; lazily imports x402 in __init__ with an actionable ImportError if the extra isn't installed
  • Errors are caught in _run and returned as a string rather than raised (matches arxiv_paper_tool.py's _run)
  • New optional-dependencies extra: x402 = ["x402[requests,evm]>=2.21.0"] in lib/crewai-tools/pyproject.toml
  • Registered (import + __all__) in crewai_tools/tools/__init__.py and crewai_tools/__init__.py

Test 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 --check on the new/changed files — clean, aside from one BLE001 (blind except Exception in _run) that also exists today in arxiv_paper_tool.py's _run, using the same error-as-string pattern
  • mypy — clean
  • import crewai_tools; crewai_tools.AgentTollSafetyTool — resolves through the full package
  • The exact x402 Python API used (x402ClientSync, x402_requests, register_exact_evm_client, EthAccountSigner) was verified by installing x402[requests,evm] and exercising it against the package's own example in x402-foundation/x402, not just its docs

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>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Thanks for the pull request.

First-time contributors need an associated open issue before we can review a PR.

  1. Open an issue with a template, or pick an existing open one.
  2. Open a new PR (or reopen this one) whose title or body mentions that issue, for example #123.

See the contributing guide.

@github-actions github-actions Bot closed this Sep 2, 2026
@coderabbitai

coderabbitai Bot commented Sep 2, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: bbc24df6-54a3-4624-b955-2054ca2ff1ab

📥 Commits

Reviewing files that changed from the base of the PR and between 3d72c70 and 8d2ff51.

📒 Files selected for processing (6)
  • lib/crewai-tools/pyproject.toml
  • lib/crewai-tools/src/crewai_tools/__init__.py
  • lib/crewai-tools/src/crewai_tools/tools/__init__.py
  • lib/crewai-tools/src/crewai_tools/tools/agenttoll_safety_tool/README.md
  • lib/crewai-tools/src/crewai_tools/tools/agenttoll_safety_tool/agenttoll_safety_tool.py
  • lib/crewai-tools/tests/tools/agenttoll_safety_tool_test.py

📝 Walkthrough

Walkthrough

Changes

AgentToll safety checks

Layer / File(s) Summary
Tool contract and package wiring
lib/crewai-tools/pyproject.toml, lib/crewai-tools/src/crewai_tools/__init__.py, lib/crewai-tools/src/crewai_tools/tools/__init__.py, lib/crewai-tools/src/crewai_tools/tools/agenttoll_safety_tool/agenttoll_safety_tool.py
Adds the AgentTollSafetyToolInput schema, tool metadata, x402 optional dependency, and public exports.
Paid safety request flow
lib/crewai-tools/src/crewai_tools/tools/agenttoll_safety_tool/agenttoll_safety_tool.py
Validates x402 and EVM_PRIVATE_KEY, creates a paid session, calls the AgentToll Base safety endpoint, and returns response text or an error string.
Validation and usage documentation
lib/crewai-tools/tests/tools/agenttoll_safety_tool_test.py, lib/crewai-tools/src/crewai_tools/tools/agenttoll_safety_tool/README.md
Tests missing credentials, successful verdicts, and session errors. Documents setup, usage, payment, testing, and verdict categories.

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
Loading

Suggested reviewers: lorenzejay

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant