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.
Manual installation
On this page
Create your AgentAgentic installationManual installationInstall and configureBuild your agentPublish tools and review the policyRun and verify1Install and configure
Use a supported Python and LangChain version and have your model-provider key ready.
pip install openeightConfigure your model
Choose your model provider to see its installation command.
pip install langchain-openaiSet 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.
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.
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.
"""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.
python first_agent.py publishIn Discover tools, check that refund_create is classified as Write. In Confirm intents, check that its rule uses amount and currency.
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.
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
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 →
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.
Email us at hello@openeight.ai.