Framework Adapters
Gavrun ships adapters for LangChain, LangGraph, CrewAI, and OpenAI Agents SDK. When auto_patch=True (the default), configure() monkey-patches your framework automatically.
Auto-patch (recommended)
python
import gavrun
gavrun.configure(
api_key="gavrun_live_...",
agent_manager_url="https://api.gavrun.ai",
auto_patch=True, # default
)
# Every LangChain / LangGraph / CrewAI tool call is now governedManual patch
python
gavrun.configure(auto_patch=False)
from gavrun.adapters import patch_frameworks
patch_frameworks()LangChain / LangGraph
Auto-patch wraps BaseTool.invoke, BaseTool.run, and BaseChatModel.invoke. No code changes needed.
python
from langchain_core.tools import tool
@tool
def delete_order(order_id: str) -> str:
"""Delete an order."""
return db.delete(order_id)
# delete_order is now governed — calls preflight before executingUse LangChainPreflightRunnable for explicit control:
python
from gavrun.adapters import LangChainPreflightRunnable
guarded = LangChainPreflightRunnable(
client=gavrun.get_client(),
runnable=my_tool,
payload_factory=lambda input: client.guard_payload(
action="delete_order",
tools=["delete_order"],
prompt=f"Delete order {input}",
),
)
result = guarded.invoke(order_id)CrewAI
Auto-patch wraps BaseTool.run. No code changes needed.
For manual control use CrewAIPreflightTool:
python
from gavrun.adapters import CrewAIPreflightTool
guarded_tool = CrewAIPreflightTool(
client=gavrun.get_client(),
tool=my_crewai_tool,
payload_factory=lambda args: client.guard_payload(
action="web_search",
tools=["web_search"],
prompt=f"Search: {args}",
),
)OpenAI Agents SDK
Use OpenAIPreflightHooks as lifecycle hooks:
python
from gavrun.adapters import OpenAIPreflightHooks
from agents import Agent, Runner
hooks = OpenAIPreflightHooks(
client=gavrun.get_client(),
payload_factory=lambda tool_name: client.guard_payload(
action=tool_name,
tools=[tool_name],
prompt=f"Tool call: {tool_name}",
),
)
agent = Agent(name="my-agent", tools=[...])
result = await Runner.run(agent, input="...", hooks=hooks)