Per-user auth, policy & audit for CrewAI tools
pip install acp-crewai, wrap each tool with @governed, and bind the end user’s JWT on each request. Every CrewAI tool call is then checked against your workspace policy for that user before it runs, and written to an audit log under that user’s name.
CrewAI is a Python framework for multi-agent systems. A typical CrewAI deployment shares one backend API key across every end user’s request. There is no per-user policy, no per-user audit trail, and no way to tell a downstream system which human triggered which action.
acp-crewai fills that gap. Before a wrapped tool runs, ACP decides allow, deny or redact from your workspace policy, the end user’s identity, rate limits and PII detection. It uses the same /govern/tool-use endpoint and the same workspace policies as Claude Code. Two differences: an ask comes back to the model as a denied tool call (approve it on the console, then re-run), and the safety floor for shell commands only applies to tools that carry a shell command.
5-minute install.
pip install acp-crewai, wrap tools with@governed, bind the end user’s JWT per request, and optionally callinstall_crew_hooks(crew)to audit handoffs between agents. See how a call is decided for the concepts every framework shares, or the frameworks index for other options.
Install
pip install acp-crewai
A minimal crew under policy
from crewai import Agent, Crew, Task
from crewai.tools import tool
from fastapi import FastAPI, Header
from acp_crewai import governed, install_crew_hooks, set_context
app = FastAPI()
# Define tools however you want. Stack @governed under @tool so the
# check runs inside CrewAI's tool dispatch.
@tool("web_search")
@governed("web_search")
def web_search(query: str) -> str:
"""Search the web."""
return my_search(query) # your code, your credentials
@tool("send_email")
@governed("send_email")
def send_email(to: str, subject: str, body: str) -> str:
"""Send an email on behalf of the user."""
return sendmail(to, subject, body)
@app.post("/run")
def run(topic: str, authorization: str = Header(...)):
# Bind the end user's JWT to this request's context.
set_context(user_token=authorization.removeprefix("Bearer ").strip())
researcher = Agent(role="researcher", goal=f"Research {topic}",
tools=[web_search, send_email])
task = Task(description=f"Research {topic} and email me a summary.",
agent=researcher)
crew = Crew(agents=[researcher], tasks=[task])
# Capture handoffs between agents too (sequential task passes,
# coworker delegation) as synthetic Agent.Handoff audit events.
install_crew_hooks(crew)
return {"result": str(crew.kickoff())}
What happens on every tool call
@governedPOSTs{ tool_name, tool_input, session_id }andAuthorization: Bearer <user-jwt>to ACP’s/govern/tool-use.- ACP checks workspace policy, the user’s scopes, rate limits and PII.
- Deny or ask: the wrapped function returns
"tool_error: <reason>". CrewAI treats that as the tool’s output, so the model sees the reason and adapts. Anaskis not shown as a prompt. It arrives as a block, you approve it on the console Approvals page or from the approval email, and then the call is retried. - Allow: your tool runs.
- After the tool returns, ACP scans the output for PII. If policy says
redact, the redacted version replaces the tool’s output. An audit row is written under the end user’s identity.
Handoffs between agents
CrewAI has two delegation paths that never cross a tool boundary, so @governed alone doesn’t see them:
- Sequential task handoffs. Task N’s output feeds Task N+1’s context.
- Hierarchical delegation. CrewAI’s built-in “Delegate work to coworker” and “Ask question to coworker” tools.
install_crew_hooks(crew) attaches task_callback and step_callback, so each message between agents becomes a synthetic Agent.Handoff audit event. PII scanning applies to them. Callbacks you already set are chained, not overwritten.
If the gateway is down
If /govern/tool-use times out (5 seconds by default) or can’t be reached, the tool runs and the decision is logged as fail-open. That keeps the check from becoming a single point of failure for your agent. Raise the timeout with configure(timeout_s=10) if latency is the cause.
Set up your ACP workspace
Before the crew can call tools, your workspace needs three things:
- An identity provider. ACP verifies the end user’s JWT against your IdP (Firebase, Auth0, any OIDC). Dashboard, Settings, Identity Provider.
- Tools listed. The names in
@governed("...")must match tools enabled in your workspace. Dashboard, Policies, Tools. - Policy per tier. Set allow or deny, rate limits and PII mode for each agent tier. Dashboard, Policies.
If you are the end user (a single-user test), logging in to cloud.agenticcontrolplane.com with Firebase gives you a valid JWT.
What shows up in the dashboard
Every checked call, tool or handoff, appears in cloud.agenticcontrolplane.com/activity with:
- Actor: the end user’s sub, not your service account
- Tool name: whatever you passed to
@governed(...) - Decision: allow, deny or redact, with the reason
- Session: groups all tool calls from one request
- Findings: PII detected in input or output, if any
CrewAI calls sit next to Claude Code and Cursor calls from the same user, in one audit log.
Add or replace tools
from crewai.tools import tool
from acp_crewai import governed
@tool("my_tool")
@governed("my_tool")
def my_tool(arg: str) -> str:
"""Description the LLM sees."""
# your code: your API, your credentials
return "..."
@governed must sit closer to the function than @tool, so the policy check runs inside CrewAI’s tool dispatch. Tools outside this pattern are not checked.
What this adds to CrewAI
CrewAI handles workflow: agents, tasks and crew composition. CrewAI also offers its own task guardrails and tracing, and its Enterprise plan adds workspace features. Check CrewAI’s docs for what your plan includes. acp-crewai adds the following on top:
- A policy check on each tool call before it runs
- Rate limits and budgets per end user
- PII detection on tool input and output
- An audit trail per human, across every tool call
- One audit log shared with your other agents (Claude Code, Cursor and so on)
Use CrewAI for what it does and add acp-crewai where you need per-user control of tools.
Price and meter the model calls
@governed covers what your agent does. A second piece, the proxy, covers what it spends. Both talk to the same gateway, and init() sets up the proxy side:
import acp_governance as acp
acp.init() # call before you construct any model client
Model calls then land on the same trail as tool calls, with cost, tokens and cache data. If you build model clients yourself, pass the config instead of calling init():
from acp_governance import model_client_kwargs
from anthropic import Anthropic
client = Anthropic(**model_client_kwargs("anthropic"))
The shapes are "anthropic", "openai" (chat completions) and "openai-responses". The last two are not interchangeable: /v1 serves chat completions and /openai/v1 serves responses.
init() handles each provider all or nothing. It sets the base URL and the key, or it leaves that provider alone and tells you which one it skipped. If OPENAI_BASE_URL already points at your own gateway, ACP won’t reroute you.
Your coverage: tool calls checked (decorated tools), model calls metered (proxy).
Limitations
- Only tools wrapped in
@governedare covered. A plain Python function used as a CrewAI tool without the decorator is invisible to ACP. This is on purpose: you choose what gets checked. But it means a missed decorator is a missed check. - The two pieces are set up separately. The decorator covers tool calls and the proxy covers model calls. See Price and meter the model calls. Decorating tools without repointing the model client gives you checks with no cost data.
- Pre-release.
acp-crewai@0.1.xis the first release line. Pin exact versions.
Troubleshooting
The crew runs but nothing appears in the dashboard. Confirm the end user’s JWT is sent as Authorization: Bearer ... and that ACP has your IdP configured for its issuer. Check the workspace dropdown on the Activity page.
401 from /govern/tool-use. The JWT is invalid, expired, or signed by an IdP ACP doesn’t trust. Check Settings, Identity Provider in the dashboard.
Decisions always show allow with reason fail-open. The gateway request is failing. Check that api.agenticcontrolplane.com is reachable from your runtime, and raise the timeout with configure(timeout_s=10) if latency is the cause.
Policy says deny, but the tool still runs. Check that the tool is wrapped with @governed, not only @tool, and that @governed is the one closer to the function.