Skip to content

Add agent observability with Monocle#287

Open
Mohammed Ansari (imohammedansari) wants to merge 1 commit into
langchain-ai:mainfrom
imohammedansari:monocle-instrumentation
Open

Add agent observability with Monocle#287
Mohammed Ansari (imohammedansari) wants to merge 1 commit into
langchain-ai:mainfrom
imohammedansari:monocle-instrumentation

Conversation

@imohammedansari

@imohammedansari Mohammed Ansari (imohammedansari) commented Jul 9, 2026

Copy link
Copy Markdown

Summary

Adds Monocle observability to the agent. Monocle is an OpenTelemetry-based tracer for LLM applications. With it enabled, each run is recorded as a structured trace: the agent and graph invocations, tool calls, LLM inferences, token usage, and timings. The change is additive and does not alter application logic.

What this adds

Instrumentation is one setup call plus one dependency:

  • pyproject.toml: adds monocle_apptrace.
  • src/open_deep_research/deep_researcher.py: calls setup_monocle_telemetry(workflow_name="open-deep-research", monocle_exporters_list="file") at startup.

That call auto-instruments the frameworks already in use (LangGraph and the LLM clients), so there is no per-tool or per-call wiring to maintain. Traces are written to .monocle/ by default.

What you get

Each run produces a trace of all the agents that were triggered and the LLM inferences they made. In effect, it's the path the run took to answer the question. This is useful for developers building the agent, since they can see how it actually behaved on a run. The same traces are also a good basis for a behavioral test suite, an integration test that asserts on that behavior, and I've opened a companion PR that shows how that works: behavioral test suite. You can open the trace files directly, view them in the Monocle VS Code extension, or send them to Okahu for analysis across many runs.


Example trace (Okahu VS Code Extension)

The open_deep_research LangGraph workflow, with the researcher agent and its OpenAI-native web search captured as trace spans.

image

PS: if Monocle looks useful, a ⭐ helps the project (https://github.com/monocle2ai/monocle). And if you want to turn these traces into tests, that's the companion PR (#288).

Enable Monocle (OpenTelemetry tracing for LLM apps) with one setup call plus the monocle_apptrace dependency. setup_monocle_telemetry auto-instruments the frameworks already in use and writes traces to .monocle/. Additive; no changes to application logic.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant