Skip to main content

Runtime safety for AI agents. Stop agents before they break things.

Project description

Edictum

PyPI License Python

Runtime contracts for AI agents.

AI agents make tool calls. Tool calls have side effects. Nobody governs what happens between "agent decides" and "tool executes." Edictum is that governance layer — preconditions, postconditions, session limits, and a full audit trail, enforced at the point where decision becomes action.

Show Me

contracts.yaml

apiVersion: edictum/v1
kind: ContractBundle

metadata:
  name: my-policy

defaults:
  mode: enforce

contracts:
  - id: block-sensitive-reads
    type: pre
    tool: read_file
    when:
      args.path:
        contains_any: [".env", ".secret", "credentials", ".pem", "id_rsa"]
    then:
      effect: deny
      message: "Sensitive file '{args.path}' blocked."
      tags: [secrets, dlp]

Python

import asyncio
from edictum import Edictum, EdictumDenied

async def main():
    guard = Edictum.from_yaml("contracts.yaml")

    try:
        result = await guard.run("read_file", {"path": "/app/config.json"}, read_file_fn)
        print(result)
    except EdictumDenied as e:
        print(f"Denied: {e}")

asyncio.run(main())

CLI

$ edictum validate contracts.yaml
✓ contracts.yaml  1 contract (1 pre)

$ edictum check contracts.yaml --tool read_file --args '{"path": ".env"}' DENIED by block-sensitive-reads
   Message: Sensitive file '.env' blocked.
   Tags: secrets, dlp
   Rules evaluated: 1

Framework integration (one adapter, same guard)

from edictum.adapters.langchain import EdictumMiddleware

middleware = EdictumMiddleware(guard)
# Wraps any LangChain tool — preconditions, audit, and session limits apply automatically

Features

  • YAML contracts — Preconditions, postconditions, and session limits declared in version-controlled YAML files
  • 6 framework adapters — LangChain, CrewAI, Agno, Semantic Kernel, OpenAI Agents SDK, Claude Agent SDK
  • Audit trail — Structured JSON events with automatic redaction of secrets (OpenAI keys, AWS creds, JWTs, GitHub tokens)
  • Observe mode — Shadow-deploy contracts without blocking; review CALL_WOULD_DENY events before enforcing
  • CLI toolingvalidate, check, diff, and replay commands for CI/CD integration
  • Principal context — Role, ticket ref, and claims propagated through every decision and audit event
  • Session limits — Cap total calls, attempts, and per-tool executions to catch runaway agents
  • Zero runtime deps — Pure Python 3.11+. OTel and adapters are optional extras

How It Compares

Approach Scope Runtime enforcement Audit trail
Prompt/output guardrails Input/output text No — advisory only No
API gateways / MCP proxies Network transport Yes — at the proxy Partial
Security scanners Post-hoc analysis No — detection only Yes
Manual if-statements Per-tool, ad hoc Yes — scattered logic No
Edictum Tool call contracts Yes — deterministic pipeline Yes — structured + redacted

Install

pip install edictum              # core (zero deps)
pip install edictum[yaml]        # + YAML contract engine
pip install edictum[otel]        # + OpenTelemetry span emission
pip install edictum[cli]         # + validate/check/diff/replay CLI
pip install edictum[all]         # everything

Built-in Templates

guard = Edictum.from_template("file-agent")      # secret file protection, destructive cmd blocking
guard = Edictum.from_template("research-agent")   # output PII detection, session limits
guard = Edictum.from_template("devops-agent")     # role gates, ticket requirements, bash safety

Links

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

edictum-0.5.0.tar.gz (147.3 kB view details)

Uploaded Source

Built Distribution

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

edictum-0.5.0-py3-none-any.whl (56.0 kB view details)

Uploaded Python 3

File details

Details for the file edictum-0.5.0.tar.gz.

File metadata

  • Download URL: edictum-0.5.0.tar.gz
  • Upload date:
  • Size: 147.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for edictum-0.5.0.tar.gz
Algorithm Hash digest
SHA256 119032b04d4f1b521f9567b9135ced39412e9699e50c09131e1ab5f5b91efb04
MD5 21aaee334635d42ff0e8cbadd497ff9d
BLAKE2b-256 3e2737626ca85c5bb9c9c176c26c3ad8e677b37f249ba6b5770972099ffe7553

See more details on using hashes here.

File details

Details for the file edictum-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: edictum-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 56.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for edictum-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9434173432bab1127a78f94ed38b2e70679ac61423db2a8202a4bf6387d09232
MD5 024316faeaa19d14120fb0d3e90898f8
BLAKE2b-256 f5efea948ddfc71cbd7332dce7d3ec9c1a32a38572ed33aeeee13ca5473d20d0

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