Skip to content
OpenEightDeveloper docs
Docs / SDK reference / Allow and deny API demo
SDK integration

Allow and deny API demo

Compare an allowed tool call with a denied call using a simulated refund.

On this page
Complete example

If this demo’s tools are not yet registered, use the publish command for setup. Configure the policy in the console, then run with your test amount.

Policy to configure for this simulated API demo
InputActive rule and expected result
amount = 5 · currency = USDAllow positive USD amounts through 10; one simulated receipt.
amount = 15 · currency = USDDeny USD amounts above 10; no receipt.

Classify the actual catalog entry for refund_create as Write, select amount and currency, and activate a policy that allows positive USD amounts through 10 inclusive and denies everything else. Deep Agents catalog names can differ from native names. These are demonstration limits you configure. Amounts use major units: 5 with USD means USD 5.00. EUR requests are denied by this demonstration policy. Review policy activation →

pip install openeight

Configure your model

Choose your model provider to see its installation command.

pip install langchain-openai
Model credentials

Set AGENT_MODEL to provider:model using a tool-calling model available to your account. Set AGENT_MODEL_API_KEY to that provider’s credential; it is separate from your OPENEIGHT_API_KEY.

Terminal · explicit model configuration
export AGENT_MODEL="openai:<your-tool-calling-model>"
export AGENT_MODEL_API_KEY="<your-model-provider-key>"
Environment · OpenEight connection
export OPENEIGHT_ENDPOINT='https://app.openeight.ai'
export OPENEIGHT_AGENT_NAME="your-agent-slug"
export OPENEIGHT_API_KEY="<your-agent-api-key>"

Save as refund_langchain_sync.py. This file includes all imports and helpers. Effects are simulated; managed examples use the model provider configured above.

Terminal · run the saved file
python refund_langchain_sync.py publish
# Configure policies in the console.
python refund_langchain_sync.py run 5 USD
python refund_langchain_sync.py run 15 USD
Pythonrefund_langchain_sync.py
"""Minimal API demo: refund_create accepts amount in major units and an explicit currency.
For the complete order-based refund scenario, see the Examples guide.
Uses an explicitly configured model provider and simulated receipts.
First-time setup only: python refund_langchain_sync.py publish
Then configure tools/policies in the console.
Run: python refund_langchain_sync.py run 5 USD
"""
import argparse
import os
from decimal import Decimal
from typing import Literal

from langchain.chat_models import init_chat_model
from openeight import OpenEightConfig
from openeight.langchain import create_agent

def build_model():
    provider, separator, model = os.environ["AGENT_MODEL"].partition(":")
    if not separator or not provider.strip() or not model.strip():
        raise ValueError("Set AGENT_MODEL to provider:model")
    api_key = os.environ["AGENT_MODEL_API_KEY"]
    if not api_key.strip():
        raise ValueError("Set AGENT_MODEL_API_KEY explicitly")
    return init_chat_model(model, model_provider=provider, api_key=api_key)

receipts = []

def refund_create(amount: float, currency: Literal["USD", "EUR"]) -> str:
    """Record a simulated refund in major units (5 means 5 dollars for USD); never contact a payment provider."""
    if type(amount) not in (int, float):
        raise ValueError("Expected a numeric amount in major units")
    value = Decimal(str(amount))
    if not value.is_finite() or value <= 0 or value != value.quantize(Decimal("0.01")):
        raise ValueError("Expected a positive amount with at most two decimal places")
    if currency not in ("USD", "EUR"):
        raise ValueError("Expected USD or EUR")
    receipts.append({"amount": amount, "currency": currency, "simulated": True})
    return "Simulated refund recorded"

def main(command, amount, currency):
    model = build_model()  # Explicit application-owned model/provider configuration.
    openeight_config = OpenEightConfig(
        agent_name=os.environ["OPENEIGHT_AGENT_NAME"],
        endpoint=os.environ["OPENEIGHT_ENDPOINT"],
        credential=os.environ["OPENEIGHT_API_KEY"],
    )
    agent = create_agent(model=model, tools=[refund_create], openeight=openeight_config)
    if command == "publish":
        agent.publish()
    else:
        agent.invoke({"messages": [("user", f"Simulate a refund of {amount} {currency} in major units using refund_create. Preserve the requested amount and currency; never change them to bypass policy.")]})
        print("Simulated receipts:", receipts)
        print(agent.delivery_status())

if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("command", choices=["publish", "run"])
    parser.add_argument("amount", type=float, nargs="?", default=5)
    parser.add_argument("currency", choices=["USD", "EUR"], nargs="?", default="USD")
    args = parser.parse_args()
    main(args.command, args.amount, args.currency)
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.