AutoGen
AutoGen¶
Zero-code: auto.connect()¶
import xybern
xybern.auto.connect() # discovers and registers your AutoGen agents, observe mode
xybern.auto.connect(mode="enforce") # authorises every tool call before it runs
The SDK instruments AutoGen 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 autogen import AssistantAgent, UserProxyAgent
from xybern import Xybern
xy = Xybern(agent_id="report-agent")
@xy.protected("write_file", context_from=lambda path, content: {"path": path})
def write_file(path: str, content: str) -> str:
open(path, "w").write(content)
return f"wrote {path}"
assistant = AssistantAgent("assistant", llm_config={"model": "gpt-4o"})
user = UserProxyAgent("user", human_input_mode="NEVER")
user.register_for_execution(name="write_file")(write_file)
assistant.register_for_llm(name="write_file", description="Write a file")(write_file)
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.