Claude SDK Integration
Installation
pip install nomotic anthropicPattern
Example
import anthropic
from nomotic import GovernanceRuntime
from nomotic.governed_agent import GovernedAgentBase, GovernanceVetoError
from nomotic.authority import CertificateAuthority
from nomotic.keys import SigningKey
from nomotic.store import MemoryCertificateStore
# Set up Nomotic governance
runtime = GovernanceRuntime()
runtime.configure_scope(
agent_id="claude-agent",
scope={"read", "write", "query", "send"},
boundaries={"customer/*", "internal/*"},
)
store = MemoryCertificateStore()
sk, _vk = SigningKey.generate()
ca = CertificateAuthority("local-issuer", sk, store)
cert, _ = ca.issue(
agent_id="claude-agent",
archetype="customer-experience",
organization="acme-corp",
)
agent = GovernedAgentBase(runtime=runtime, certificate=cert)
# Set up Anthropic client
client = anthropic.Anthropic()
def governed_claude_call(
prompt: str,
action_type: str = "query",
target: str = "internal/knowledge",
) -> str:
"""Make a governed Claude API call."""
try:
return agent.governed_run(
action_type=action_type,
target=target,
execute_fn=lambda: client.messages.create(
model="claude-sonnet-4-6",
max_tokens=1024,
messages=[{"role": "user", "content": prompt}],
).content[0].text,
)
except GovernanceVetoError as e:
return f"[GOVERNANCE VETO] {e.verdict} (UCS: {e.ucs_score:.3f})"
# Use it
response = governed_claude_call(
prompt="Summarize the customer's recent orders",
action_type="read",
target="customer/orders",
)
print(response)Tool Use with Governance
Last updated

