Making a custom Python step visible in an MLflow trace
GenAI Engineer
Application Development
Medium
Question 37 of 45
A Generative AI Engineer has LangChain autologging enabled, so retriever and LLM spans appear in MLflow traces. A custom Python function that deduplicates and reorders chunks between those calls is invisible in the trace, and it is the suspected cause of bad answers.
How should the engineer make that step visible in the same trace?
Show answer and explanation
DDecorate the custom function with @mlflow.trace and keep autologging
Automatic tracing captures supported library calls and composes with the @mlflow.trace decorator, so custom logic between LLM calls joins the same unified trace. Autologging does not overwrite manual spans, so disabling it removes the retriever and LLM spans rather than adding the missing one. A span deliberately opened as its own root produces a second trace beside the first, which is the fragmentation to avoid. An artifact records the output without placing it in the call sequence.
Source: docs.databricks.com/
Anonymous, no account needed. Your tally stays in this browser.
Practice by topic: RAG questions