[mason] Fix agent-langgraph template dropping LangGraph/tool spans from traces - #546
Open
jamesbxwu wants to merge 1 commit into
Open
[mason] Fix agent-langgraph template dropping LangGraph/tool spans from traces#546jamesbxwu wants to merge 1 commit into
jamesbxwu wants to merge 1 commit into
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
agent-langgraphtemplate produces malformed MLflow traces: the trace shows only the runtime's per-request root span, with the entire LangGraph subtree - model calls, thetoolsnode, and the individual tool spans - missing. Tool calls never appear grouped under the root span.Root cause
agent/agent.pyimportedconfigure_tracingfrom the top-leveldatabricks_mason:That resolves to the framework-neutral
runtime.tracing.configure_tracing(autolog=None). With noautologbound, it enables tracing (a destination + experiment are configured) but never callsmlflow.langchain.autolog().runtime.pystill 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-openaitemplate already importsconfigure_tracingfromdatabricks_mason.openai(which bindsmlflow.openai.autolog). This brings the langgraph template in line by importing fromdatabricks_mason.langgraph(which bindsmlflow.langchain.autolog).Fix
configure_tracingfromdatabricks_mason.langgraphinstead of the neutral top-level one.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:
After: full nested tree:
Template test suite: 16 passed, 1 skipped (the live model test).
This pull request and its description were written by Isaac.