Skip to main content

AI Agent Action Firewall core SDK

Project description

agsec

PyPI version Python 3.8+ License

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. Addresses 7 of 10 OWASP Agentic Top 10 risks.

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 (tested)
agsec install codex            # OpenAI Codex
agsec install cursor           # Cursor
agsec install windsurf         # Windsurf (Codeium)
agsec install cline            # Cline
agsec install copilot          # GitHub Copilot (project + user level)

Claude Code and Claude Cowork are fully tested. Codex, Cursor, Windsurf, and Cline are functional but need community testing. VS Code Copilot also works with agsec install claude-code since it reads .claude/settings.json. 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
agsec halt                     # kill switch: block ALL actions immediately
agsec resume                   # restore from halt

Documentation

Contributing

See CONTRIBUTING.md for setup and guidelines.

License

Apache 2.0 — see LICENSE.

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

agsec-0.2.1.tar.gz (65.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agsec-0.2.1-py3-none-any.whl (82.2 kB view details)

Uploaded Python 3

File details

Details for the file agsec-0.2.1.tar.gz.

File metadata

  • Download URL: agsec-0.2.1.tar.gz
  • Upload date:
  • Size: 65.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for agsec-0.2.1.tar.gz
Algorithm Hash digest
SHA256 13736ab059fdb0f16e55493f4dc69705f1b2b5c56e7e7c1b93761f4afdbeaebb
MD5 ec7643d2c91990c6464df65c38920d76
BLAKE2b-256 6f5185def087f38b90a46d042f875b6764d1eb37a1568cf9e20f5762e4c2c9f3

See more details on using hashes here.

File details

Details for the file agsec-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: agsec-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 82.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for agsec-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a04823b9db2c503b95105f689d87ad1b821138419021b11ec53db0dee86b3421
MD5 70ba44b11e5201e821281496c7b94c85
BLAKE2b-256 538fbe192ad889911852cdb7e2b6435f537a61e22b9d984c960cd17d0d5837e4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page