Skip to main content
Version: v0 (preview)

OpenAI Agents

Wrap any function tool with guard(kelhe, func). It returns a normal FunctionTool, so the agent uses it exactly as before.

from kelhe import Kelhe, Mode
from kelhe.adapters.openai_agents import guard
from agents import Agent, Runner

kelhe = Kelhe(mode=Mode.ENFORCE, risk_threshold=7.0)

def issue_refund(amount: int, customer: str) -> str:
"Issue a refund to a customer."
return f"refunded ${amount} to {customer}"

agent = Agent(
name="billing",
instructions="process approved customer refunds",
tools=[guard(kelhe, issue_refund)],
)

Runner.run_sync(agent, "Refund the duplicate $20 charge for cust_42")

The adapter captures the tool name, arguments, the agent's live instructions, and recent conversation, and sends them to the engine to score. guard() also accepts name= and description= to override what the model sees.