Skip to content

CrewAI

CrewAI

Zero-code: auto.connect()

pip install xybern
export XYBERN_API_KEY=xb_live_…
import xybern
xybern.auto.connect()                  # discovers and registers your CrewAI agents, observe mode
xybern.auto.connect(mode="enforce")    # authorises every tool call before it runs

The SDK instruments CrewAI directly (xybern doctor shows exactly what is enforceable). Nothing else in your code changes.

Explicit guard

For finer control, authorise inside the tool itself with the explicit client. authorize() returns a Decision: execute only on allowed, wait() holds an escalated action until a human decides in the dashboard, and raise_for_decision() raises PolicyBlocked / PolicyEscalated / SessionTerminated.

from crewai import Agent, Task, Crew
from crewai.tools import tool
from xybern import Xybern

xy = Xybern(agent_id="finance-agent")

@tool("send_email")
@xy.protected("email.send", context_from=lambda to, body: {"to": to, "recipient_external": not to.endswith("@company.com")})
def send_email(to: str, body: str) -> str:
    """Send an email."""
    return f"sent to {to}"

finance_agent = Agent(role="Financial Analyst", goal="Generate quarterly reports",
                      backstory="Expert in financial analysis", tools=[send_email])
crew = Crew(agents=[finance_agent], tasks=[Task(description="Send the Q4 report", agent=finance_agent, expected_output="confirmation")])
crew.kickoff()

The REST payload underneath is documented in the Quick Start: action_type plus optional action_content, metadata, agent_id; decisions come back lowercase as allow, block, escalate or terminate.