CrewAI
Wrap a CrewAI tool (or a plain function) with guard(kelhe, tool). It returns a
BaseTool to hand to your agent; the guard runs on CrewAI's before_tool_call
hook, right before the real tool executes.
from kelhe import Kelhe, Mode
from kelhe.adapters.crewai import guard
from crewai import Agent
from crewai.tools import tool
kelhe = Kelhe(mode=Mode.ENFORCE, risk_threshold=7.0)
@tool("issue_refund")
def issue_refund(amount: int, customer: str) -> str:
"Issue a refund to a customer."
return f"refunded ${amount} to {customer}"
agent = Agent(
role="billing assistant",
goal="process approved customer refunds",
backstory="You handle refunds carefully.",
tools=[guard(kelhe, issue_refund)],
)
Scope is by tool name — guarding a name guards every call CrewAI addresses
to it, which matches how CrewAI dispatches tools. You can also pass a plain
function and guard() turns it into a CrewAI tool for you.