Edictum
Python SDK

Python SDK

Reference Edictum SDK for Python. Load rulesets, run tool calls, wire 8 adapters, and attach Workflow Gates.

AI Assistance

Right page if: you want the Python package surface, install commands, a quick start, or a map of the 8 Python adapters. Wrong page if: you need TypeScript or Go usage. For workflow authoring, see https://docs.edictum.ai/docs/guides/workflow-gates. Gotcha: the base package has zero runtime dependencies. Install `edictum[yaml]` for YAML rulesets. Add framework extras separately.

The Python package is the reference Edictum SDK. Use it when you want local ruleset enforcement, Workflow Gates, server-backed rulesets from edictum-api, or one of the 8 Python adapters.

Quick Start

Install

pip install edictum[yaml]

Write a ruleset

Save this as rules.yaml:

apiVersion: edictum/v1
kind: Ruleset
metadata:
  name: file-safety
defaults:
  mode: enforce
rules:
  - id: block-sensitive-reads
    type: pre
    tool: read_file
    when:
      args.path:
        contains_any: [".env", ".secret", "credentials", ".pem", "id_rsa"]
    then:
      action: block
      message: "Sensitive file '{args.path}' blocked."

Run it

import asyncio

from edictum import Edictum, EdictumDenied

guard = Edictum.from_yaml("rules.yaml")


async def read_file(path: str) -> str:
    return f"contents of {path}"


async def main() -> None:
    result = guard.evaluate("read_file", {"path": ".env"})
    print(result.decision)  # "block"
    print(result.block_reasons[0])  # "Sensitive file '.env' blocked."

    try:
        await guard.run("read_file", {"path": ".env"}, read_file)
    except EdictumDenied as exc:
        print(exc.reason)  # "Sensitive file '.env' blocked."


asyncio.run(main())

Package Extras

NeedInstall
Core runtime onlypip install edictum
YAML rulesetspip install edictum[yaml]
OpenTelemetrypip install edictum[otel]
Server SDKpip install edictum[yaml,server]
Signature verificationpip install edictum[yaml,server,verified]
Canonical CLI / Gatego install github.com/edictum-ai/edictum-go/cmd/edictum@latest

Python Adapter Coverage

All Python adapters take the same core constructor shape: guard, optional session_id, optional principal, and optional principal_resolver.

FrameworkInstallImportIntegration
LangChain + LangGraphpip install edictum[yaml,langchain]from edictum.adapters.langchain import LangChainAdapteras_tool_wrapper() / as_async_tool_wrapper() / as_middleware()
CrewAIpip install edictum[yaml,crewai]from edictum.adapters.crewai import CrewAIAdapterregister()
OpenAI Agents SDKpip install edictum[yaml,openai-agents]from edictum.adapters.openai_agents import OpenAIAgentsAdapteras_guardrails()
Claude Agent SDKpip install edictum[yaml] plus the upstream Claude SDKfrom edictum.adapters.claude_agent_sdk import ClaudeAgentSDKAdapterto_hook_callables()
Google ADKpip install edictum[yaml] google-adkfrom edictum.adapters.google_adk import GoogleADKAdapteras_plugin() / as_agent_callbacks()
Agnopip install edictum[yaml,agno]from edictum.adapters.agno import AgnoAdapteras_tool_hook()
Semantic Kernelpip install edictum[yaml,semantic-kernel]from edictum.adapters.semantic_kernel import SemanticKernelAdapterregister(kernel)
Nanobotpip install edictum[yaml] plus nanobotfrom edictum.adapters.nanobot import NanobotAdapterwrap_registry()

See Python adapters for per-framework examples and compatibility notes.

Workflow Gates and Server Runtime

Python exposes both sides of the runtime directly:

  • Rulesets: Edictum.from_yaml(), Edictum.from_yaml_string(), Edictum.from_template()
  • Workflow Gates: workflow_path, workflow_content, or a prebuilt WorkflowRuntime
  • Server-backed runtime: await Edictum.from_server(...)

If your workflow uses trusted exec(...) conditions, opt in explicitly with workflow_exec_evaluator_enabled=True.

Next Steps

Last updated on

On this page