Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix(trace): stop v4 tree/search rows overlapping with many scores (LFE-10591) (#14691)

Nikita Kabardinb91b014fcb7c
diff --git a/.agents/skills/seed-test-data/SKILL.md b/.agents/skills/seed-test-data/SKILL.md
index cdb978fc09..0b7e3acc96 100644
--- a/.agents/skills/seed-test-data/SKILL.md
+++ b/.agents/skills/seed-test-data/SKILL.md
@@ -37,6 +37,7 @@ this.
| A super tough session (v3 legacy session view) | `pnpm run seed -- long-session --traces 300 --observations-per-trace 8` |
| Many traces for list/filter performance | `pnpm run seed -- many-traces --count 100000 --days 14` |
| Scores with spaces in the name (filter/grammar testing) | `pnpm run seed -- scored-traces --traces 24 --v4` |
+| Lots of scores on every node (dense score badges, tree-row overflow testing) | add `--scores-per-node 12` to `trace-tree` (N distinct scores per observation; try `--depth 2 --breadth 44` for many tall sibling rows) |
| Varied human-annotation queues (annotate UI / keyboard testing) | `pnpm run seed -- annotation-queue --core-items 12` (creates a "core types" queue covering every score-field render path + an "edge cases" queue with archived/stale/partial scores and observation/session/deleted/completed items) |
| Huge/malformed/unicode payloads | `pnpm run seed -- trace-tree --payload-bytes 1000000 --payload-style malformed` (styles: json, text, malformed, unicode, bignum) |
| Big integers beyond 2^53-1 (number-precision testing) | `pnpm run seed -- trace-tree --observations 1 --payload-style bignum` |
diff --git a/packages/shared/scripts/seeder/scenarios/trace-tree.ts b/packages/shared/scripts/seeder/scenarios/trace-tree.ts
index 2ccd1279e7..d84413e0c6 100644
--- a/packages/shared/scripts/seeder/scenarios/trace-tree.ts
+++ b/packages/shared/scripts/seeder/scenarios/trace-tree.ts
@@ -123,6 +123,11 @@ const run = async (
const payloadStyle = params["payload-style"] as PayloadStyle;
const withV4 = params["v4"] as boolean;
const asyncParents = params["async-parents"] as boolean;
+ // Attach this many distinct scores to EVERY observation. The default 0 keeps
+ // the historic handful of trace-level scores. A high value (e.g. 12) is the
+ // "lots of scores" shape from LFE-10591 that overflows fixed/virtualized tree
+ // rows — many distinct score names wrap into several badge lines per node.
+ const scoresPerNode = params["scores-per-node"] as number;
if (!PAYLOAD_STYLES.includes(payloadStyle)) {
throw new SeedError(
@@ -154,6 +159,12 @@ const run = async (
"larger payloads exceed V8 string limits during generation",
);
}
+ if (scoresPerNode < 0 || scoresPerNode > 100) {
+ throw new SeedError(
+ `--scores-per-node must be between 0 and 100, got ${scoresPerNode}`,
+ "pass e.g. --scores-per-node 12 to reproduce the many-scores overflow",
+ );
+ }
const breadth = Math.min(
requestedBreadth,
@@ -176,7 +187,10 @@ const run = async (
counts: {
traces: 1,
observations: observationCount,
- scores: 3 + (observationCount >= 7 ? 1 : 0),
+ scores:
+ 3 +
+ (observationCount >= 7 ? 1 : 0) +
+ observationCount * scoresPerNode,
events: withV4 ? observationCount + 1 : 0,
},
verified: {},
@@ -478,6 +492,44 @@ const run = async (
successScore.string_value = successScore.value === 1 ? "True" : "False";
}
+ // --scores-per-node: attach N distinct scores to EVERY observation. This is
+ // the LFE-10591 "lots of scores" shape — many differently-named badges per
+ // row that wrap into several lines. Names are stable and jitter-derived (not
+ // rng stream) so re-runs with the same prefix overwrite in place. Every 4th
+ // name is categorical; the rest numeric. Names are long-ish so they truncate
+ // like real eval metrics (mirroring the reported trace).
+ if (scoresPerNode > 0) {
+ const SCORE_CATEGORIES = ["pass", "warn", "fail"] as const;
+ observations.forEach((obs, obsIndex) => {
+ for (let s = 0; s < scoresPerNode; s++) {
+ const label = String(s).padStart(2, "0");
+ const isCategorical = s % 4 === 3;
+ const seedIndex = obsIndex * (scoresPerNode + 1) + s + 1;
+ scores.push(
+ createTraceScore({
+ id: `${obs.id}-nodescore-${label}`,
+ project_id: ctx.projectId,
+ trace_id: traceId,
+ observation_id: obs.id,
+ environment: ctx.environment,
+ name: isCategorical
+ ? `eval_categorical_metric_${label}`
+ : `eval_numeric_metric_${label}`,
+ value: isCategorical ? 0 : jitter(ctx.seed, seedIndex, 100) / 100,
+ string_value: isCategorical
+ ? SCORE_CATEGORIES[jitter(ctx.seed, seedIndex, 2)]
+ : undefined,
+ data_type: isCategorical ? "CATEGORICAL" : "NUMERIC",
+ source: "EVAL",
+ comment: null,
+ metadata: {},
+ timestamp: traceTimestamp,
+ }),
+ );
+ }
+ });
+ }
+
const events = withV4
? [
traceToEvent(trace),
@@ -499,7 +551,9 @@ const run = async (
for (const batch of chunk(observations, 1000)) {
await createObservationsCh(batch);
}
- await createScoresCh(scores);
+ for (const batch of chunk(scores, 1000)) {
+ await createScoresCh(batch);
+ }
for (const batch of chunk(events, 500)) {
await createEventsCh(batch);
}
@@ -633,6 +687,13 @@ export const traceTreeScenario: ScenarioDefinition = {
description:
"root + hub nodes end immediately while their subtree keeps running (async/fire-and-forget shape; surfaces the subtree wall-clock duration badge)",
},
+ {
+ flag: "scores-per-node",
+ type: "number",
+ default: 0,
+ description:
+ "attach N distinct scores to every observation (the LFE-10591 'lots of scores' shape; try 12), 0-100",
+ },
],
run,
};
diff --git a/web/src/components/trace/components/SpanContent.tsx b/web/src/components/trace/components/SpanContent.tsx
index 122205aca4..0618a1573e 100644
--- a/web/src/components/trace/components/SpanContent.tsx
+++ b/web/src/components/trace/components/SpanContent.tsx
@@ -32,6 +32,11 @@ import { useViewPreferences } from "../contexts/ViewPreferencesContext";
import { useTraceData } from "../contexts/TraceDataContext";
import type Decimal from "decimal.js";
+// How many distinct score groups to show inline on a tree/search row before
+// collapsing the rest into a "+N" pill. Keeps dense-score rows compact; the
+// full set is always on the node's Scores tab. (The timeline caps at 3.)
+const MAX_INLINE_SCORE_GROUPS = 3;
+
interface SpanContentProps {
node: TreeNode;
parentTotalCost?: Decimal;
@@ -233,10 +238,16 @@ export function SpanContent({
</div>
)}
- {/* Scores row */}
+ {/* Scores row. Cap the inline badges and roll the rest into a "+N"
+ pill (hover to see them) so a node with many scores stays a compact
+ one/two-line row instead of a tall wrapping grid. */}
{showScores && nodeScores.length > 0 && (
<div className="flex flex-wrap gap-1">
- <GroupedScoreBadges compact scores={nodeScores} />
+ <GroupedScoreBadges
+ compact
+ scores={nodeScores}
+ maxVisible={MAX_INLINE_SCORE_GROUPS}
+ />
</div>
)}
</div>
diff --git a/web/src/components/trace/components/_shared/VirtualizedList.tsx b/web/src/components/trace/components/_shared/VirtualizedList.tsx
index 062e9406e3..f700a4cf58 100644
--- a/web/src/components/trace/components/_shared/VirtualizedList.tsx
+++ b/web/src/components/trace/components/_shared/VirtualizedList.tsx
@@ -41,6 +41,14 @@ export function VirtualizedList<T>({
count: items.length,
getScrollElement: () => parentRef.current,
estimateSize: () => estimatedItemSize,
+ // Key the measurement cache by item id, matching the React key on each row.
+ // Rows have dynamic heights (SpanContent wraps a node's score badges over
+ // several lines) and the list filters/reorders as the search query changes.
+ // Without this the cache is keyed by index, so a reordered row reuses the
+ // previous occupant's measured height and the translateY offsets drift into
+ // overlap (same failure as the tree — LFE-10591). Keying by id keeps each
+ // measurement with its item.
+ getItemKey: (index) => getItemId(items[index]!),
overscan,
});
diff --git a/web/src/components/trace/components/_shared/VirtualizedTree.tsx b/web/src/components/trace/components/_shared/VirtualizedTree.tsx
index 4521bd053e..6243b40fb4 100644
--- a/web/src/components/trace/components/_shared/VirtualizedTree.tsx
+++ b/web/src/components/trace/components/_shared/VirtualizedTree.tsx
@@ -61,6 +61,16 @@ export function VirtualizedTree<T extends { id: string; children: T[] }>({
estimateSize: estimateSize
? (index) => estimateSize(flattenedItems[index]!.node, index)
: defaultEstimateSize,
+ // Key the measurement cache by node id, matching the React key on each row.
+ // Rows have dynamic, wildly-varying heights (a node's score badges wrap into
+ // several lines), and collapse/expand reorders the flattened list. Without
+ // this the cache is keyed by index: on a reorder React reuses a row's DOM
+ // element (same id) without resizing it, so the virtualizer never
+ // re-measures and keeps the PREVIOUS node's height at that index — the
+ // translateY offsets drift out of sync with the real heights and rows
+ // overlap (LFE-10591, worst right after "Collapse all"). Keying by id makes
+ // each measurement travel with its node, so offsets stay correct.
+ getItemKey: (index) => flattenedItems[index]!.node.id,
overscan,
measureElement:
typeof window !== "undefined"