Documentation
The complete reference for the Antraft Governance Runtime (v1.1.0).
Designed for Mission Critical AI systems.
Introduction
Antraft (Agentic Neural Trust & Runtime audit Framework) is a governance middleware that sits between your agent's "Brain" (LLM) and its "Hands" (Tools). Unlike static analysis tools, Antraft operates at runtime, intercepting every action proposed by the agent and validating it against a deterministic policy engine.
Quick Start
Antraft is available on PyPI and supports Python 3.10+.
pip install antraft
The easiest way to integrate is using the Fluent SDK. This wraps your existing agent instance (whether it's LangChain, AutoGen, or raw Python) and injects the governance layer.
import { Antraft } from "antraft"
# 1. Define your Agent (Mock)
agent = MyCustomerSupportAgent()
tools = {"lookup_user": db.lookup, "refund": stripe.refund}
# 2. Add Governance
await Antraft.guard(agent, tools)
.allow(["lookup_user"])
.deny(["delete_user"])
.record_session("logs/flight_data.jsonl")
.run()The Runtime Architecture
The antraftRuntime is the heart of the system. It enforces a strict Propose-Evaluate-Execute cycle.
- Proposal: Agent outputs a Thought or Action.
- interception: Runtime pauses execution.
- Behavioral Analysis: The Drift Detector checks for anomalies (loops, bursts).
- Policy Check: The Policy Engine evaluates the action against Rules and State.
- Enforcement: Action is Allowed, Denied, or Paused (for Human Review).
Policy Engine & DSL
Policies are the "Laws" of your agent. They can be simple lists or complex logic rules.
Configuration Schema (YAML)
allow:
- "read_file"
- "search_google"
deny:
- "exec_shell"
- "os.system"
rules:
- trigger: "action:transfer_money"
checks:
- "amount > 10000"
- "not context.user_verified"
enforce: "pause"
message: "High value transfer requires approval"
prerequisites:
"transfer_money": ["authenticate_user"]DSL Notes: The checks field supports Python-like syntax. You can access action parameters (e.g., amount) and runtime context.
Tool Gateway
The Gateway is the secure interface for side-effects. Agents cannot import arbitrary libraries Use the Gateway to expose only specific functions to the agent.
def my_search(query: str):
return "results..."
gateway = ToolGateway({"search": my_search})Session Recorder & PII
For compliance (GDPR/CCPA), you often need a complete record of what the AI did. The Session Recorder captures a "Black Box" flight log.
The recorder automatically detects and redacts:
- Email Addresses
- Credit Card Numbers
- US Social Security Numbers
- Phone Numbers
{"type": "thought", "data": {"content": "I need to email <EMAIL>"}}
{"type": "action", "data": {"name": "send_email", "params": {"to": "<EMAIL>"}}}Audit Log Schema
Every event (Think, Act, Pause) is logged to antraft_audit.log in JSONL format.
{
"timestamp": "2023-10-01T12:00:00Z",
"agent_id": "support-bot-01",
"type": "action",
"payload": {
"tool": "read_file",
"decision": "allow"
}
}Swarm Control (Distributed)
Antraft supports a Control Plane architecture. Agents deployed on edge devices or multiple servers can "phone home" to a central API.
Features
- Mass PauseStop all agents instantly if a bug is found.
- Live Policy PushUpdate allow-lists without redeploying code.
Drift Detection
The Drift Detector uses statistical baselining to identify anomalies. It flags behavior like:
- Repetition Loops: Using the same tool 5x in a row.
- Burst Rate: 50 actions in 1 second.
- New Tool Usage: First time accessing a critical tool.