Developer guide
Wrap your agent, wherever it runs. Aegis does not care what framework it is built on or whose cloud it sits in.
Hand the whole thing to a coding agent
One self-contained Markdown file covering the platform, the SDK, the boundary rules, the audit vocabulary and the failure modes — written to be pasted into Claude Code, Cursor or any coding agent and used as the integration spec. Your API base is filled in before download.
Integration diagnostics
Checks what Aegis actually believes about your agents — not what your .env says.
1. Install
pip install infocion-aegis
You can tell them apart from your own code: this SDK exposes guard, aegis_session and context_from_env. If what you have exposes MetricsReporter or AuditLog, it is not this package, which is why nothing is reaching this console. Reinstall by the exact name above.
2. Point it at your agent's identity
Go to Agents → your agent → Access → Agent keys → Create key. The key is displayed once, at creation, and cannot be retrieved afterwards — if you lose it, revoke it and mint another. Then put it in the environment wherever the agent runs. No VPN and no inbound ports are required; the SDK makes outbound calls only.
export AEGIS_API_BASE=https://aegis.example.com/api/aegis export AEGIS_AGENT_KEY=agk_a1b2c3d4_... # from Access → Agent keys # Declares whether this agent's egress is restricted by the network. # There is no default: 'governed' on a machine with open egress refuses # to start, and 'development' shows as "Network not locked down". export AEGIS_ENFORCEMENT=development # or 'governed' — see below
The governed client-zone bundle also supplies its durable local-audit connection and control-plane service token. Use that bundle for a pilot instead of copying those deployment-only values into an agent project.
A governed deployment runs the agent inside a network whose egress is restricted, so the only route out is through the gateway. The SDK verifies this at startup and refuses to run if it is false. Use the client-zone bundle in deploy/client-zone/ for a pilot; development mode is for building and testing.
3. Add three lines to the agent
import aegis_sdk aegis_sdk.init() # identity, config, audit and session, from the environment tools = aegis_sdk.govern(tools) # your existing tools, unedited # ...build and run your agent exactly as before, using these tools.
govern accepts a list or dict of functions, a module, or LangChain tool objects, and returns the same shape. The first time the agent starts, each tool's name appears on its page under Tools. Pick the connector and scope for each there; no code change and no restart is needed, because the binding arrives with the signed config. Until a tool is bound, calling it is blocked and logged.
Using an agent framework
govern also takes CrewAI, Microsoft Agent Framework, Google ADK and Claude Agent SDK tool objects. Add the framework's hook as well: it refuses, and logs, any tool call that did not go through Aegis, such as the framework's own built-in tools or a tool added later.
from aegis_sdk import frameworks
# LangChain / LangGraph: put the backstop last among middleware
agent = create_agent(model, tools, middleware=[..., frameworks.langchain_middleware()])
# CrewAI: run governed crews with cache=False (a cached result skips the guard)
register_before_tool_call_hook(frameworks.crewai_before_tool_call)
# Microsoft Agent Framework
agent = Agent(..., middleware=[..., frameworks.agent_framework_middleware()])
# Google ADK
agent = LlmAgent(..., before_tool_callback=frameworks.adk_before_tool_callback)
# Claude Agent SDK: name the server that holds the governed tools
hooks = {"PreToolUse": [HookMatcher(hooks=[frameworks.claude_pre_tool_use("aegis", tools)])]}
# OpenAI Agents SDK: govern the function, then make the tool
tool = function_tool(aegis_sdk.govern(lookup_trial))- Credentials
- A tool that declares an aegis_cred keyword argument receives a short-lived credential for its connector. Other tools are governed without a secret being issued.
- Approvals
- If this agent's guardrails require approval, a tool bound at a scope that changes something (anything other than read) opens one request in the review app and raises ApprovalRequired. Calling it again once a reviewer has signed proceeds, and uses that approval up: one approval, one action. Pass approval_wait=900 to block for the decision instead.
- Servers
- A server handling many jobs calls aegis_sdk.init(session=False) once and wraps each job in with aegis_sdk.run():, so every job gets its own session, token budget and row on the Sessions tab.
- Policy gaps
- If the SDK recognises an identifier your DLP field list does not name, it redacts it anyway and records phi.policy_gap with the field names, so an upgrade never stops an agent. Add the named fields to the list.
- Threads
- init() makes the context visible to every thread in the process, so framework worker pools need no extra wrapping. A process governs one agent; one that serves several agents or tenants should use aegis_session(ctx) per run instead.
- Client zone
- Pass aegis_sdk.init(audit=PostgresAuditSink()) so the detail row is written locally and only an opaque pointer reaches this console.
Prefer the binding in code?
The explicit form is still supported and behaves identically at call time.
from uuid import uuid4
from aegis_sdk import guard
from aegis_sdk.guard import aegis_session
from aegis_sdk.platform import context_from_env
ctx = context_from_env(session_id=str(uuid4()))
@guard(tool_name="query_trials", connector="hospital-ctms", scope="read")
def query_trials(condition: str, *, aegis_ctx=None, aegis_cred=None) -> list[dict]:
return ctms_client.search(condition=condition, token=aegis_cred.secret)
with aegis_session(ctx):
result = query_trials("type 2 diabetes")