Skip to main content

SDK API

This is the canonical reference for the Python SDK. For tutorial-style introductions see Quickstart; for framework-specific patterns see the Framework adapters.

arclasp.init()

Configure the SDK. Call once at application startup before opening any chains.
Required Common Failure handling Policy thresholds Privacy Performance

Returns

A ChainConfig instance. Configuration is also stored globally for the process so subsequent arclasp.Chain(...) calls use it.

Sanitization defaults

The SDK uses two separate default lists for redacting sensitive data: sensitive_field_patterns (default — matches against dict keys by case-insensitive substring):
sensitive_value_patterns (default — matches against string values using str.startswith()):
Custom patterns you pass via the corresponding kwarg are appended to the defaults.

arclasp.Chain

Context manager that opens a chain and records every action within it. Use as an async or sync context manager depending on your code.

Constructor parameters

Lifecycle

On __aenter__ / __enter__: a chain record is created on the backend; the chain ID is available as chain.chain_id after entry. On __aexit__ / __exit__: the SDK calls POST /v1/chains/{chain_id}/complete, which seals the chain and triggers receipt generation on the backend. If exit was triggered by an exception, the chain is marked accordingly and the receipt reflects the failure mode.

Methods

record_agent_action() (async)

Record an action and receive a policy decision. There is no metadata parameter on this method — action-level metadata is not currently supported; chain-level metadata is set once on Chain(...). Returns a PolicyDecision object with policy_decision="allow". Blocks until resolution on require_approval (returns allow with decision_source="human_approval" once approved). Raises ActionDeniedError on deny or human denial, ChainTimeoutError if the local polling window expires, and ChainAutoPausedError if the backend halts the chain for a runaway-limit trigger.

chain.chain_id

The backend-assigned chain UUID. Available after __aenter__ / __enter__. Useful for logging or cross-system references:

arclasp.PolicyDecision

Returned by record_agent_action when the action is allowed (including after a human approval resolves).

Framework adapters

Each adapter exposes a govern() function that wraps an existing framework object. See the framework-specific pages for usage details.

arclasp.langgraph.govern()

See LangGraph adapter.

arclasp.langchain.govern()

The agent_name for recorded events is derived from type(executor).__name__ at wrap time — it isn’t a govern() parameter. See LangChain adapter.

arclasp.crewai.govern()

See CrewAI adapter.

arclasp.mcp.ArclaspMcpAdapter

install() is not supported with mcp >= 1.0 and always raises RuntimeError; it is kept only for signature compatibility. Wire governance through handle_tool_call() inside your own @server.call_tool() handler instead. See MCP adapter.

arclasp.client.verify_receipt_v2()

Verify receipt integrity through the authenticated v2 API.
Receipt verification is server-attested integrity verification. It is not an independent offline proof export.

arclasp.client.verify_approval_v2()

Verify an approval through the authenticated role-aware v2 API.
The response separates integrity, signature, key-trust, timestamp-anchor, and overall status. Member and admin responses differ based on role.

Public verification token helpers

issue_public_verification_token() returns the plaintext public token once. List and revoke helpers do not return plaintext tokens or token hashes. verify_public_token() calls GET /public/v2/verify/{opaque_token} and raises a sanitized verification error if the token is unavailable.

arclasp.client.verify_receipt()

Legacy receipt verification helper.
This helper remains temporarily available for compatibility with the legacy GET /v1/receipts/{receipt_id}/verify route and emits a deprecation warning. New callers should use verify_receipt_v2().

See Verification for current verification routes and migration guidance.

Exceptions

All exceptions live in arclasp.exceptions. The base for policy-driven errors is ArclaspPolicyError.
See Exceptions reference for attributes and handling patterns.

Version compatibility

The SDK requires Python 3.10 or later (enforced at install time by pip). Supported framework version ranges are pinned in sdk/pyproject.toml; install Arclasp with a compatible version of your framework already installed. See Limitations for the current compatibility matrix.

Where to go next

Configuration

Detailed walkthrough of every init() option.

Exceptions

All exception types and how to handle them.

Framework adapters

Per-framework usage and edge cases.

Limitations

What Arclasp does and doesn’t do at current version.