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”pip install deedglassThe client has one dependency, httpx. Extras: deedglass[crypto] for offline deed checks and signed intents, deedglass[langchain] and deedglass[claude-agent-sdk] for the adapters.
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 OpenAI Agents and CrewAI adapters come in the next release. Importing them today raises
ImportErrorsaying so.
- Python SDK reference: every method, the adapters and the error classes.
- What VERIFIED means