Python SDK
Reference Edictum SDK for Python. Load rulesets, run tool calls, wire 8 adapters, and attach Workflow Gates.
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
| Need | Install |
|---|---|
| Core runtime only | pip install edictum |
| YAML rulesets | pip install edictum[yaml] |
| OpenTelemetry | pip install edictum[otel] |
| Server SDK | pip install edictum[yaml,server] |
| Signature verification | pip install edictum[yaml,server,verified] |
| Canonical CLI / Gate | go 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.
| Framework | Install | Import | Integration |
|---|---|---|---|
| LangChain + LangGraph | pip install edictum[yaml,langchain] | from edictum.adapters.langchain import LangChainAdapter | as_tool_wrapper() / as_async_tool_wrapper() / as_middleware() |
| CrewAI | pip install edictum[yaml,crewai] | from edictum.adapters.crewai import CrewAIAdapter | register() |
| OpenAI Agents SDK | pip install edictum[yaml,openai-agents] | from edictum.adapters.openai_agents import OpenAIAgentsAdapter | as_guardrails() |
| Claude Agent SDK | pip install edictum[yaml] plus the upstream Claude SDK | from edictum.adapters.claude_agent_sdk import ClaudeAgentSDKAdapter | to_hook_callables() |
| Google ADK | pip install edictum[yaml] google-adk | from edictum.adapters.google_adk import GoogleADKAdapter | as_plugin() / as_agent_callbacks() |
| Agno | pip install edictum[yaml,agno] | from edictum.adapters.agno import AgnoAdapter | as_tool_hook() |
| Semantic Kernel | pip install edictum[yaml,semantic-kernel] | from edictum.adapters.semantic_kernel import SemanticKernelAdapter | register(kernel) |
| Nanobot | pip install edictum[yaml] plus nanobot | from edictum.adapters.nanobot import NanobotAdapter | wrap_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 prebuiltWorkflowRuntime - 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
Python Adapters
Imports, examples, and compatibility for all 8 Python adapters
Python Server SDK
Connect to edictum-api for rulesets, approvals, SSE updates, and the decision log
Workflow Gates Runtime
Attach a workflow runtime and enforce stage progression
Quickstart
Cross-SDK starter path with real ruleset YAML
Last updated on