Skip to content

AutoGen

Install

pip install scopebound

Integration

from scopebound import ScopeboundSDK
from scopebound.adapters.autogen import enforce_autogen

sb = ScopeboundSDK()

@enforce_autogen(sb, role="invoice-processor")
def read_invoices(status: str = "pending") -> str:
    return get_invoices(status)

Deny example

On deny, enforce_autogen returns a structured error dict instead of raising — AutoGen agents can handle this as a tool result:

result = read_invoices(status="pending")
if isinstance(result, dict) and result.get("error"):
    print(result["deny_code"])  # SCOPE_VIOLATION

Session management

from scopebound.adapters.autogen import AutoGenSession

with AutoGenSession(sb, roles={"researcher": "read-only-analyst"}) as session:
    # Session is provisioned on entry, revoked on exit
    pass