Policy-enforced runtime for autonomous AI agents
Project description
ANTRAFT
Policy-enforced runtime for autonomous AI agents.
Antraft is a secure runtime environment designed to execute autonomous AI agents with strict, policy-based governance. It ensures that agents operate within defined boundaries, enforcing explicit allow/deny rules, resource limits, and comprehensive audit logging.
Unlike standard agent frameworks that prioritize capability, Antraft prioritizes control and safety.
Key Features
- Policy Enforcement: Every action proposed by an agent is evaluated against a strict policy before execution.
- Secure by Default: Actions are denied by default unless explicitly allowed.
- Hard & Soft Limits: Enforce maximum action checks (Hard/DENY) and runtime duration (Soft/PAUSE).
- Immutable Audit Logs: All agent decisions and runtime enforcements are recorded in an append-only audit log.
- Tool Gateway: A controlled interface for external tool execution, preventing unauthorized access.
Installation
Requires Python 3.10+.
# Clone the repository
git clone https://github.com/AshrafGalibShaik/ANTRAFT.git
cd ANTRAFT
# Install dependencies
pip install .
Quick Start
Here is a simple example of how to run an agent within the Antraft runtime.
from antraft.core.runtime import antraftRuntime
from antraft.core.agent import SimpleAgent
from antraft.policy.engine import PolicyEngine
from antraft.gateway.gateway import ToolGateway
# 1. Define the Policy
policy = {
"allow": ["run_tests", "read_file"],
"deny": ["shell_execute", "delete_file"],
"limits": {
"hard": {"max_actions": 10}, # Kill agent if exceeded
"soft": {"max_runtime_seconds": 60} # Pause agent if exceeded
},
}
# 2. Setup the Components
agent = SimpleAgent()
engine = PolicyEngine(policy)
gateway = ToolGateway(tools={
"run_tests": lambda: print("Running tests..."),
"read_file": lambda path: print(f"Reading {path}...")
})
# 3. Initialize Runtime
runtime = antraftRuntime(
agent=agent,
policy_engine=engine,
tool_gateway=gateway
)
# 4. Execute
runtime.run()
Architecture
Antraft operates on a rigorous cycle: Propose > Evaluate > Enforce > Execute.
- Agent: Proposes an
Action(e.g., "delete file"). - PolicyEngine: The proposed action is passed to the Policy Engine, which evaluates it against the loaded ruleset. Evaluation fails fast and moves in a strict order:
- Explicit Deny: Checks if the action is in the
denylist. If found, returnsDENY. - Hard Limits: Checks if global counters (e.g.,
max_actions) have been exceeded. If so, returnsDENY. - Soft Limits: Checks if soft thresholds (e.g.,
max_runtime_seconds) have been exceeded. If so, returnsPAUSE. - Explicit Allow: Checks if the action is in the
allowlist. If found, returnsALLOW. - Default Deny: If no rules match, the action is denied by default for security.
- Explicit Deny: Checks if the action is in the
- AuditLogger: The
AuditEventis constructed, capturing the Agent ID, proposed Action, Decision (ALLOW/DENY/PAUSE), and the Reason. This is written to an append-only log file. - Runtime: Enforces the decision:
- ALLOW: The action is passed to the
ToolGatewayfor actual execution. The result is observed by the Agent. - DENY: The runtime immediately terminates the agent loop (
context.kill()). - PAUSE: The runtime suspends the agent loop safely (
context.pause()).
- ALLOW: The action is passed to the
Policy Configuration
Policies are defined as Python dictionaries or JSON objects. They dictate the exact boundaries of the agent's capabilities.
Example Configuration
{
"allow": [
"list_dir",
"read_file",
"analyze_code"
],
"deny": [
"connect_internet",
"exec_subprocess",
"write_file"
],
"limits": {
"hard": {
"max_actions": 50
},
"soft": {
"max_runtime_seconds": 300
}
}
}
Limit Types
- Hard Limits: These define the absolute maximums for an execution session. If a hard limit is breached, the agent is considered compromised or malfunctioning, and the runtime will
DENYfurther actions and terminate. - Soft Limits: These define safe operating thresholds. If a soft limit is reached, the runtime will
PAUSEexecution. This allows for state inspection or manual intervention without killing the agent process entirely.
API Reference
antraft.core.runtime.antraftRuntime
The main entry point for executing an agent.
__init__(agent, policy_engine, tool_gateway, auditor=None): Initializes the runtime components.run() -> RuntimeContext: Starts the main execution loop. It continues until the agent finishes or a policy decision stops it.
antraft.policy.engine.PolicyEngine
Stateless evaluator of actions.
evaluate(action, context) -> PolicyDecision: Takes a proposed action and current runtime statistics (action count, runtime duration) and returns an enforcement decision.
antraft.gateway.gateway.ToolGateway
The security boundary for external tools.
execute(action) -> Any: Executes the verified action. This method is only called after the PolicyEngine has returnedALLOW.
Contributing
Contributions are welcome. Please feel free to submit a Pull Request.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
License
Distributed under the MIT License. See LICENSE for more information.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file antraft-0.1.0.tar.gz.
File metadata
- Download URL: antraft-0.1.0.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c479e25820ade3becbedbfd1cdfda255e56512efdba90d16f485a4b59d956a4e
|
|
| MD5 |
2b3c330cecbbb8e45a94015ef52c7e20
|
|
| BLAKE2b-256 |
4aa83bbebe06b3821b2e56149389b480684847208fcb43f994e875d165979d78
|
File details
Details for the file antraft-0.1.0-py3-none-any.whl.
File metadata
- Download URL: antraft-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6448a4701dc48a6599e03246be14b03fe192f694cc5237fc72a43496cf150d5a
|
|
| MD5 |
1f5e128c8e92743cea333fa471ec96e5
|
|
| BLAKE2b-256 |
b764a61e877cd8e2d63c0100524554c9da2cd11ab6587a5792d92185d255acb1
|