CrewAI Adapter¶
Monitor tool calls in CrewAI agents using the @monitored_tool decorator.
Install¶
Usage¶
Replace @tool with @monitored_tool:
from toolwitness.adapters.crewai import monitored_tool
@monitored_tool
def get_weather(city: str) -> str:
"""Get current weather for a city."""
return '{"city": "Miami", "temp_f": 72, "condition": "sunny"}'
# Use with CrewAI agents normally
output = get_weather(city="Miami")
# Verify the agent's response
results = get_weather.toolwitness.verify("Miami is 72°F and sunny.")
How it works¶
The @monitored_tool decorator:
- Wraps the function the same way CrewAI's
@tooldoes - Before execution: records the tool call and arguments
- After execution: records the return value and generates an HMAC-signed receipt
- Attaches a
.toolwitnessattribute for verification access
Your CrewAI agents use the tool exactly as before — the monitoring is transparent.
With storage persistence¶
from toolwitness.adapters.crewai import CrewAIMonitor, monitored_tool
from toolwitness.storage.sqlite import SQLiteStorage
monitor = CrewAIMonitor(storage=SQLiteStorage())
@monitored_tool
def get_weather(city: str) -> str:
"""Get current weather for a city."""
return '{"city": "Miami", "temp_f": 72}'
Options¶
| Parameter | Type | Default | Description |
|---|---|---|---|
storage |
SQLiteStorage |
None |
Persist results for CLI and dashboard |
session_id |
str |
auto-generated | Custom session identifier |
Next¶
- Getting Started — basic usage and CLI
- How It Works — verification engine details