Skip to content
OpenEightDeveloper docs
Docs / Start here / Build your first agent
From code to a governed action

Build your first agent

Build a LangChain agent with OpenEight, publish its tools, and govern its first action.

  • Set up the Agent
  • Publish tools
  • Review policies
  • Run and verify

Create your Agent in the Console first

Open agent setup in the Console, choose your integration and name the Agent. Issue an Agent key or use an eligible Workspace identity offered during setup. Copy the environment settings, including the Agent slug. Enter the saved key privately in your local environment file or shell.

Agentic installation

The OpenEight skill helps your coding assistant build a reference agent and publish its tools. During onboarding, review the policy proposed by Assist. Once you accept it, your assistant runs the agent. Review its first approval request in Approvals.

From an empty folder for your agent, give your coding assistant this prompt.

Install the OpenEight skill from https://github.com/OpenEight-Labs/skills
Build a refund agent and walk me through approving its first refund in OpenEight

Manual installation

On this pageCreate your AgentAgentic installationManual installationInstall and configureBuild your agentPublish tools and review the policyRun and verify

1Install and configure

Use a supported Python and LangChain version and have your model-provider key ready.

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>"

Set your connection values

Copy the environment settings from Agent setup and enter your saved key privately in the shell that runs Python.

Terminal
export OPENEIGHT_ENDPOINT='https://app.openeight.ai'
export OPENEIGHT_AGENT_NAME="your-agent-slug"
export OPENEIGHT_API_KEY="<your-agent-api-key>"

If you use a .env file, load it in your application before reading the environment.

2Build your agent

Use Sync for scripts; use Async inside an event loop.

Save this complete program as first_agent.py. It reads the model variables exported in “Configure your model” and the OpenEight connection variables. It does not load a .env file automatically. Use a dedicated test Agent; receipts are simulated in memory and reset on each command.

Pythonfirst_agent.py
"""A simulated USD/EUR refund agent. No payment provider is contacted."""
import argparse
import os
from decimal import Decimal
from typing import Literal

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

class ConfigurationError(ValueError):
    pass

def required_env(name):
    value = os.environ.get(name, "").strip()
    if not value:
        raise ConfigurationError(f"Set {name} in the shell running this program.")
    return value

receipts = []

def refund_create(amount: float, currency: Literal["USD", "EUR"]) -> str:
    """Record a simulated refund. amount is in major units (5 = $5 for USD), with at most two decimal places. currency is USD or EUR. No payment provider is contacted."""
    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("This simulated example supports USD and EUR")
    receipts.append({"amount": amount, "currency": currency, "simulated": True})
    return f"Simulated refund recorded: {currency} {value:.2f}"

def build_agent():
    provider, separator, model_name = required_env("AGENT_MODEL").partition(":")
    if not separator or not provider.strip() or not model_name.strip():
        raise ConfigurationError("Set AGENT_MODEL to provider:model, with both parts present.")
    model_key = required_env("AGENT_MODEL_API_KEY")
    config = OpenEightConfig(
        agent_name=required_env("OPENEIGHT_AGENT_NAME"),
        endpoint=required_env("OPENEIGHT_ENDPOINT"),
        credential=required_env("OPENEIGHT_API_KEY"),
        on_block="raise",
    )
    model = init_chat_model(model_name, model_provider=provider, api_key=model_key)
    tools = [refund_create]
    return create_agent(
        model=model,
        tools=tools,
        system_prompt=(
            "You handle simulated USD and EUR refunds. For a refund request, call refund_create "
            "once with the requested amount in major units and its explicit currency. Interpret "
            "dollars or $ as USD and euros as EUR; ask if the currency is unclear. Never change "
            "the amount or currency to bypass a policy. Report success only after the tool returns a receipt."
        ),
        openeight=config,
    )

def main(command, request):
    agent = build_agent()
    try:
        if command == "publish":
            agent.publish()
            print("Publication finished. Confirm the catalog and activate the policy before running.")
            return 0
        inputs = {"messages": [("user", request)]}
        result = agent.invoke(inputs)
        print("Agent response:", result["messages"][-1].text)
        if not receipts:
            print("No simulated refund was recorded. Check whether the model requested the tool.")
        return 0
    except BlockedError:
        print("Action blocked. Inspect the Decision in OpenEight for the reason.")
        return 1
    finally:
        print("Simulated receipts:", receipts)
        print("Delivery status:", agent.delivery_status())

if __name__ == "__main__":
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument("command", choices=["publish", "run"])
    parser.add_argument("--request", default="Refund $5.")
    args = parser.parse_args()
    try:
        raise SystemExit(main(args.command, args.request))
    except ConfigurationError as error:
        parser.exit(2, f"Configuration error: {error}\n")

3Publish tools and review the policy

Publish the tool from your saved agent so it appears in Console onboarding.

One-time setup
python first_agent.py publish

In Discover tools, check that refund_create is classified as Write. In Confirm intents, check that its rule uses amount and currency.

Example policy intent

Allow USD refunds with an amount greater than 0 and at most 100 inclusive. Require human approval for larger USD refunds or any positive EUR refund. Deny invalid amounts and unsupported currencies.

Amounts use major units, so 5 means USD 5.00 when currency is USD. These are illustrative limits you configure, not built-in refund rules.

Review the onboarding proposal

In Govern tools, review the proposal and generated cases for each write tool. A Workspace Admin or Owner can choose Accept when the results match the intended rule. Tune the proposal if an outcome differs. Read-only tools skip this step.

4Run and verify

Terminal
python first_agent.py run --request 'Refund $500.'

Keep this process running. In Approvals, open the pending request for your Agent. Check that refund_create requests 500 USD. If the details match, approve it.

Return to the same terminal. The agent resumes and prints one simulated receipt for 500 USD.

Missing an approval request or receipt? Troubleshoot your integration →

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.

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.