Quickstart: LangGraph
Esta página aún no está disponible en tu idioma.
Use the traces your LangGraph agent emits to test its behavior in Mibo. You instrument an order-support graph with OpenInference, export one trace over OpenTelemetry, and write your first tool-call test.
Before you start
Section titled “Before you start”- A Mibo account with a verified email. Open the verification link in the browser you signed up with.
- Python 3.14 and uv.
- An OpenAI API key with access to GPT-5.4 mini.
Tested with Python 3.14.10 and the package versions pinned below.
1. Create a Mibo API key
Section titled “1. Create a Mibo API key”Open the verification link in the browser you signed up with. If you open it in a browser where Mibo can’t confirm the signup, Mibo asks you to choose a new password and revokes the API keys of workspaces you own. If you own the workspace, create an API key in Settings and copy it. Mibo shows the key only once. If you’re a workspace member, ask the owner for a key.
This example sets service.name to langgraph-support. With a workspace key, Mibo creates an Agent with that name on the first trace if your plan has a free slot. A key scoped to one Agent sends traces to that Agent. See trace routing.
2. Install and configure OpenInference
Section titled “2. Install and configure OpenInference”Run these commands in a new project directory.
uv venv --python 3.14uv pip install langgraph==1.2.24 langchain-core==1.8.4 langchain-openai==1.8.5 \ openinference-instrumentation-langchain==0.1.89 opentelemetry-sdk==1.45.2 \ opentelemetry-exporter-otlp-proto-http==1.45.2Set the exporter and model credentials in the same shell.
export OTEL_SERVICE_NAME=langgraph-supportexport MIBO_OTLP_TRACES_ENDPOINT=https://api.mibo-ai.com/public/tracesexport MIBO_API_KEY='<YOUR_MIBO_API_KEY>'export OPENAI_API_KEY='<YOUR_OPENAI_API_KEY>'The Python example uses OTLP/HTTP protobuf. It passes the full traces endpoint and the x-api-key header directly to the Mibo exporter.
The LangChain OpenInference instrumentor captures LangGraph runs, including LangChain model and tool calls. If your app already emits OpenLLMetry traces, you can use the exporter in the OpenLLMetry quickstart.
3. Send your first trace
Section titled “3. Send your first trace”Save the following as agent.py.
import asyncioimport os
from langchain_core.messages import AIMessage, HumanMessagefrom langchain_core.tools import toolfrom langchain_openai import ChatOpenAIfrom langgraph.graph import START, MessagesState, StateGraphfrom langgraph.prebuilt import ToolNode, tools_conditionfrom openinference.instrumentation.langchain import LangChainInstrumentorfrom opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporterfrom opentelemetry.sdk.resources import Resourcefrom opentelemetry.sdk.trace import TracerProviderfrom opentelemetry.sdk.trace.export import BatchSpanProcessor
provider = TracerProvider( resource=Resource.create({"service.name": os.environ["OTEL_SERVICE_NAME"]}),)provider.add_span_processor( BatchSpanProcessor( OTLPSpanExporter( endpoint=os.environ["MIBO_OTLP_TRACES_ENDPOINT"], headers={"x-api-key": os.environ["MIBO_API_KEY"]}, timeout=10, ) ))LangChainInstrumentor().instrument(tracer_provider=provider)
@toolasync def lookup_order(order_id: str) -> dict[str, str]: """Look up an order by ID.""" return {"order_id": order_id, "status": "shipped", "eta": "Friday"}
model = ChatOpenAI(model="gpt-5.4-mini", timeout=20, max_retries=0).bind_tools( [lookup_order])
async def call_model(state: MessagesState) -> dict[str, list[AIMessage]]: return {"messages": [await model.ainvoke(state["messages"])]}
async def main() -> None: builder = StateGraph(MessagesState) builder.add_node("assistant", call_model) builder.add_node("tools", ToolNode([lookup_order])) builder.add_edge(START, "assistant") builder.add_conditional_edges("assistant", tools_condition) builder.add_edge("tools", "assistant") agent = builder.compile(name="support_agent")
result = await agent.ainvoke( {"messages": [HumanMessage(content="Use lookup_order to check order A-1042.")]}, config={"recursion_limit": 5}, ) print(result["messages"][-1].text)
try: asyncio.run(main())finally: provider.force_flush() provider.shutdown()Run the script.
uv run --no-project python agent.pyThe script prints the model’s reply, for example Your order A-1042 has shipped and should arrive on Friday. Before the script exits, force_flush() exports buffered spans and shutdown() closes the provider.
Open Traces and select the Agent that received the trace by its current name. If Mibo created the Agent for this example, its initial name is langgraph-support. Open the order trace. If the model called lookup_order, it appears under What the agent did. Click View raw trace data to inspect the ChatOpenAI model spans.
4. Create your first test
Section titled “4. Create your first test”- Wait for the order trace to finish, then click Create test from this trace.
- Open Draft if the editor shows tabs. Set Name to
Looks up the orderand clear Checks a trace when so the test checks each new trace for this Agent. - Keep the Tool call check. If the draft omits it, choose Tool call from Does check. Set Tool name to
lookup_orderand select Must call. Remove the other checks and click Save test. - Run the script again. Open the new trace on Traces and look under Test results. The check passes when the trace records a call to
lookup_order.
What Mibo reads from the trace
Section titled “What Mibo reads from the trace”| Data | OpenInference attributes |
|---|---|
| User input and final reply | llm.input_messages.* and llm.output_messages.* |
| Requested model | llm.invocation_parameters or llm.model_name |
| Tool name and result | tool.name and output.value on the tool span |
| Tool arguments | The tool_call.function.arguments field of the model’s indexed output message |
OpenInference records this tool’s single string input as plain text on the tool span. The model’s message carries the structured arguments. Use the tool name for this check. Review Data handling before sending traces that contain personal data.
Troubleshooting
Section titled “Troubleshooting”| Problem | Likely cause | Solution |
|---|---|---|
404 or connection error |
Wrong host or path, such as /public/traces/v1/traces |
Set MIBO_OTLP_TRACES_ENDPOINT to https://api.mibo-ai.com/public/traces. |
KeyError: 'MIBO_API_KEY' or HTTP 401 |
Missing, invalid, or revoked key | Set MIBO_API_KEY before running the script. Ask the workspace owner to check whether the key is active. |
HTTP 401 with API_KEY_EXPIRED in the message |
The API key expired | Set MIBO_API_KEY to an active key and rerun the script. |
| Export fails with a gRPC transport error | The exporter uses OTLP/gRPC | Import the exporter from opentelemetry.exporter.otlp.proto.http.trace_exporter for OTLP/HTTP protobuf. |
KeyError: 'OTEL_SERVICE_NAME' or HTTP 400 with a message beginning OTLP traces need the 'service.name' resource attribute |
OTEL_SERVICE_NAME is unset, or Mibo can’t infer the Agent from the exported resource |
Set OTEL_SERVICE_NAME to the Agent’s service name and pass it as a resource attribute as shown above. |
| The script prints a reply but no trace appears | The process exits with spans still buffered | Call provider.force_flush() after the graph finishes and provider.shutdown() before exit. Check exporter errors if the trace is still missing. |
403 AGENT_LIMIT_REACHED |
service.name is new and your plan’s Agent limit is reached |
Use an existing Agent or free capacity for a new one. See Agent limit reached. |
403 UNVERIFIED_TRACE_LIMIT_REACHED |
The owner’s email is not verified and the workspace stores 1,000 traces | Verify the email, then resend the trace. |
| HTTP 403 with “Monthly trace ingestion limit reached” in the message | Your workspace has used its monthly trace quota | Wait for the next usage period or upgrade. Once capacity returns, rerun the script or resend the rejected payload. |
| Export succeeds but the trace is hidden or tool calls are missing | Content capture is off, or the instrumentation emits an unsupported set of attributes | Check your capture settings and the supported trace dialects. Use OpenInference or OpenLLMetry. |
What’s next
Section titled “What’s next”- Assertion reference for checks you can add to your test.
- OpenInference quickstart to connect another app that emits OpenInference traces.
- OpenTelemetry (OTLP) for routing, batching, and response codes.
- Collector fan-out to send a copy of your existing traces to Mibo.