Framework integration

CrewAI

Wrap a CrewAI Agent after assigning its local BaseTools and before the Crew begins execution.

Before you begin: create an API key with agent:register, policy:sync and decision:create, then set QUASENTRA_API_KEY and QUASENTRA_URL.

1. Install

pip install 'quasentra[crewai]'

2. Create local tools

Keep each business capability as a named, typed tool. Underscores in tool names become dots in policy actions.

from crewai.tools import tool

@tool("customer_lookup")
def customer_lookup(customer_id: str) -> str:
    """Read one customer record."""
    return company_database[customer_id]

@tool("customer_delete")
def customer_delete(customer_id: str) -> str:
    """Permanently delete one customer."""
    del company_database[customer_id]
    return "deleted"

3. Secure the agent

import os
from crewai import Agent, Crew, Task
from quasentra import Quasentra

security = Quasentra(api_key=os.environ["QUASENTRA_API_KEY"], base_url=os.environ["QUASENTRA_URL"])
agent = Agent(
    role="Support", goal="Resolve requests safely",
    backstory="Company support specialist",
    tools=[customer_lookup, customer_delete],
)
agent = security.crewai(
    agent_id="support-agent", agent=agent,
    permissions={"customer.lookup": "ALLOW", "customer.delete": "DENY"},
)
task = Task(description="Look up CUST-100", expected_output="Customer status", agent=agent)
result = Crew(agents=[agent], tasks=[task]).kickoff()
print(result)
security.close()

4. Confirm enforcement

  1. Start the application once.
  2. Open Dashboard → Agents and confirm the agent and tools were discovered.
  3. Open Policies and confirm every action has the intended effect.
  4. Request an allowed action and confirm the implementation runs.
  5. Request a denied action and confirm it appears in Decisions but never reaches the implementation.

Runtime guarantees

  • Agent and tool metadata sync idempotently at construction/startup.
  • Newly discovered tools receive default-DENY.
  • A denied or approval-required tool implementation does not execute.
  • Authorization transport exhaustion fails closed.

Security boundary

The adapter intercepts local CrewAI BaseTool objects. External execution paths require gateway enforcement.

Do not keep another unwrapped path to sensitive functions. For high-impact tools, move credentials and execution into the trusted gateway.