Edictum
Python SDK

Python Adapters

Imports, setup patterns, and compatibility notes for all 8 Python adapters.

AI Assistance

Right page if: you are wiring Edictum into a Python agent framework and need the exact adapter import and integration method. Wrong page if: you want the package overview or server SDK. See https://docs.edictum.ai/docs/python or https://docs.edictum.ai/docs/python/server. Gotcha: not every framework can rewrite tool output after execution. LangChain, Agno, Semantic Kernel, Google ADK, and Nanobot can; CrewAI, Claude Agent SDK, and OpenAI Agents SDK are more limited.

Adapters are thin translation layers. The rule engine stays in Edictum; the adapter just maps framework hooks onto the same runtime.

Quick Comparison

FrameworkImportInstallBest-fit compatibilityPost-execution result replacement
LangChain + LangGraphfrom edictum.adapters.langchain import LangChainAdapterpip install edictum[yaml,langchain]ToolNode, LangGraph agents, sync or async pathsYes
CrewAIfrom edictum.adapters.crewai import CrewAIAdapterpip install edictum[yaml,crewai]Global CrewAI before/after hooksNo
OpenAI Agents SDKfrom edictum.adapters.openai_agents import OpenAIAgentsAdapterpip install edictum[yaml,openai-agents]Per-tool guardrails on @function_toolBlock only
Claude Agent SDKfrom edictum.adapters.claude_agent_sdk import ClaudeAgentSDKAdapterpip install edictum[yaml] plus the upstream Claude SDKManual bridge into Claude hook shapeNo
Google ADKfrom edictum.adapters.google_adk import GoogleADKAdapterpip install edictum[yaml] google-adkRunner plugins or LlmAgent callbacksYes
Agnofrom edictum.adapters.agno import AgnoAdapterpip install edictum[yaml,agno]tool_hooks wrap-around integrationYes
Semantic Kernelfrom edictum.adapters.semantic_kernel import SemanticKernelAdapterpip install edictum[yaml,semantic-kernel]AUTO_FUNCTION_INVOCATION filterYes
Nanobotfrom edictum.adapters.nanobot import NanobotAdapterpip install edictum[yaml] plus nanobotDrop-in governed registry for ToolRegistryYes

Shared Constructor

from edictum import Edictum, Principal

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

adapter = SomeAdapter(
    guard=guard,
    session_id="task-42",
    principal=Principal(user_id="alice", role="reviewer"),
    principal_resolver=None,
)

Every adapter also exposes set_principal() for mid-session updates.

LangChain + LangGraph

from edictum import Edictum
from edictum.adapters.langchain import LangChainAdapter
from langgraph.prebuilt import ToolNode

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

tool_node = ToolNode(tools=[search_tool, read_tool], wrap_tool_call=adapter.as_tool_wrapper())

Use this when you want full wrap-around control. as_tool_wrapper() is the default choice, as_async_tool_wrapper() is the cleanest path for native async code, and as_middleware() is the legacy sync-only option.

See LangChain adapter.

CrewAI

from edictum import Edictum
from edictum.adapters.crewai import CrewAIAdapter

guard = Edictum.from_yaml("rules.yaml")
adapter = CrewAIAdapter(guard)
adapter.register()

CrewAI uses global before/after hooks. That makes setup simple, but post-execution callbacks are side-effect only.

See CrewAI adapter.

OpenAI Agents SDK

from agents import function_tool
from edictum import Edictum
from edictum.adapters.openai_agents import OpenAIAgentsAdapter

guard = Edictum.from_yaml("rules.yaml")
adapter = OpenAIAgentsAdapter(guard)
input_gr, output_gr = adapter.as_guardrails()


@function_tool(tool_input_guardrails=[input_gr], tool_output_guardrails=[output_gr])
def search_documents(query: str) -> str:
    return perform_search(query)

This path is per-tool, not per-agent. Output guardrails can reject content, but they cannot replace the tool result.

See OpenAI Agents adapter.

Claude Agent SDK

from edictum import Edictum
from edictum.adapters.claude_agent_sdk import ClaudeAgentSDKAdapter

guard = Edictum.from_yaml("rules.yaml")
adapter = ClaudeAgentSDKAdapter(guard)
hooks = adapter.to_hook_callables()

to_hook_callables() returns raw pre_tool_use and post_tool_use callables. Use this when you want to bridge Edictum into the Claude SDK's hook system without changing rule logic.

See Claude Agent SDK adapter.

Google ADK

from edictum import Edictum
from edictum.adapters.google_adk import GoogleADKAdapter

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

plugin = adapter.as_plugin()
before_cb, after_cb, error_cb = adapter.as_agent_callbacks()

Use as_plugin() for runner-wide enforcement. Use as_agent_callbacks() for per-agent scoping or ADK live mode.

See Google ADK adapter.

Agno

from edictum import Edictum
from edictum.adapters.agno import AgnoAdapter

guard = Edictum.from_yaml("rules.yaml")
adapter = AgnoAdapter(guard)
tool_hook = adapter.as_tool_hook()

Agno uses a wrap-around hook, so Edictum can block before execution and replace results after execution.

See Agno adapter.

Semantic Kernel

from edictum import Edictum
from edictum.adapters.semantic_kernel import SemanticKernelAdapter
from semantic_kernel import Kernel

kernel = Kernel()
guard = Edictum.from_yaml("rules.yaml")
adapter = SemanticKernelAdapter(guard)
adapter.register(kernel)

This registers an AUTO_FUNCTION_INVOCATION filter. Set terminate_on_deny=False if you want the kernel to continue evaluating later tool calls after one tool is blocked.

See Semantic Kernel adapter.

Nanobot

from edictum import Edictum
from edictum.adapters.nanobot import NanobotAdapter

guard = Edictum.from_yaml("rules.yaml")
adapter = NanobotAdapter(guard)
governed_registry = adapter.wrap_registry(tool_registry)

Nanobot gets a governed registry instead of hook registration. This is the cleanest Python path when you want Edictum around every registry execution.

See Nanobot adapter.

Choosing Quickly

  • Pick LangChainAdapter for LangGraph or ToolNode.
  • Pick GoogleADKAdapter if you need runner-wide enforcement in Google ADK.
  • Pick SemanticKernelAdapter when your app already centers on a Kernel.
  • Pick OpenAIAgentsAdapter only if per-tool guardrails fit your integration model.
  • Pick CrewAIAdapter or ClaudeAgentSDKAdapter when the framework owns the hook lifecycle and side effects are enough.
  • Pick NanobotAdapter when the framework centers on a registry object, not hook callbacks.

Last updated on

On this page