LlamaIndex
LlamaIndex¶
Zero-code: auto.connect()¶
import xybern
xybern.auto.connect() # discovers and registers your LlamaIndex agents, observe mode
xybern.auto.connect(mode="enforce") # authorises every tool call before it runs
The SDK instruments LlamaIndex 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 llama_index.core.tools import FunctionTool
from xybern import Xybern
xy = Xybern(agent_id="research-agent")
@xy.protected("web.fetch", context_from=lambda url: {"url": url, "external": True})
def fetch_url(url: str) -> str:
"""Fetch a web page."""
return http_get(url)
tool = FunctionTool.from_defaults(fn=fetch_url)
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.