Skip to content

Commit 1bdff0c

Browse files
fix(eval): flush span processors before reading execution trace
_get_and_clear_execution_data() read ExecutionSpanExporter.get_spans() without first flushing the batch span processor. The flush triggered by the root execution span ending only exports spans whose on_end() already fired by that moment, so a tool-call span finishing a beat later (e.g. a detached background task) could still be queued, unexported, and missing from AgentRunHistory when the evaluator reads the trace (UV-16309). Force a flush immediately before the read so every span that has ended by then is guaranteed to be exported first. See UV-16309 and the repro test in test/uv-16309-span-flush-race (test_execution_span_race.py). Co-Authored-By: Claude Sonnet 5 <[email protected]>
1 parent 611fe7d commit 1bdff0c

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

packages/uipath/src/uipath/eval/runtime/runtime.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,13 @@ async def _generate_input_for_eval(
970970
def _get_and_clear_execution_data(
971971
self, execution_id: str
972972
) -> tuple[list[ReadableSpan], list[logging.LogRecord]]:
973+
# Force a flush right before reading: the flush triggered by the root
974+
# execution span ending only exports spans whose on_end() had already
975+
# fired by that moment. A tool-call span that finishes a beat later
976+
# (e.g. a detached background task) would otherwise still be sitting
977+
# in the batch processor's queue and be silently missing from
978+
# AgentRunHistory (UV-16309).
979+
self.trace_manager.flush_spans()
973980
spans = self.span_exporter.get_spans(execution_id)
974981
self.span_exporter.clear(execution_id)
975982
self.span_collector.clear(execution_id)

0 commit comments

Comments
 (0)