Python Adapters
Imports, setup patterns, and compatibility notes for all 8 Python adapters.
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
| Framework | Import | Install | Best-fit compatibility | Post-execution result replacement |
|---|---|---|---|---|
| LangChain + LangGraph | from edictum.adapters.langchain import LangChainAdapter | pip install edictum[yaml,langchain] | ToolNode, LangGraph agents, sync or async paths | Yes |
| CrewAI | from edictum.adapters.crewai import CrewAIAdapter | pip install edictum[yaml,crewai] | Global CrewAI before/after hooks | No |
| OpenAI Agents SDK | from edictum.adapters.openai_agents import OpenAIAgentsAdapter | pip install edictum[yaml,openai-agents] | Per-tool guardrails on @function_tool | Block only |
| Claude Agent SDK | from edictum.adapters.claude_agent_sdk import ClaudeAgentSDKAdapter | pip install edictum[yaml] plus the upstream Claude SDK | Manual bridge into Claude hook shape | No |
| Google ADK | from edictum.adapters.google_adk import GoogleADKAdapter | pip install edictum[yaml] google-adk | Runner plugins or LlmAgent callbacks | Yes |
| Agno | from edictum.adapters.agno import AgnoAdapter | pip install edictum[yaml,agno] | tool_hooks wrap-around integration | Yes |
| Semantic Kernel | from edictum.adapters.semantic_kernel import SemanticKernelAdapter | pip install edictum[yaml,semantic-kernel] | AUTO_FUNCTION_INVOCATION filter | Yes |
| Nanobot | from edictum.adapters.nanobot import NanobotAdapter | pip install edictum[yaml] plus nanobot | Drop-in governed registry for ToolRegistry | Yes |
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.
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.
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.
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
LangChainAdapterfor LangGraph orToolNode. - Pick
GoogleADKAdapterif you need runner-wide enforcement in Google ADK. - Pick
SemanticKernelAdapterwhen your app already centers on aKernel. - Pick
OpenAIAgentsAdapteronly if per-tool guardrails fit your integration model. - Pick
CrewAIAdapterorClaudeAgentSDKAdapterwhen the framework owns the hook lifecycle and side effects are enough. - Pick
NanobotAdapterwhen the framework centers on a registry object, not hook callbacks.
Last updated on