Skip to content

CrewAI Integration

ShadowAudit wraps CrewAI tools with a runtime gate. The wrapped tool is used in place of the original wherever it would appear in a crew or task definition.

Installation

pip install "shadowaudit[crewai]"

Wrapping a CrewAI tool

from shadowaudit import ShadowAuditTool
from crewai_tools import FileReadTool

safe_file = ShadowAuditTool(
    tool=FileReadTool(),
    agent_id="research-agent",
    capability="filesystem.read",
    policy_path="policies/research.yaml"
)

Using with a crew

from crewai import Agent, Task, Crew

researcher = Agent(
    role="Researcher",
    goal="Gather information from files",
    tools=[safe_file]
)

task = Task(
    description="Read and summarize /data/report.pdf",
    agent=researcher
)

crew = Crew(agents=[researcher], tasks=[task])
crew.kickoff()

Wrapping custom tools

from crewai.tools import BaseTool
from shadowaudit import ShadowAuditTool

class MyDatabaseTool(BaseTool):
    name: str = "database_query"
    description: str = "Query the production database"

    def _run(self, query: str) -> str:
        # database logic
        ...

safe_db = ShadowAuditTool(
    tool=MyDatabaseTool(),
    agent_id="db-agent",
    capability="database.read",
    policy_path="policies/database.yaml"
)

Policy example for CrewAI

# policies/research.yaml
deny:
  - capability: filesystem.write
  - capability: filesystem.delete

allow:
  - capability: filesystem.read
  - capability: web.search
  - capability: web.fetch

Scanning for ungated tools

shadowaudit check ./src --framework crewai