fix(llmobs): prevent evaluator spans from leaking into experiments index#17172
Draft
FouadWahabi wants to merge 1 commit intomainfrom
Draft
fix(llmobs): prevent evaluator spans from leaking into experiments index#17172FouadWahabi wants to merge 1 commit intomainfrom
FouadWahabi wants to merge 1 commit intomainfrom
Conversation
Codeowners resolved as |
1506319 to
a584393
Compare
Clear trace context between task and evaluator execution so that LLM spans created inside evaluators don't inherit the experiment span's baggage and get incorrectly routed to the experiments index.
a584393 to
908beb2
Compare
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.
Summary
_clear_trace_context()call between task and evaluator execution in_process_and_evaluateto clear both the default tracer and LLMObs context providersscope=experimentswhile evaluator spans do notRoot Cause
In
_run_tasks_with_evaluators, the_process_and_evaluatecoroutine runs_process_record(task) and_evaluate_record(evaluators) sequentially within the same asyncio Task. The experiment span created during task execution setsEXPERIMENT_ID_KEYas baggage on its trace context. After the experiment span finishes, the trace context may still carry this baggage when evaluator code runs, causing any LLM spans created by evaluators to inherit thescope=experimentsattribute and get routed to the wrong index.Test plan
test_experiment_evaluator_spans_not_in_experiments_scopeverifies task spans havescope=experimentswhile evaluator spans do not