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
  • Postcondition findings — Structured detection results from tool output checks, with optional remediation callbacks (redact PII, replace secrets, log and continue)
  • 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.1.tar.gz (155.5 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.1-py3-none-any.whl (60.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: edictum-0.5.1.tar.gz
  • Upload date:
  • Size: 155.5 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.1.tar.gz
Algorithm Hash digest
SHA256 8a4b9f2ca400096d597e3a73904c8621b0015938db02ba7af9229359129b2c7d
MD5 7250c6de157e174b6c1c9c50ae0fe0dd
BLAKE2b-256 79541487db4efae4651635088152e158b7c7318c13308c80c7e9b95bbe775c51

See more details on using hashes here.

File details

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

File metadata

  • Download URL: edictum-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 60.2 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 68b554f36f098cd82e018a76980d995a7b3716a329d0452d4cac3717a896e545
MD5 dbc0735bf52ddee6dd23a0a33b13141a
BLAKE2b-256 78d7b7c789ef32300ba1a40b703abbe42a69a1566e14372086bb6397bb5455a9

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