Skip to content

[mason] Fix agent-langgraph template dropping LangGraph/tool spans from traces - #546

Open
jamesbxwu wants to merge 1 commit into
mainfrom
mason-fix-langgraph-tracing-autolog
Open

[mason] Fix agent-langgraph template dropping LangGraph/tool spans from traces#546
jamesbxwu wants to merge 1 commit into
mainfrom
mason-fix-langgraph-tracing-autolog

Conversation

@jamesbxwu

Copy link
Copy Markdown

Problem

The agent-langgraph template produces malformed MLflow traces: the trace shows only the runtime's per-request root span, with the entire LangGraph subtree - model calls, the tools node, and the individual tool spans - missing. Tool calls never appear grouped under the root span.

Root cause

agent/agent.py imported configure_tracing from the top-level databricks_mason:

from databricks_mason import configure_tracing, ...

That resolves to the framework-neutral runtime.tracing.configure_tracing(autolog=None). With no autolog bound, it enables tracing (a destination + experiment are configured) but never calls mlflow.langchain.autolog(). runtime.py still opens its manual per-request span, so a trace is produced - but nothing emits the LangGraph/LangChain spans, leaving a single-span trace.

The sibling agent-openai template already imports configure_tracing from databricks_mason.openai (which binds mlflow.openai.autolog). This brings the langgraph template in line by importing from databricks_mason.langgraph (which binds mlflow.langchain.autolog).

Fix

  • Import configure_tracing from databricks_mason.langgraph instead of the neutral top-level one.
  • Add a hermetic regression test asserting configure_tracing() enables LangChain autologging when tracing is configured. It fails on the old import and passes on the fix.

Verification (end-to-end, live workspace)

Ran the actual template server against a live workspace with MLflow tracing to a real experiment and a real tool-calling model.

Before: trace had a single span:

stream_handler

After: full nested tree:

stream_handler
  └ LangGraph
      ├ model → _RoutedChatDatabricks
      ├ tools → get_current_time      ← tool call now under the root
      └ model → _RoutedChatDatabricks

Template test suite: 16 passed, 1 skipped (the live model test).

This pull request and its description were written by Isaac.

…om traces

The agent-langgraph template imported `configure_tracing` from the top-level
`databricks_mason`, which resolves to the framework-neutral
`runtime.tracing.configure_tracing(autolog=None)`. With no autolog bound, it
turns tracing on (a destination + experiment are set) but never calls
`mlflow.langchain.autolog()`. The runtime still opens its manual per-request
span, so a trace appears - but it contains only that one span. The entire
LangGraph subtree (model calls, the `tools` node, and the individual tool
spans) is never recorded, so tool calls never show up under the root span.

Import `configure_tracing` from `databricks_mason.langgraph` instead, which
binds `mlflow.langchain.autolog`. The sibling agent-openai template already
imports it from `databricks_mason.openai` - this brings the langgraph
template in line.

Verified end-to-end against a live workspace with MLflow tracing: before the
fix the trace had a single `stream_handler` span; after, the full nested tree
(`stream_handler -> LangGraph -> model/tools -> get_current_time`).

Adds a hermetic regression test asserting `configure_tracing()` enables
LangChain autologging when tracing is configured; it fails on the old import
and passes on the fix.

Co-authored-by: Isaac <no-reply@databricks.com>
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