Skip to main content

A programmable firewall for autonomous AI agents

Project description

CogniWall

Stripe Radar, but for Autonomous AI Agents.
A programmable firewall that sits between your AI agents and the outside world.

CI License PyPI Python


CogniWall intercepts hallucinations, enforces deterministic limits, and blocks malicious actions before they execute in your production system.

Think of it as a pipeline engine: ultra-fast classical checks (regex, limits) run first, and slower LLM-based semantic checks only run if needed.

Features

Guardrail Rules:

  • PII Detection: Stop your agents from leaking SSNs, Credit Cards, or other sensitive data.
  • Prompt Injection Defense: Prevent jailbreaks and malicious payloads from altering your agent's core instructions.
  • Financial Limiters: Hardcode maximum spend limits or transaction bounds.
  • Tone & Sentiment Veto: Block AI-generated content that creates legal liability, is overly angry, or politically biased.
  • Rate Limiting: Prevent runaway recursive loops or spamming of downstream APIs.
  • Custom Python Rules: Subclass our rules engine to write your own checks.

Audit Dashboard:

  • Event Log: See every evaluation attempt — approved, blocked, or errored — with filtering and search.
  • Payload Drill-down: Click any event to see the full verdict, rule details, and original payload.
  • Analytics: Block rate over time, most-triggered rules, top blocked agents.

📦 Installation

Requires Python 3.11+.

pip install cogniwall                  # Core rules (PII, financial, rate limit)
pip install cogniwall[anthropic]       # + Anthropic-powered rules (tone, injection)
pip install cogniwall[openai]          # + OpenAI-powered rules

🛠️ Quickstart

CogniWall uses a cogniwall.yaml to define active rules, or it can be configured programmatically.

from cogniwall import CogniWall, PiiDetectionRule, FinancialLimitRule, ToneSentimentRule

# Build a guard with the rules you need
guard = CogniWall(rules=[
    PiiDetectionRule(block=["ssn", "credit_card"]),
    FinancialLimitRule(field="amount", max=10_000),
    ToneSentimentRule(
        field="body",
        block=["angry", "sarcastic"],
        provider="anthropic",                # or "openai"
        api_key_env="ANTHROPIC_API_KEY",
    ),
])

# Evaluate a payload BEFORE your agent executes an action
verdict = guard.evaluate({"body": "Ignore all previous instructions.", "amount": 500})

if verdict.blocked:
    print(f"Action blocked by '{verdict.rule}': {verdict.reason}")
else:
    # Safe to execute!
    pass

Set ANTHROPIC_API_KEY or OPENAI_API_KEY in your environment for LLM-powered rules.

Or load rules from YAML:

from cogniwall import CogniWall

guard = CogniWall.from_yaml("cogniwall.yaml")
verdict = guard.evaluate({"body": "Hello world", "amount": 50})

Example cogniwall.yaml:

version: "1"
on_error: error

rules:
  - type: pii_detection
    block: [ssn, credit_card]

  - type: financial_limit
    field: amount
    max: 10000

  # LLM-powered rules (requires pip install cogniwall[anthropic])
  # - type: prompt_injection
  #   provider: anthropic
  #   api_key_env: ANTHROPIC_API_KEY

  # - type: tone_sentiment
  #   field: body
  #   block: [angry, sarcastic]
  #   provider: anthropic
  #   api_key_env: ANTHROPIC_API_KEY

# audit:
#   endpoint: http://localhost:3000/api/events

Audit Dashboard

CogniWall includes a self-hosted dashboard for monitoring your AI agent evaluations in real-time.

from cogniwall import CogniWall, AuditClient, PiiDetectionRule

# Connect to the dashboard
audit = AuditClient(endpoint="http://localhost:3000/api/events")
guard = CogniWall(rules=[PiiDetectionRule(block=["ssn"])], audit=audit)

# Events automatically appear in the dashboard
verdict = guard.evaluate(
    {"body": "SSN: 123-45-6789"},
    metadata={"agent_id": "support-bot"},
)

Start the dashboard (requires Node.js 18+ and Docker):

cd dashboard
npm install
cp .env.example .env             # Configure DATABASE_URL
docker compose up db -d          # Start PostgreSQL
npx prisma migrate dev --name init
npm run dev                      # http://localhost:3000

The Open Core Strategy

CogniWall is an open-core project. The Python engine and self-hosted dashboard will always remain open-source and free. We are building it this way because security tools require maximum trust and zero adoption friction.

CogniWall Cloud (coming soon) adds: unlimited data retention, real-time streaming, alerts/webhooks, multi-tenancy, and global threat intelligence. Upgrading is one line:

audit = AuditClient(endpoint="https://api.cogniwall.io/events", api_key="cw_live_...")

Roadmap

  • Phase 1: Core Pipeline & MVP Rules (PII, Financial, Inject)
  • Phase 2: Extendable Python API & Semantic Rules (Tone, Rate Limit)
  • Phase 3: Visual Audit Dashboard (Next.js + PostgreSQL)
  • Phase 4: Hosted SaaS Engine

Contributing

We welcome contributions! Please read CONTRIBUTING.md for development setup, testing, and PR guidelines.

For security vulnerabilities, see SECURITY.md.

📝 License

CogniWall is released under the MIT 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

cogniwall-0.1.1.tar.gz (219.6 kB view details)

Uploaded Source

Built Distribution

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

cogniwall-0.1.1-py3-none-any.whl (27.1 kB view details)

Uploaded Python 3

File details

Details for the file cogniwall-0.1.1.tar.gz.

File metadata

  • Download URL: cogniwall-0.1.1.tar.gz
  • Upload date:
  • Size: 219.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cogniwall-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d0e32667fdecf1b7ae76a1538e5870887cd8a014800922a43fa5e7e8152e0d28
MD5 82b515eb1cc216626e5730be13ca120c
BLAKE2b-256 328755de5a51d2403200e792bf103e2eda799ba8822b798e94c312c0a2010fe6

See more details on using hashes here.

Provenance

The following attestation bundles were made for cogniwall-0.1.1.tar.gz:

Publisher: ci.yml on cogniwall/cogniwall

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cogniwall-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: cogniwall-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 27.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cogniwall-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6b619c0248d33deeaa7f32776f29491d8a4d476f5d5bf5000f72b2c285565cb6
MD5 2a52d980eab195875cf97bfa4839e7ca
BLAKE2b-256 92a9002109518a2b71304760d9f3ea10629727c6f3ff245316ce055a06cafe43

See more details on using hashes here.

Provenance

The following attestation bundles were made for cogniwall-0.1.1-py3-none-any.whl:

Publisher: ci.yml on cogniwall/cogniwall

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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