Set a readable root-span request and response - #31
Open
adamgurary wants to merge 2 commits into
Open
Conversation
Signed-off-by: Adam Gurary <guraryadam@gmail.com>
span.set_outputs() inside a @mlflow.trace body is overwritten by the
decorator after the function exits (last-write-wins). Empirically
confirmed on MLflow 3.11.1.dev0: the old example left root span outputs
at 58k chars. Two correct patterns now shown: update_current_trace
(request_preview/response_preview) for compact Trace list UI previews
while keeping the decorator, and a manual start_span entry point for
compact storage on the root span itself. Also fixes None-safety on
note_text slice: (state.get("note_text") or "")[:200].
Signed-off-by: Adam Gurary <guraryadam@gmail.com>
adamgurary
force-pushed
the
readable-root-span
branch
from
July 30, 2026 23:33
1aa0c12 to
ef4ef3e
Compare
Contributor
Author
|
Hi — just rebased this onto the latest main (was 12 commits behind). The PR adds two reference commits to the |
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.
Fixes #29
Context
This issue is one finding from a hands-on evaluation (a Critical User Journey run) of building, tracing, and improving an agent that runs off Databricks. The agent is a LangGraph rebuild of a customer-notes workflow. It runs on a laptop and calls the Databricks Foundation Model API endpoint
databricks-claude-opus-4-8. Its MLflow traces are written to Unity Catalog.Full writeup:
Environment
Instrumentation skill should produce a readable root-span request and response
Summary
When a coding agent used the MLflow instrumentation skills to trace a LangGraph agent, the top of the trace showed an unreadable blob instead of the run inputs and outputs. The
@mlflow.tracedecorator on the entry point auto-recorded the compiled LangGraph object as the request and the entire final state dict as the response. The root span showed neither the customer name going in nor the note coming out.Steps to reproduce
@mlflow.traceper the skills.Actual behavior
The root-span request was the Python repr of the compiled graph object. The root-span response was the full accumulated state dictionary (transcript plus all research plus draft). Both were unreadable in the UI.
Root cause
The skill applied
@mlflow.traceto a function whose input is a large framework object and whose output is a large state dict, without guiding the agent to record a compact, human-readable summary instead.Expected behavior and proposed fix
The MLflow instrumentation skills should teach the coding agent to set a compact, readable request and response on the root span, rather than letting
@mlflow.tracecapture raw framework objects. For a LangGraph agent, that means the meaningful inputs (the customer and date) and the meaningful outputs (the output path and a short preview). The goal is that the trace reads well in the UI by default.Evidence and references
Fixed in the agent by hand-setting compact root-span fields (commit 64c0d647d). See the walkthrough linked above.