Verifiable decision evidence for Claude agent actions.
Keep your Claude Agent SDK tools and MCP connections. LoopGrid attaches decision-scoped policy and approval evidence to native tool hooks, prevents unauthorized execution and records the verified evidence of what ran and what happened afterward.
loopgrid-claude-agent==0.1.0 · Python 3.12 and Claude Agent SDK 0.2.165 validated · LoopGrid SDK 0.8.0 · Core 0.8.1-design-partner.
PreToolUse authorizationPostToolUse + actual receiptClaude remains native. Evidence becomes verifiable. LoopGrid Core signs and chains the captured record; the host supplies trustworthy reviewer and downstream-outcome evidence.
Install the native Claude Agent SDK integration.
pip install loopgrid-claude-agent==0.1.0
For Python 3.11+, this package depends on claude-agent-sdk>=0.2.165,<0.3 and loopgrid>=0.8.0,<0.9. Point it at a LoopGrid Core workspace; no changes to Claude's model or MCP tools are required. The published source repository ↗ includes sandbox examples and a security contract.
Bind one authorized action to Claude's native hooks.
Your trusted application starts the decision with the exact tool name and expected arguments. The policy verdict belongs to your application, not to Claude's response. The example below assumes a running LoopGrid Core and a workspace you have already created.
from loopgrid import LoopGrid
from loopgrid_claude_agent import LoopGridClaudeAgent
workspace_id = "YOUR_EXISTING_WORKSPACE_ID"
core = LoopGrid(base_url="http://127.0.0.1:8000", workspace_id=workspace_id)
bridge = LoopGridClaudeAgent(client=core, workspace_id=workspace_id, agent_id="refund-agent")
decision_id = bridge.start_decision(
decision_type="refund_simulation",
agent={"id": "refund-agent", "version": "1"},
authority={"acting_for": "sandbox", "scope": ["refund:simulate"]},
model={"provider": "anthropic", "name": "claude-agent-sdk"},
context={"prompt_version": "refund-v1"},
proposed_action={
"tool": "mcp__loopgrid_sandbox__sandbox_refund",
"arguments": {"amount": 25},
},
policy={"policy_id": "refund-policy", "version": "1", "decision": "auto_allowed"},
)["decision_id"]
hooks = bridge.hooks(decision_id)
# Provide your application's in-process MCP server to the native SDK options.
options = hooks.options(mcp_servers={"loopgrid_sandbox": your_mcp_server})
your_mcp_server is a placeholder for the in-process MCP server your application provides. For full workspace setup, a real MCP sandbox tool and signed verification assertions, see the complete Claude runtime example ↗. It requires authenticated Claude API access and available credits.
from claude_agent_sdk import ClaudeSDKClient
async with ClaudeSDKClient(options=options) as agent:
await agent.query("Simulate the authorized refund once using the sandbox tool.")
async for message in hooks.observe_messages(agent.receive_response()):
pass
# Separately verify an actual receipt from the downstream sandbox ledger.
bridge.record_observed_outcome(
decision_id,
observer="sandbox-ledger",
receipt_id=verified_receipt["id"],
outcome=verified_receipt,
)
record = bridge.get_decision(decision_id)
print(record["verification"]["valid"])verified_receipt must come from your actual sandbox or system-of-record response. Do not treat Claude's message as independent proof of an external action. Use the deterministic Core-backed hook example ↗ when you want to test without Claude API credits.
Enforce before execution. Record what happened after.
start_decision() creates decision-scoped authority, arguments and versioned policy evidence in Core.
PreToolUse matches the exact tool name and committed arguments. Unknown, unapproved or repeated calls are denied before execution.
PostToolUse and PostToolUseFailure correlate tool-call IDs with the resulting evidence. Model output is captured separately.
record_observed_outcome() accepts a host-verified receipt after tool-result evidence is persisted; it does not infer success from model text.
LoopGrid Core produces Ed25519-signed, SHA-256-chained evidence for inspection, export and independent verification.
Bring delegated authority and approval to tool execution.
A decision may be auto_allowed, human_approval_required, or blocked. For sensitive actions, your application authenticates the reviewer and records the review with record_human_review(), or supplies a host-owned asynchronous approval_handler returning a ReviewVerdict. A model-generated approval claim cannot substitute for a real reviewer.
Review the native hook / evidence contract ↗ and trust model ↗ for deployment details.
Persist authorization and reconcile uncertain outcomes.
The optional local SQLite mode preserves consumed authorizations and execution claims across worker restarts. It protects against repeated execution attempts and records post-execution evidence-write failures as reconciliation work rather than falsely marking an action complete.
from loopgrid_claude_agent import LoopGridClaudeAgent
bridge = LoopGridClaudeAgent.with_sqlite(
client=core,
workspace_id=workspace_id,
agent_id="refund-agent",
sqlite_path="./loopgrid-claude-authorizations.db",
)
pending = bridge.pending_reconciliations()Tested security behavior and signed LoopGrid Core evidence.
evidence_complete · signed verification validThese security and Core-backed tests use deterministic native hook inputs and safe simulated actions. The separate model-driven Claude → MCP runtime test has not yet completed because the Anthropic account lacked API credits. See the full validation record ↗ for exact test scope.
Keep Claude's tool runtime. Add verifiable decision evidence.
Link the policy, human review, exact tool call, verified downstream receipt and signed evidence to one decision.