Skip to content

Repository files navigation

sidclaw

PyPI versionLicense: Apache-2.0Python

Python SDK for SidClaw — governance for AI agents.

Identity. Policy. Approval. Trace. Four primitives that give you control over what your AI agents can do.

Install

pip install sidclaw

Quick Start

fromsidclawimportSidClawclient=SidClaw(api_key="ai_...", agent_id="your-agent-id")
# Evaluate an action against the policy enginedecision=client.evaluate({
"operation": "send_email",
"target_integration": "email_service",
"resource_scope": "outbound_email",
"data_classification": "confidential",
})
ifdecision.decision=="allow":
send_email(...)
client.record_outcome(decision.trace_id, {"status": "success"})
elifdecision.decision=="approval_required":
approval=client.wait_for_approval(decision.approval_request_id)
ifapproval.status=="approved":
send_email(...)
client.record_outcome(decision.trace_id, {"status": "success"})
elifdecision.decision=="deny":
print(f"Denied: {decision.reason}")

Governance Decorator

fromsidclawimportSidClawfromsidclaw.middlewareimportwith_governance, GovernanceConfigclient=SidClaw(api_key="ai_...", agent_id="your-agent-id")
@with_governance(client, GovernanceConfig(operation="send_email",target_integration="email_service",data_classification="confidential",))defsend_email(to: str, subject: str, body: str) ->None:
email_service.send(to=to, subject=subject, body=body)
send_email("customer@example.com", "Follow-up", "Hello...")
# allow -> executes immediately# approval_required -> waits for human approval, then executes# deny -> raises ActionDeniedError

Async

fromsidclawimportAsyncSidClawasyncwithAsyncSidClaw(api_key="ai_...", agent_id="...") asclient:
decision=awaitclient.evaluate({
"operation": "send_email",
"target_integration": "email_service",
"resource_scope": "outbound_email",
"data_classification": "confidential",
})

Framework Integrations

pip install sidclaw[langchain] # LangChain
pip install sidclaw[crewai] # CrewAI
pip install sidclaw[openai-agents] # OpenAI Agents SDK
pip install sidclaw[pydantic-ai] # Pydantic AI
pip install sidclaw[mcp] # MCP governance proxy
pip install sidclaw[all] # Everything

LangChain

fromsidclaw.middleware.langchainimportgovern_toolsgoverned=govern_tools(my_tools, client=client)
agent=create_react_agent(llm, governed)

CrewAI

fromsidclaw.middleware.crewaiimportgovern_crewai_toolgoverned_tool=govern_crewai_tool(my_tool, client=client)

OpenAI Agents SDK

fromsidclaw.middleware.openai_agentsimportgovern_function_tooltool, handler=govern_function_tool(tool_def, my_handler, client=async_client)

MCP Governance Proxy

fromsidclaw.mcpimportGovernanceMCPServer, GovernanceMCPServerConfigserver=GovernanceMCPServer(GovernanceMCPServerConfig(
api_key="ai_...",
agent_id="agent-001",
upstream_command="npx",
upstream_args=["-y", "@modelcontextprotocol/server-postgres", "postgresql://..."],
))
awaitserver.start()

Or use the CLI:

SIDCLAW_API_KEY=ai_... SIDCLAW_AGENT_ID=agent-001 \
SIDCLAW_UPSTREAM_CMD=npx SIDCLAW_UPSTREAM_ARGS="-y,@modelcontextprotocol/server-postgres,postgresql://..." \
sidclaw-mcp-proxy

Webhook Verification

fromsidclawimportverify_webhook_signatureis_valid=verify_webhook_signature(
payload=request.body,
signature=request.headers["X-Webhook-Signature"],
secret="whsec_...",
)

Error Handling

fromsidclawimportActionDeniedError, ApprovalTimeoutError, RateLimitErrortry:
decision=client.evaluate(...)
exceptActionDeniedErrorase:
print(f"Denied: {e.reason}, trace: {e.trace_id}")
exceptRateLimitErrorase:
print(f"Rate limited, retry after {e.retry_after}s")
exceptApprovalTimeoutErrorase:
print(f"Approval timed out for {e.approval_request_id}")

Links

About

Python SDK for SidClaw — governance for AI agents

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages