Aegis — AI Agent Governance

io.github.Acacian由 GitHub 帳號 Acacian 發布v0.1.7更新於 Oct 28, 2026

Policy-based governance for AI agent tool calls. YAML policy, approval gates, audit logging.

概覽

AI 產生的概覽

Aegis 是本地治理層,可包裝 MCP 伺服器與 AI 代理框架,執行 YAML 政策、攔截提示注入、遮蔽 PII 並保留防竄改稽核日誌。

可以做什麼
  • 以 stdio 或 HTTP 代理任意 MCP 伺服器,對其工具呼叫套用政策、參數清理與稽核
  • 攔截或警示提示注入、PII、提示洩漏、有害內容及 MCP STDIO 注入
  • 依宣告式 YAML 規則把符合的動作判定為自動放行、需核准或封鎖
  • 將每次呼叫寫入 Merkle 鏈式稽核日誌,支援 SQLite、JSONL 與 webhook 輸出
  • 掃描程式碼中未受治理的 AI 呼叫,並在上線前測試或比對政策變更
適用情境
當代理或助理呼叫的工具需要核准關卡、內容護欄或稽核紀錄時適用;也適合在不改動現有 MCP 伺服器程式碼的前提下,為它加上一層政策管控。
執行需求
以本機 Python 程序執行,從 agent-aegis 的 PyPI 套件安裝,使用代理功能需安裝 mcp 附加元件。需透過 AEGIS_POLICY_PATH 環境變數提供 YAML 政策檔。僅限桌面用戶端,未宣告身分驗證。
安裝前請注意
代理位於每次工具呼叫的路徑上,可阻擋呼叫或改寫參數,政策設定錯誤可能讓原本可用的工具失效。稽核輸出與 webhook 會把呼叫紀錄傳送到所設定的目的地。護欄為確定性正規表達式檢查,並非完整的安全邊界。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Aegis — AI Agent Governance,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

Agent-Aegis

The governance layer for AI agents. One API, 12 frameworks, every governance primitive.

Aegis is to agent governance what Redis is to data structures — one runtime that unifies prompt-injection blocking, PII masking, policy enforcement, trust delegation, and tamper-evident audit across every agent framework. No code changes.
pip install agent-aegis → aegis.auto_instrument() → 12 frameworks are now governed.

[OpenSSF Best Practices] [CI] [PyPI] [Python] [License]
[Tests] [Coverage] [Playground]

What is Aegis • Primitives • Frameworks • Use Cases • 30-Second Start • Research • Docs • Playground

English • 한국어


[Aegis Demo]


What is Aegis

Every AI agent framework reinvents the same governance primitives — and each one does it slightly differently. Aegis is the abstraction layer that unifies them.

LayerWhat it doesExamples
1. PrimitivesA universal contract for every tool callAction, ActionClaim, Policy, Result, DelegationChain, AuditEvent
2. AdaptersAuto-instrument any framework through its own hooksLangChain callbacks, CrewAI BeforeToolCallHook, OpenAI Agents tracing, Google ADK BasePlugin, MCP transport, DSPy modules, httpx middleware, Playwright context
3. GovernanceDeclarative primitives you compose into policyPrompt injection / PII / leak / toxicity guardrails, RBAC, rate limit, cost budget, drift detection, anomaly scoring, trust delegation, justification gap, selection audit, Merkle audit chain
4. LifecycleOne runtime, every stage of agent opsScan → Instrument → Policy CI/CD → Runtime → Proxy → Audit
python
import aegisaegis.auto_instrument()    # 12 frameworks governed. No other code changes.

You don't write a LangChain guardrail and a CrewAI guardrail and an OpenAI guardrail — you write one Policy and every framework inherits it.

How this differs from the guardrail libraries

They solve a different problem, and mostly a text-shaped one. Guardrails AI validates model output against a hub of validators; NeMo Guardrails scripts conversational and tool policy in the Colang DSL; Snyk Agent Scan — Invariant Labs' mcp-scan, since the Snyk acquisition — scans MCP servers and agent skills for known risk patterns and can proxy them at runtime; LLM Guard chained input/output scanners until it was archived in July 2026. Each one you wire in yourself, at a call site you choose. Aegis starts from the other end: auto_instrument() finds the frameworks already installed and instruments them in place, so one Policy covers all of them without a line of agent code changing. What it enforces is agent-shaped rather than prompt-shaped — delegation chains under a monotone trust constraint, audits of what an agent excluded rather than what it picked, the distance between an agent's declared intent and its measured impact, and a tamper-evident audit chain. All of it is deterministic, so there is no second model sitting in the request path. These are not exclusive choices: a semantic or model-based detector drops into GuardrailEngine.add() alongside the built-ins.


Primitives

The contract every adapter maps into. Framework-agnostic by design.

PrimitivePurposeModule
ActionUnified representation of any tool / LLM / HTTP / MCP call across all frameworksaegis.core.action
ActionClaimTripartite structure — Declared (agent-authored) / Assessed (Aegis-computed) / Chain (delegation)aegis.core.action_claim
PolicyDeclarative YAML rules: match → risk → approval (auto / approve / block)aegis.core.policy
ClaimPolicyPolicy layer that evaluates 6-dimensional impact vectors, not just tool namesaegis.core.claim_policy
GuardrailsDeterministic regex checks for injection, PII, prompt leak, toxicity — 2.65ms cold / <1µs warmaegis.guardrails
DelegationChainMulti-agent hand-off tracking with monotone trust constraint (non-increasing)aegis.core.agent_identity
AuditEventTamper-evident append-only log, Merkle-chained, SQLite + JSONL + webhook sinksaegis.core.merkle_audit
SelectionAuditAudits what an agent excludes, not just what it picks — detects cosmetic alignmentaegis.core.selection_audit
JustificationGap6D asymmetric scoring: agents declare impact, Aegis independently assesses, gap triggers escalationaegis.core.justification_gap
CryptoAuditChainEd25519-signed chain for long-term compliance evidenceaegis.core.crypto_audit

Every governance feature in Aegis — anomaly detection, cost budgets, drift, cascade guards, kill switches — is a composition of these primitives. Read the Concepts guide to see how they fit together.


Frameworks

One API. 12 agent frameworks + 3 protocol-level adapters.

FrameworkHookIntegration
Google ADKBasePlugin lifecycle (tool calls, agent routing, sessions)Native — the patch only installs the plugin
CrewAIglobal BeforeToolCallHook, Crew.kickoff/kickoff_asyncHybrid — native hook for tool calls, patch for crew entry
Pydantic AIAbstractCapability · Agent.run/run_syncNative (opt-in) · Patch (auto)
OpenAI Agents SDKtool_input_guardrail/tool_output_guardrail · Runner.run/run_syncNative (opt-in) · Patch (auto)
LangChainBaseChatModel.invoke/ainvoke, BaseTool.invoke/ainvokePatch
OpenAI APICompletions.create (chat & completions)Patch
Anthropic APIMessages.createPatch
LiteLLMcompletion, acompletionPatch
Google GenAIModels.generate_content (new + legacy)Patch
LlamaIndexLLM.chat/achat/complete/acomplete on every concrete subclass, BaseQueryEngine.query/aqueryPatch
InstructorInstructor.create, AsyncInstructor.createPatch
DSPyModule.__call__, LM.forward/aforwardPatch
MCPTransport-layer proxy for any MCP server (stdio / HTTP)Proxy — no patching
httpxHttpxExecutor for raw HTTP egress (REST agents, webhooks)Wrapper — no patching
PlaywrightPlaywrightExecutor for browsing agentsWrapper — no patching

auto_instrument() detects what's installed and patches only those — no hard dependencies. Custom adapters use the same BaseAdapter interface. Every adapter above is exercised against the current upstream release daily by the integration workflow, which drives each framework's real entrypoint and asserts a guardrail fires — the unit suite fakes these frameworks, so it cannot see upstream drift on its own.

Integration policy. Native extension points win wherever one exists that can actually block — Google ADK's BasePlugin and CrewAI's BeforeToolCallHook both do, and there auto_instrument() patches only enough to install the native object. Pydantic AI and the OpenAI Agents SDK ship native implementations you opt into (AbstractCapability, tool_input_guardrail) alongside a patch-based path for the zero-code case. Everything else is patched because no blocking hook exists: the raw OpenAI/Anthropic SDKs and DSPy expose none, and LlamaIndex's instrumentation dispatcher emits events but swallows handler exceptions, so it can observe and not enforce.

The Pydantic AI integration is the reason this policy is written down. It was monkey-patched until core maintainer DouweM reviewed it — "It doesn't look like those features are actually exposed as Pydantic AI capabilities?" — and was rebuilt on the native extension API in response (src/aegis/contrib/pydantic_ai.py; the review is pydantic-ai#4888).

Patching is the fallback, not the preference — it is the part most exposed to upstream change, which is why the integration workflow exists.

Default Guardrails

GuardrailDefaultWhat it catches
Prompt injectionBlock13 attack categories, 109 patterns, 9 languages (EN/KO/ZH/JA/ES/DE/FR/TH/VI)
PII detectionWarn13 categories (email, credit card, SSN, IBAN, API keys, etc.)
Prompt leakWarnSystem prompt extraction attempts
ToxicityWarnHarmful, violent, or abusive content
MCP STDIO injectionBlockJSON-RPC injection, frame concatenation, unicode escape bypass (OX Security advisory)

Deterministic regex — no LLM calls, no network. 2.65ms cold / <1µs warm per check.


Use Cases

The same primitives, five different entry points. Pick whichever matches your workflow.

1. Runtime protection (most common)

One line. Any framework.

python
import aegisaegis.auto_instrument()

Or zero code changes — AEGIS_INSTRUMENT=1 python my_agent.py. Injection blocking, PII masking, prompt-leak warnings, audit trail, and policy enforcement become active for every LangChain / CrewAI / OpenAI / Anthropic / LiteLLM / ADK / DSPy / LlamaIndex / Pydantic AI call.

Pydantic AI native capability — no monkey-patching, explicit per-agent control:

python
from pydantic_ai import Agentfrom aegis.contrib.pydantic_ai import AegisCapability
agent = Agent(    "openai:gpt-4o-mini",    capabilities=[AegisCapability.default()],  # injection, PII, toxicity, prompt-leak, hallucination)result = await agent.run("What is AI governance?")

Full Pydantic AI integration guide →

2. Pre-production scanning

Find ungoverned AI calls before they ship.

bash
pip install agent-aegisaegis scan .
Aegis Governance Scan=====================Scanned: 47 files in ./src
Found 5 ungoverned tool call(s):  agent.py:12   OpenAI        function call with tools= — no governance wrapper  [ASI02]  tools.py:8    LangChain     @tool "search_db" — no policy check  [ASI02]  llm.py:21     LiteLLM       litellm.completion() — no governance wrapper  [ASI02]  run.py:5      subprocess    subprocess.run — direct shell execution  [ASI08]  api.py:14     HTTP          requests.post — raw HTTP in agent code  [ASI07]
Governance Score: D (5 ungoverned call(s))

Supports --format json|sarif|suggest, --threshold A-F, .aegisscanignore, and inline # aegis: ignore pragmas. Auto-fix with aegis scan --fix.

3. Policy CI/CD

Security tools protect at runtime. Aegis also manages the policy lifecycle — the same way you test and ship code.

bash
aegis plan current.yaml proposed.yaml --audit-db aegis_audit.db
# Policy Impact Analysis#   Rules: 2 added, 1 removed, 3 modified#   Impact (replayed 1,247 actions):#     23 actions would change from AUTO → BLOCK
bash
aegis test policy.yaml tests.yaml                      # Run in CIaegis test policy.yaml --generate                      # Auto-generate test suiteaegis test new.yaml tests.yaml --regression old.yaml   # Regression check
yaml
# .github/workflows/policy-check.yml- uses: Acacian/aegis@main  with:    policy: aegis.yaml    tests: tests.yaml    fail-on-regression: true

Or block ungoverned calls at PR time:

yaml
- uses: Acacian/[email protected]  with:    command: scan    fail-on-ungoverned: true

4. Audit & compliance

Every call is logged to a tamper-evident Merkle chain, with mappings to EU AI Act / NIST AI RMF / SOC2 built in.

bash
aegis audit
  ID  Session       Action        Target   Risk      Decision    Result  1   a1b2c3d4...   read          crm      LOW       auto        success  2   a1b2c3d4...   bulk_update   crm      HIGH      approved    success  3   a1b2c3d4...   delete        crm      CRITICAL  block       blocked

SQLite + JSONL + webhook sinks. Ed25519 signing for long-term evidence. See the Compliance guide.

5. Governance server (multi-agent)

Centralized governance for multiple agents. Each agent connects via SDK, server handles policy, guardrails, audit, and compliance.

bash
pip install 'agent-aegis[server]'aegis-server

37 REST endpoints + WebSocket audit streaming + web dashboard. Agents auto-register, send heartbeats, and query policy over HTTP. See Governance Framework Server.


30-Second Start

bash
pip install agent-aegis
python
import aegisaegis.auto_instrument()# All 12 frameworks now governed with default guardrails.

Or use a YAML policy for full control:

bash
aegis init  # Creates aegis.yaml
yaml
# aegis.yamlguardrails:  pii: { enabled: true, action: mask }  injection: { enabled: true, action: block, sensitivity: medium }
policy:  version: "1"  defaults:    risk_level: medium    approval: approve  rules:    - name: read_safe      match: { type: "read*" }      risk_level: low      approval: auto    - name: no_deletes      match: { type: "delete*" }      risk_level: critical      approval: block

Install Options

bash
pip install agent-aegis                   # Core (includes auto_instrument for all frameworks)pip install langchain-aegis               # LangChain standalone integrationpip install 'agent-aegis[mcp]'            # MCP server + proxypip install 'agent-aegis[server]'         # REST API + dashboardpip install 'agent-aegis[all]'            # Everything

MCP Proxy — govern any MCP server with zero code changes

json
{  "mcpServers": {    "filesystem": {      "command": "uvx",      "args": ["--from", "agent-aegis[mcp]", "aegis-mcp-proxy",               "--wrap", "npx", "-y",               "@modelcontextprotocol/server-filesystem", "/home"]    }  }}

Works with Claude Desktop, Cursor, VS Code, Windsurf. STDIO injection protection, tool poisoning detection, rug-pull detection, argument sanitization, policy evaluation, full audit trail.

Governance Framework Server

Run Aegis as a dedicated governance server with REST API, WebSocket streaming, and web dashboard.

bash
pip install 'agent-aegis[server]'aegis-server --init          # Generate aegis-server.yamlaegis-server                 # Start server on :8000

37 REST endpoints covering the full governance lifecycle:

API GroupEndpointsPurpose
Coreevaluate, execute, audit, policyPolicy evaluation + execution pipeline
Agentsregister, heartbeat, list, statusAgent lifecycle management
Guardrailscheck, listContent safety checks
Policy Versioningcommit, diff, rollback, tagGit-like policy change management
Crypto Auditverify, entries, evidenceTamper-proof audit chain verification
Trust & Drifttrust score, drift detectionPer-agent behavioral analysis
Costbudget check, reportsLLM cost governance
Compliancereports, regulatory gapsSOC2 / GDPR / EU AI Act reports
Sessionslist, replaySession recording + forensic replay

Connect with the Python SDK (sync or async):

python
from aegis import AegisClient
with AegisClient("http://localhost:8000", agent_id="my-agent") as client:    result = client.evaluate("delete", "user_data")    # result["risk_level"] == "CRITICAL", result["is_allowed"] == False
python
from aegis import AsyncAegisClient
async with AsyncAegisClient("http://localhost:8000", agent_id="my-agent") as client:    result = await client.evaluate("read", "reports")

Config-driven via aegis-server.yaml — guardrails, webhooks (Slack/PagerDuty), rate limiting, cost budgets, and auth all declarative. See aegis-server.example.yaml.


Why Aegis?

Writing your ownPlatform guardrailsEnterprise platformsAegis
Abstraction levelPer-framework if/elseSingle-vendor SDKProprietary gatewayUniversal primitives across 12 frameworks
SetupDays of if/elseVendor-specific configKubernetes + procurementpip install + one line
Code changesWrap every callSDK-specificMonths of integrationZero — auto-instruments
Policy portabilityRewrite per frameworkLocked to ecosystemUsually single-vendorOne YAML policy, every framework
Governance primitivesBuild from scratchSubset, vendor-definedProprietary10+ composable primitives
Policy CI/CDNoneNoneNoneaegis plan + aegis test
Audit trailprintf debuggingPlatform logs onlyCloud dashboardSQLite + JSONL + webhooks + Merkle chain
ComplianceManual docsNoneEnterprise sales cycleEU AI Act, NIST, SOC2 built-in
CostEngineering timeFree-to-$$$$$$$ + infraFree (MIT). Forever.

What Only Aegis Does

Other tools check inputs and outputs. Aegis governs the decision itself — with primitives no other governance runtime exposes.

CapabilityWhat it meansBased on
Tripartite ActionClaimEvery tool call splits into Declared (agent-authored, untrusted), Assessed (Aegis-computed), and Chain (delegation) fields. The structural separation is what makes cosmetic alignment detectable.Justification Gap measurement on 14,285 tau-bench calls
Justification Gap6-dimensional asymmetric scoring: agents declare impact, Aegis independently assesses it, and per_dim = max(0, assessed − declared). Under-reporting triggers escalate (>0.15) or block (>0.40).Name "ActionClaim" from COA-MAS (Carvalho); 6D metric + runtime form original
Selection GovernanceAudits what agents exclude, not just what they choose. A model that "helpfully" omits risky options is exerting selection power — Aegis detects this.Santander et al., arXiv:2602.14606
Monotone Trust ConstraintDelegated agents cannot escalate their own authority. Trust levels must be non-increasing along the chain — violations auto-block.Lattice-based access control
Full LifecycleScan (detect) → Instrument (protect) → Policy CI/CD (test) → Runtime (govern) → Proxy (gateway) → Audit (trace). One library, one pip install.—

CLI

bash
aegis scan ./src/                       # Detect ungoverned AI callsaegis score ./src/ --policy policy.yaml # Governance score (0-100)aegis init                              # Generate starter policyaegis validate policy.yaml              # Validate syntaxaegis plan current.yaml proposed.yaml   # Preview policy changesaegis test policy.yaml tests.yaml       # Policy regression testingaegis check policy policy.yaml read:crm # Policy decision per action (CI gate)aegis audit                             # View audit logaegis serve policy.yaml                 # REST API + dashboardaegis probe policy.yaml                 # Adversarial policy testingaegis autopolicy "block deletes"        # Natural language → YAML

Research

Original measurements on public agent trace datasets. Stdlib-only, reproducible in 30 seconds.

  • The Justification Gap in 14,285 Tau-Bench Tool Calls — Formal definition of the Tripartite ActionClaim with a silent-baseline empirical study. 90.3% approve / 9.7% escalate / 0% block across four model:domain groups. Airline domain exposes ~2× the mean gap of retail. Includes soundness sketches for the three structural invariants and an honest note on the max-only override limitation discovered during the study.
  • Tool Distribution Drift in 1,960 Tau-Bench Trajectories — Shannon entropy on tool name sequences across GPT-4o and Sonnet 3.5 New. 39.8% of scored trajectories collapse onto one or two tools by the end. Bimodal distribution, 1.7× cross-model gap. All scripts and raw data included.

Run the same signal on your own trace:

bash
aegis check drift --trace path/to/trace.jsonl

The CLI reads only the tool_name field — never args, CoT, or prompts — so enterprise users can score prod traces without exfiltrating PII.

We also ran aegis scan across 39 public agent repositories and graded their governance posture: 92% scored an F. That is a finding about the ecosystem, not about any one project — most agent code has no tool-call policy at all.

Documentation

Full documentation at acacian.github.io/aegis:

Contributing

bash
git clone https://github.com/Acacian/aegis.git && cd aegismake dev      # Install deps + hooksmake test     # Run testsmake lint     # Lint + format check

Contributing Guide • Good First Issues • [Open in GitHub Codespaces]

License

MIT -- see LICENSE for details.

Copyright (c) 2026 구동하 (Dongha Koo, @Acacian). Created March 21, 2026.


The governance layer for AI agents. One API, 12 frameworks, every governance primitive.
If Aegis helps you, consider giving it a star -- it helps others find it too.

來源:README.md,提交 757f570

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.1.7最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分