Use the Python SDK
Your Python code asks the Gate before a tool runs, and gets back the decision, the result and the verdict.
Before you start
- Python 3.10 to 3.14.
- A running Deedglass server and an agent key. The Quickstart gives you both.
1. Install
Section titled “1. Install”deedglass isn’t on PyPI yet. Until it is, install it from the repository:
pip install "deedglass @ git+https://github.com/deedglass/deedglass#subdirectory=sdk/python"Each GitHub release also has the wheel. The client has one dependency, httpx. Extras: crypto for offline deed checks and signed intents, langchain and claude-agent-sdk for the adapters (deedglass[crypto] @ git+…).
2. Configure
Section titled “2. Configure”export DEEDGLASS_API_KEY="$(cat .deedglass/quickstart.key)"export DEEDGLASS_SERVER=http://127.0.0.1:80803. Send an action
Section titled “3. Send an action”from deedglass import Deedglass, PolicyDeniedError
with Deedglass() as dg: # reads DEEDGLASS_API_KEY and DEEDGLASS_SERVER try: dg.act("postgres.execute", {"sql": "DROP TABLE public.orders"}) except PolicyDeniedError as e: print("blocked:", e.message)
action = dg.act( "postgres.execute", {"sql": "UPDATE public.orders SET status = 'shipped' WHERE id = 42"}, wait_for_approval=120, ) print(action)The DROP raises PolicyDeniedError with the policy’s own sentence. The UPDATE waits up to 120 seconds for a person to approve it (under postgres-safe), runs, and prints a line like act_… · postgres.execute · executed · L2 · VERIFIED · deed_….
AsyncDeedglass has the same methods with await.
4. Read the verdict
Section titled “4. Read the verdict”A MISMATCH is not an exception: the action ran and the Witness found a difference. Check it:
from deedglass import Deedglass
dg = Deedglass()action = dg.act("postgres.execute", {"sql": "UPDATE public.orders SET status = 'shipped' WHERE id = 42"})if action.witness and action.witness.verdict == "MISMATCH": print("Postgres changed something else:", action.witness.summary)What it doesn’t do
Section titled “What it doesn’t do”- The SDK asks before your function runs and reports what happened. It doesn’t sandbox your function.
- It doesn’t retry a 500: the server stores that answer under the request’s Idempotency-Key and would replay it.
- The Python OpenAI Agents and CrewAI adapters aren’t built yet (0.2.1). Importing them raises
ImportErrorsaying so. The TypeScript SDK has an OpenAI Agents adapter.
- Python SDK reference: every method, the adapters and the error classes.
- What Matches means