Getting Started with LangChain
OpenBox integrates with LangChain by adding middleware to your agent. Your model, tools, prompts, and invocation pattern stay in place while OpenBox adds governance, approvals, guardrails, DID signing, and operational telemetry.
One Middleware Change
- LangChain
- OpenBox
agent.py
from langchain.agents import create_agent
agent = create_agent(
model="openai:gpt-4o",
tools=[search_web, lookup_customer],
)
result = agent.invoke({"messages": [("user", "Check this customer issue")]})
agent.py
import os
from langchain.agents import create_agent
from openbox_langchain import create_openbox_langchain_middleware
middleware = create_openbox_langchain_middleware(
api_url=os.environ["OPENBOX_URL"],
api_key=os.environ["OPENBOX_API_KEY"],
agent_did=os.environ["OPENBOX_AGENT_DID"],
agent_private_key=os.environ["OPENBOX_AGENT_PRIVATE_KEY"],
agent_name="SupportAgent",
)
agent = create_agent(
model="openai:gpt-4o",
tools=[search_web, lookup_customer],
middleware=[middleware],
)
result = agent.invoke({"messages": [("user", "Check this customer issue")]})
Newly created OpenBox agents require DID signing by default. If Require
signing is disabled for the agent, omit agent_did and agent_private_key.
See Agent DID Identity
for the required configuration.
Choose Your Path
LangChain 101
Get the LangChain concepts that matter for OpenBox before you wire governance into a real agent.
Wrap an Existing Agent
Add OpenBox to an existing LangChain codebase without rewriting your model, tools, or prompts.
What OpenBox Captures
From a single middleware integration point, OpenBox captures:
- Agent lifecycle events for each run
- Model call lifecycle events, including token metadata when the provider returns it
- Tool call lifecycle events for governed tool execution
- User prompt signals for auditability
- HTTP, database, file, and traced-function telemetry
- Governance decisions, approvals, and guardrail outcomes
What To Expect In The UI
After integration, OpenBox gives you:
- A run timeline for agent, model, and tool events
- Policy and guardrail decisions on governed boundaries
- Session replay with runtime context
- Model and token usage when provider metadata is available
- Tool health metrics for agents that actually execute tools
Next Steps
- Read LangChain 101 if you want the conceptual model first.
- Use Wrap an Existing Agent if you already have LangChain in production.
- Read LangChain SDK (Python) for the full SDK reference.