Preserve tracker tags when an execution completes - #37
Merged
adham90 merged 1 commit intoJul 30, 2026
Merged
Conversation
build_running_execution_data injects the active tracker's request_id and tags into execution metadata, but build_completion_data rebuilds metadata from agent + context metadata and drops them. Any completion that produces metadata (every successful LLM run records request timing) then replaces the column and the tags correlation is lost; error runs keep it only because their rebuild usually produces no metadata. Carry the tracker fields through the completion rebuild via the existing inject_tracker_data helper, but only when the rebuild actually produced metadata — when it did not, leaving the column untouched preserves the running record's metadata as before.
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.
Defect
Instrumentation#build_running_execution_datainjects the active tracker'srequest_idandtags(viainject_tracker_data) into the execution's metadata when the "running" row is created. But when the run completes,build_completion_datarebuildsmetadatafrom agent metadata + context metadata and never carries the tracker fields over. So whenever the completion rebuild produces any metadata at all — which it does on essentially every successful LLM run, since request timing/count land in context metadata — theupdate!replaces the wholemetadatacolumn and thetagscorrelation written at start is gone.Error runs keep their tags only by accident: their rebuild usually produces no metadata, so the column is left untouched.
Reproduction
Fix
At the end of
build_completion_data, call the existinginject_tracker_data(context, data)— the same helperbuild_running_execution_datauses — but only when the rebuild actually produced metadata (if data[:metadata]). The guard keeps the no-metadata case on the previous behavior:datacarries nometadatakey, theupdate!leaves the column alone, and the running record's metadata (tags included) is preserved. This also avoids replacing the column with a tags-only hash, so other keys written at start (e.g.replay_source_id) can never be clobbered by the completion.Tests
New
tracker tags on completionexamples inspec/lib/pipeline/middleware/instrumentation_spec.rb:main— tags are dropped)Full suite: 4900 examples, 0 failures (Ruby 3.3.6).
standardrbclean on changed files.