Skip to content
OpenEightDeveloper docs
Docs / SDK reference / Direct SDK reference
SDK integration

Direct SDK reference

Register tools, authorize attempts and report execution with a direct client.

On this pageDirect clientsRuns and EventsCreate a machine clientRegister native factsRead the current policy contractPrepare one immutable attemptAuthorize, then executeReport executionApproval and retryComplete the Run

Direct clients

Python Client(base_url, *, api_key, agent_name) is synchronous. After OpenEight acknowledges tool registration, pass the returned tool version IDs to get_tool_readiness. Use collect_selected_values to extract the tool inputs required by the active policies.

Need help connecting your agent?

Tell us which framework you use and how your agent runs. We’ll help you choose the integration approach. Keep credentials and private application data out of your message.

Client constructor parameters →

Runs and Events

Managed integrations report Runs and supported tool Events automatically. Direct integrations own Run identity, Event submission and delivery. Buffered telemetry is not crash-durable.

Continuation inside execute_attempt, after its authorization and identity checks have passed. Use the guarded helper; never call the effect from this fragment without those checks.

PythonReport the authorized execution
effect(json.loads(retained))  # Detached view of the same complete snapshot, never caller-owned input.
run.submit_event(Event(name=tool.name, observation_kind="tool_call", operation_kind="invoke",
    occurred_at=datetime.now(timezone.utc), outcome="success", decision_id=decision.decision_id,
    tool_id=tool.id, tool_version_id=version.id, tool_name=tool.name,
    input={"input": prepared["input"], "policy_contract_set_digest": prepared["policy_contract_set_digest"], "selected_values": prepared["selected_values"]}))
run.flush()  # Acknowledgment, not permission to repeat the effect on failure.

Expected result · The Event carries the same Decision, Run, tool version and selected policy inputs. A delivery failure must not trigger another effect.

Create a machine client

Use synchronous Python Client on the server. Machine credentials identify the Agent; they never create a human console Session. The client does not invoke your business function.

  1. Register tools and retain the acknowledged ToolVersion IDs.
  2. Read exact-version readiness and freeze the native arguments for one attempt.
  3. Request authorization; if approval is required, wait and replay that same request.
  4. Execute only after the authorization checks pass, then report the correlated Event.
  5. Settle delivery and complete the Run without repeating the effect.

Register native facts

Register name, description and JSON input schema; inspect every registration result and retain acknowledged Tool/ToolVersion IDs. The direct example deliberately calls its catalog tool refund.create, while the local function is refund_create. Reject partial or conflicted registration.

Excerpt from the complete simulated-refund API demo. Keep its imports, helper functions and validation together. This fragment is not a standalone authorization boundary.

PythonInside main · register tools
results = client.register_tools([ToolRegistration(name="refund.create", description="Simulate a refund in whole major units with an explicit currency", input_schema=SCHEMA)])
if len(results) != 1 or results[0].status not in ("registered", "replayed") or results[0].tool is None or results[0].tool_version is None:
    raise RuntimeError("Tool publication not acknowledged; reconcile in console")
tool, version = results[0].tool, results[0].tool_version
print("Published:", tool.name, tool.id, version.id)
if command == "publish":
    return

Expected result · Retain the acknowledged ToolVersion before reading readiness.

Read the current policy contract

Request exact-version readiness and require the configured executable contract before preparing a write. Console configuration owns selectors and policies. These programmatic checks protect execution; they are not another onboarding screen or authorization by themselves.

Excerpt from the complete simulated-refund API demo. Keep its imports, helper functions and validation together. This fragment is not a standalone authorization boundary.

PythonInside main · require policy readiness
readiness = client.get_tool_readiness(tool_version_ids=[version.id])
contracts = [c for c in readiness.tools if c.tool_id == tool.id and c.tool_version_id == version.id]
if len(contracts) != 1 or not contracts[0].eligible or not contracts[0].policy_ready or contracts[0].reason != "ready" or not contracts[0].policy_contract_set_digest:
    raise RuntimeError("Configure this exact ToolVersion in console before running")

Expected result · Missing or unready exact-version contracts stop execution.

Prepare one immutable attempt

Before any asynchronous authorization, deep-snapshot all native arguments into private retained state. Derive the minimal selected native path/value union from that snapshot, send input: {}, and retain the contract digest. Execute only a detached view of those same retained arguments, never a caller object read after a wait.

Python retains explicit Run/Decision IDs and source time for Client.decide. The selected-value helper alone does not freeze all unselected business arguments. Reject unsnapshotable values; never fall back to the original mutable object.

Excerpt from the complete simulated-refund API demo. Keep its imports, helper functions and validation together. This fragment is not a standalone authorization boundary.

PythonSnapshot arguments before preparing authorization
retained = snapshot_arguments(arguments)  # Before projection or any wait; never log this.
prepared = dict(decision_id=uuid7(), run_id=run.run_id,
    source_time=datetime.now(timezone.utc).isoformat(), tool_id=tool.id,
    tool_version_id=version.id, input={},
    policy_contract_set_digest=contract.policy_contract_set_digest,
    selected_values=collect_selected_values(json.loads(retained), contract))
request = json.dumps(prepared, allow_nan=False)  # Private exact request retained alongside arguments.
prepared = json.loads(request)  # Normalize tuple selections to JSON arrays for Event input.

Expected result · Retain both the full native arguments and the prepared request. Later caller mutations cannot change the authorized effect; retries reuse the same IDs, time and request values.

Authorize, then execute

Only allow or an observed approved state followed by successful exact authorization replay permits the simulated effect. Deny, pending, rejected, expired, dry-run, mismatch and transport failure all produce no effect. Retain the full argument snapshot with the prepared request for continuation.

Excerpt from the complete simulated-refund API demo. Keep its imports, helper functions and validation together. This fragment is not a standalone authorization boundary.

PythonAuthorize, wait, replay and report the same attempt
def execute_attempt(client, run, tool, version, contract, arguments, effect):
    retained = snapshot_arguments(arguments)  # Before projection or any wait; never log this.
    prepared = dict(decision_id=uuid7(), run_id=run.run_id,
        source_time=datetime.now(timezone.utc).isoformat(), tool_id=tool.id,
        tool_version_id=version.id, input={},
        policy_contract_set_digest=contract.policy_contract_set_digest,
        selected_values=collect_selected_values(json.loads(retained), contract))
    request = json.dumps(prepared, allow_nan=False)  # Private exact request retained alongside arguments.
    prepared = json.loads(request)  # Normalize tuple selections to JSON arrays for Event input.
    decision = client.decide(**json.loads(request))
    authorized = decision.allowed
    approval_deadline = None
    if decision.needs_approval and decision.decision_id == prepared["decision_id"] and decision.run_id == prepared["run_id"]:
        approval_deadline = time.monotonic() + 30
        while (remaining := approval_deadline - time.monotonic()) > 0:
            state = client.approval_state(decision.decision_id, timeout=remaining)
            remaining = approval_deadline - time.monotonic()
            if remaining <= 0:
                break
            if state == "approved":
                decision = client.decide(**json.loads(request), timeout=remaining)
                authorized = decision.replayed and (decision.allowed or decision.needs_approval)
                break
            if state != "pending":
                break
            time.sleep(min(0.5, remaining))
    matches = decision.decision_id == prepared["decision_id"] and decision.run_id == prepared["run_id"]
    within_budget = approval_deadline is None or time.monotonic() < approval_deadline
    if not (within_budget and matches and authorized):
        print("No simulated effect: blocked, pending, rejected, expired or dry-run")
        return False
    effect(json.loads(retained))  # Detached view of the same complete snapshot, never caller-owned input.
    run.submit_event(Event(name=tool.name, observation_kind="tool_call", operation_kind="invoke",
        occurred_at=datetime.now(timezone.utc), outcome="success", decision_id=decision.decision_id,
        tool_id=tool.id, tool_version_id=version.id, tool_name=tool.name,
        input={"input": prepared["input"], "policy_contract_set_digest": prepared["policy_contract_set_digest"], "selected_values": prepared["selected_values"]}))
    run.flush()  # Acknowledgment, not permission to repeat the effect on failure.
    return True

Expected result · Only an allow, or observed approval followed by a matching successful replay, reaches the simulated effect. Denied, pending, rejected, expired, dry-run and failed revalidation do not execute it.

Report execution

Submit the execution Event with the authorized Decision, Run, Tool, ToolVersion and frozen policy envelope. Queue acceptance is local ownership; flush confirms server acknowledgment. A telemetry error must not cause the effect to run again.

Continuation inside execute_attempt, after its authorization and identity checks have passed. Use the guarded helper; never call the effect from this fragment without those checks.

PythonReport the authorized execution
effect(json.loads(retained))  # Detached view of the same complete snapshot, never caller-owned input.
run.submit_event(Event(name=tool.name, observation_kind="tool_call", operation_kind="invoke",
    occurred_at=datetime.now(timezone.utc), outcome="success", decision_id=decision.decision_id,
    tool_id=tool.id, tool_version_id=version.id, tool_name=tool.name,
    input={"input": prepared["input"], "policy_contract_set_digest": prepared["policy_contract_set_digest"], "selected_values": prepared["selected_values"]}))
run.flush()  # Acknowledgment, not permission to repeat the effect on failure.

Expected result · The Event carries the same Decision, Run, tool version and selected policy inputs. A delivery failure must not trigger another effect.

Approval and retry

Wait using machine approval-state reads. After approved, replay the identical request and check the same Decision/Run IDs. The immutable approval_required verdict plus replayed=true is a valid approved continuation after successful revalidation; there is no approvalState field on DecisionResult.

Transport retries reuse the same IDs, time and bytes. A genuinely new policy contract requires a new attempt. In-memory identity retention is not crash recovery, distributed fencing or exactly-once effects.

Follow the guarded helper rather than implementing a separate approval path.

Expected result · Approval must be observed and the identical request successfully replayed before execution.

Guarded authorization and approval helper →

Complete the Run

Flush and close the Run with its actual lifecycle, then close the client. Keep unresolved identities in application-owned durable state before extending this example to real payments. The complete API demo simulates receipts; it never contacts a payment provider.

Excerpt from the complete simulated-refund API demo. Keep its imports, helper functions and validation together. This fragment is not a standalone authorization boundary.

PythonInside main · complete the Run
run_id, started_at = uuid7(), datetime.now(timezone.utc).isoformat()
receipts = []
with client.governed_run(run_id=run_id, started_at=started_at) as run:
    execute_attempt(client, run, tool, version, contracts[0], {"amount": amount, "currency": currency}, lambda args: receipts.append({**args, "simulated": True}))

Expected result · Python exits the governed_run context after the helper settles. Client cleanup does not promise restart-safe or exactly-once business execution.

OpenEight / Developer docsPython SDK 0.0.1

Search documentation

Build with OpenEightBuild or connect an agent, configure its controls, and inspect its activity.
Build your first agentDefine a model and tools, create an agent with OpenEight, configure policies, and run it.
Connect an existing agentKeep your existing model, tools, and agent logic. Add the OpenEight Python SDK where your agent calls tools so a policy can allow a call, block it, or pause it for approval.
Refund walkthroughSee how OpenEight checks a refund before the tool runs. USD refunds through $100 can proceed. Larger USD refunds and refunds in other currencies wait for a reviewer. All receipts in this walkthrough are simulated.
Integrate LangChainConnect your existing LangChain agent to OpenEight and verify its first governed tool call.
Integrate Deep AgentsConnect your existing Deep Agents agent to OpenEight and verify its first governed tool call.
Custom integrationsUse OpenEight with an Agent that calls tools directly or uses another framework.
Observe without enforcementConnect your Agent’s OpenTelemetry exporter to see Runs and tool activity in OpenEight. Tool calls proceed without policy checks or approval requests.
How governance worksBefore your Agent runs a governed tool, OpenEight checks the request against its active policies.
Prepare tools for governanceCheck how OpenEight classifies your Agent’s tools and confirm the intent Assist will use to draft policies.
Create policies with AssistAssist drafts rules and test cases from a policy intent. Review what the rules allow, deny or hold for approval before activating them.
Handle approvalsReview a pending tool call and decide whether the Agent may continue.
Inspect decisionsSee how your policies applied to a tool call and find out whether it executed.
Inspect runs and eventsOpen a Run to see which tools your Agent called, how long they took, and what status the Agent reported.
Configure model pricingModel rates apply across every Workspace in your organization. OpenEight uses them to calculate spend from recorded usage.
Set Agent budgetsSet cost and token limits for an Agent.
Send approval notifications to SlackSend approval requests to a Slack channel so reviewers can open them in the OpenEight Console.
Export and verify evidenceExport a Workspace evidence bundle, establish trust in its signing key, and verify recorded evidence offline with the OpenEight CLI.
TroubleshootingDiagnose SDK startup, tool publication, approval, and delivery issues.
Calls and sessionsChoose when to open a session and how to manage resources across calls.
Stream results and clean upRead incremental agent results and release resources when a reader stops early.
Threads and checkpointsSave a conversation between calls so your Agent can pick up where it left off.
Delivery and shutdown checksFlush buffered work and inspect delivery before shutdown.
Compatibility and installationFind your integration, supported runtime and SDK version.
ConfigurationConfigure connection settings, approval waiting and content capture.
Constructors and executionCreate an agent and choose its invocation methods.
LangChain optionsLook up structured output, configurable models and LangChain execution limits.
Deep Agents optionsConfigure root and child tools, filesystem permissions and MCP sources.
Tool publication and readinessPublish tool schemas, find acknowledged versions and check policy readiness.
Approval waiting and replayA managed Agent can wait in the running process or return a waiting thread for your code to resume. With a direct Python client, your code polls and replays the request.
Python API signaturesLook up parameters, defaults and return types for OpenEight Python SDK 0.0.1.