AI Agent Action Firewall core SDK
Project description
agsec
Action firewall for AI agents. Before an agent can do anything, it passes through agsec.
Agent wants to act --> agsec evaluates policy --> allow / block / review --> real world
Why
AI agents get real access to real systems. agsec gives you one policy layer across all of them — declarative YAML policies, runtime enforcement, full audit trail. Like AWS IAM, but for what agents can do.
Quick Start
pip install agsec
agsec init # create default policies
agsec install claude-code # activate firewall
Done. Every tool call is now checked. rm -rf blocked, .env writes blocked, force push blocked — out of the box.
Start in Observe Mode
Not ready to block? Audit everything first, block nothing:
agsec init --observe # log only, no blocking
agsec audit --stats # see what would be blocked
agsec enforce # start blocking when ready
Supported Platforms
System Agents (hook-based enforcement)
agsec install claude-code # Claude Code + Claude Cowork
agsec install codex # OpenAI Codex
agsec install cursor # Cursor
agsec install windsurf # Windsurf (Codeium)
agsec install cline # Cline
agsec install copilot # GitHub Copilot
Claude Code and Claude Cowork are fully tested. Other integrations are functional but community testing is welcome — please report issues.
Python SDKs (client wrapper)
Frameworks (tool wrapper)
LangChain:
from agsec.integrations.langchain import guard, allow, deny, review, param
agent = create_react_agent(llm, guard(
allow(search, calculator),
review(send_email),
deny(delete_record),
deny(payment).when(param("amount") > 10000),
))
OpenAI / Anthropic / OpenRouter:
from agsec.integrations.openai import protect, deny, param
client = protect(OpenAI(),
deny("delete_user"),
deny("payment").when(param("amount") > 10000),
)
# Works with OpenRouter, Groq, Together — anything OpenAI-compatible
Any Python function:
from agsec import guard
@guard("email.send")
def send_email(to, subject, body):
...
Policy Example
version: "1.0"
default: deny
statements:
- sid: "AllowReadOps"
effect: allow
actions: ["file.read", "file.glob", "file.grep"]
- sid: "BlockFileDelete"
effect: deny
actions: ["bash.execute"]
conditions:
params.command:
op: "regex"
value: "\\brm\\s"
reason: "Agents should not delete files"
- sid: "AllowBash"
effect: allow
actions: ["bash.execute"]
Deny always wins. Same evaluation order as AWS IAM.
CLI
agsec init [--observe] # scaffold policies
agsec install <platform> # activate (claude-code, codex, cursor, windsurf, cline, copilot)
agsec uninstall <platform> # deactivate
agsec policy list # see all rules
agsec policy add # add a rule (interactive)
agsec policy remove <sid> # remove a rule
agsec validate # check for errors
agsec audit [--stats] # view logs
agsec observe # switch to observe mode
agsec enforce # switch to enforce mode
Documentation
- Policy Format — schema, operators, conditions, examples
- CLI Reference — all commands in detail
- Integrations — Claude Code/Cowork, Codex, Cursor, Windsurf, Cline, Copilot, LangChain, OpenAI, Anthropic
- SDK Usage — programmatic Python API
- Observe Mode — audit first, enforce later
Contributing
See CONTRIBUTING.md for setup and guidelines.
License
Apache 2.0 — see LICENSE.
Project details
Release history Release notifications | RSS feed
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 agsec-0.2.0.tar.gz.
File metadata
- Download URL: agsec-0.2.0.tar.gz
- Upload date:
- Size: 53.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd16f97d3eae3c88d0a2b03ac13519b07bf4a469a7e8844b7e973808a1d41a4f
|
|
| MD5 |
9e4ce0e0602b52977657f7287722e20c
|
|
| BLAKE2b-256 |
98af9308fa585ff8a9a8921bb00ebfb8325e4804a32c2e95c6b60e08ed66fa4d
|
File details
Details for the file agsec-0.2.0-py3-none-any.whl.
File metadata
- Download URL: agsec-0.2.0-py3-none-any.whl
- Upload date:
- Size: 69.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
576efd53d519ec1a5fa019f906c22affa67a607e213e82b94d66c17a8a17daf9
|
|
| MD5 |
f50defd8c3e69a544e2cc7ae97203b49
|
|
| BLAKE2b-256 |
d0a22bf21911ba48aa8aa4c029ffefcac9e6a864b353cf786266fab5fa6297f7
|