🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
fix(tables): use full row height for Input/Output cells (LFE-14586) (#15875)
Nikita Kabardin9ddc84d04d03
diff --git a/packages/shared/src/server/repositories/events.ts b/packages/shared/src/server/repositories/events.tsindex 373502781e..e6042b8805 100644--- a/packages/shared/src/server/repositories/events.ts+++ b/packages/shared/src/server/repositories/events.ts@@ -2470,6 +2470,12 @@ export const getObservationsBatchIOFromEventsTable = async <minStartTime: Date;maxStartTime: Date;truncated?: boolean; // Default true for performance, false for full data+ /**+ * Chars of I/O and of each metadata value to ship on a full read. Lets a+ * caller that needs more than events_core's pre-truncated I/O still bound+ * the payload. Ignored for truncated reads (events_core caps far tighter).+ */+ ioCharLimit?: number;includeExperimentFields?: TIncludeExperiment;/** Opt-in: tool-call arrays can be large; only eval consumers need them. */includeToolCallFields?: TIncludeToolCalls;@@ -2481,6 +2487,12 @@ export const getObservationsBatchIOFromEventsTable = async <}const truncated = opts.truncated ?? true;+ // Interpolated into SQL, so coerce to a positive integer here rather than+ // trusting the caller's number.+ const fullReadCharLimit =+ !truncated && opts.ioCharLimit !== undefined+ ? Math.max(1, Math.trunc(opts.ioCharLimit))+ : undefined;// Extract IDs and trace IDs for filteringconst observationIds = opts.observations.map((o) => o.id);@@ -2492,16 +2504,28 @@ export const getObservationsBatchIOFromEventsTable = async <// Use events_core for truncated reads (lightweight), events_full for full I/Oconst tableName = truncated ? "events_core" : "events_full";- const inputSelect = truncated- ? `leftUTF8(e.input, ${env.LANGFUSE_SERVER_SIDE_IO_CHAR_LIMIT}) as input`+ const charLimit = truncated+ ? env.LANGFUSE_SERVER_SIDE_IO_CHAR_LIMIT+ : fullReadCharLimit;+ const inputSelect = charLimit+ ? `leftUTF8(e.input, ${charLimit}) as input`: `e.input as input`;- const outputSelect = truncated- ? `leftUTF8(e.output, ${env.LANGFUSE_SERVER_SIDE_IO_CHAR_LIMIT}) as output`+ const outputSelect = charLimit+ ? `leftUTF8(e.output, ${charLimit}) as output`: `e.output as output`;+ // events_core already stores these pre-truncated, so only a full read needs+ // capping — an explicit limit has to bound every large field, not just I/O.+ const capOnFullRead = (expr: string) =>+ fullReadCharLimit ? `leftUTF8(${expr}, ${fullReadCharLimit})` : expr;+ const capEachOnFullRead = (expr: string) =>+ fullReadCharLimit+ ? `arrayMap(v -> leftUTF8(v, ${fullReadCharLimit}), ${expr})`+ : expr;+ const metadataValues = capEachOnFullRead("e.metadata_values");const experimentFieldsSelect = opts.includeExperimentFields? `- experiment_item_expected_output,- mapFromArrays(arrayReverse(e.experiment_item_metadata_names), arrayReverse(e.experiment_item_metadata_values)) as experiment_item_metadata,+ ${capOnFullRead("e.experiment_item_expected_output")} as experiment_item_expected_output,+ mapFromArrays(arrayReverse(e.experiment_item_metadata_names), arrayReverse(${capEachOnFullRead("e.experiment_item_metadata_values")})) as experiment_item_metadata,`: "";const toolCallFieldsSelect = opts.includeToolCallFields@@ -2518,7 +2542,7 @@ export const getObservationsBatchIOFromEventsTable = async <${outputSelect},${experimentFieldsSelect}${toolCallFieldsSelect}- mapFromArrays(arrayReverse(e.metadata_names), arrayReverse(e.metadata_values)) as metadata+ mapFromArrays(arrayReverse(e.metadata_names), arrayReverse(${metadataValues})) as metadataFROM ${tableName} eWHERE e.project_id = {projectId: String}AND e.span_id IN {observationIds: Array(String)}diff --git a/web/src/__tests__/server/repositories/event-repository.servertest.ts b/web/src/__tests__/server/repositories/event-repository.servertest.tsindex c3cded9313..61d793ff6a 100644--- a/web/src/__tests__/server/repositories/event-repository.servertest.ts+++ b/web/src/__tests__/server/repositories/event-repository.servertest.ts@@ -3779,6 +3779,69 @@ describe("Clickhouse Events Repository Test", () => {expect(withToolCalls[0]?.toolCalls).toEqual([storedToolCall]);expect(withToolCalls[0]?.toolCallNames).toEqual(["get_weather"]);});++ it("should serve ioCharLimit chars of I/O and metadata on an untruncated read", async () => {+ const traceId = randomUUID();+ const observationId = randomUUID();+ const nowMicro = Date.now() * 1000;+ const timestamp = new Date(nowMicro / 1000);+ const charLimit = 1_000;+ const longInput = "i".repeat(3 * charLimit);+ const longOutput = "o".repeat(3 * charLimit);+ const longMetadataValue = "m".repeat(3 * charLimit);+ const longExpectedOutput = "e".repeat(3 * charLimit);++ await createEventsCh([+ createEvent({+ id: observationId,+ span_id: observationId,+ project_id: projectId,+ trace_id: traceId,+ type: "GENERATION",+ name: "test-io-char-limit",+ input: longInput,+ output: longOutput,+ metadata_names: ["long"],+ metadata_values: [longMetadataValue],+ experiment_item_expected_output: longExpectedOutput,+ start_time: nowMicro,+ }),+ ]);++ const baseParams = {+ projectId,+ observations: [{ id: observationId, traceId }],+ minStartTime: timestamp,+ maxStartTime: timestamp,+ };++ // The default read serves events_core, whose I/O is stored pre-truncated+ // well below what a taller table row can display (LFE-14586).+ const truncated = await getObservationsBatchIOFromEventsTable(baseParams);+ expect(truncated[0]?.input?.length).toBeLessThan(charLimit);++ // The limit has to bound every large field the read returns, not just I/O.+ const capped = await getObservationsBatchIOFromEventsTable({+ ...baseParams,+ truncated: false,+ ioCharLimit: charLimit,+ includeExperimentFields: true,+ });+ expect(capped[0]?.input).toBe("i".repeat(charLimit));+ expect(capped[0]?.output).toBe("o".repeat(charLimit));+ expect(capped[0]?.metadata?.long).toBe("m".repeat(charLimit));+ expect(capped[0]?.experimentItemExpectedOutput).toBe(+ "e".repeat(charLimit),+ );++ // Without a limit an untruncated read still returns everything.+ const full = await getObservationsBatchIOFromEventsTable({+ ...baseParams,+ truncated: false,+ });+ expect(full[0]?.input).toBe(longInput);+ expect(full[0]?.metadata?.long).toBe(longMetadataValue);+ });});maybe("getLatestSdkVersionInfoFromEvents", () => {diff --git a/web/src/components/table/data-table-row-height-switch.tsx b/web/src/components/table/data-table-row-height-switch.tsxindex 1ef7852689..92686a0c21 100644--- a/web/src/components/table/data-table-row-height-switch.tsx+++ b/web/src/components/table/data-table-row-height-switch.tsx@@ -28,6 +28,18 @@ const defaultHeights: Record<RowHeight, string> = {export type RowHeight = (typeof heightOptions)[number]["id"];export type CustomHeights = Record<RowHeight, string>;+/**+ * Chars of Input/Output a taller row needs to fill its cells. Small shows a+ * single truncated line, so it stays on the cheap pre-truncated read; Medium+ * and Large have room for far more text than that (LFE-14586). Sized to fill a+ * Large row even at a generously widened column.+ */+export const EXPANDED_ROW_IO_CHAR_LIMIT = 2_000;++/** Undefined for Small, which keeps the default truncated read. */+export const getRowHeightIOCharLimit = (rowHeight: RowHeight) =>+ rowHeight === "s" ? undefined : EXPANDED_ROW_IO_CHAR_LIMIT;+export const getRowHeightTailwindClass = (rowHeight?: RowHeight,customHeights?: CustomHeights,diff --git a/web/src/features/events/components/EventsTable.tsx b/web/src/features/events/components/EventsTable.tsxindex 041b62d7ed..dc1a09b034 100644--- a/web/src/features/events/components/EventsTable.tsx+++ b/web/src/features/events/components/EventsTable.tsx@@ -48,7 +48,10 @@ import {usdFormatter,} from "@/src/utils/numbers";import { useOrderByState } from "@/src/features/orderBy/hooks/useOrderByState";-import { useRowHeightLocalStorage } from "@/src/components/table/data-table-row-height-switch";+import {+ getRowHeightIOCharLimit,+ useRowHeightLocalStorage,+} from "@/src/components/table/data-table-row-height-switch";import { useTableDateRange } from "@/src/hooks/useTableDateRange";import {toAbsoluteTimeRange,@@ -840,6 +843,7 @@ export default function ObservationsEventsTable({// In chart mode the table is hidden and the chart runs its own aggregate// query — don't also run the expensive row + batched-I/O fetches.rowsEnabled: !chartActive,+ ioCharLimit: getRowHeightIOCharLimit(rowHeight),});useApplyAppRootFallback({diff --git a/web/src/features/events/hooks/useEventsTableData.ts b/web/src/features/events/hooks/useEventsTableData.tsindex 7127ee6a91..b727124f9e 100644--- a/web/src/features/events/hooks/useEventsTableData.ts+++ b/web/src/features/events/hooks/useEventsTableData.ts@@ -43,6 +43,11 @@ type UseEventsTableDataParams = {* fetches don't run alongside the chart's aggregate query.*/rowsEnabled?: boolean;+ /**+ * Chars of I/O to fetch per cell. Undefined keeps the cheap pre-truncated+ * read, which holds too little text to fill a taller row (LFE-14586).+ */+ ioCharLimit?: number;};export function useEventsTableData({@@ -57,6 +62,7 @@ export function useEventsTableData({setSelectedRows,appRootFallbackEnabled = false,rowsEnabled = true,+ ioCharLimit,}: UseEventsTableDataParams) {// Prepare query payloadsconst getCountPayload = useMemo(@@ -158,11 +164,17 @@ export function useEventsTableData({})),minStartTime,maxStartTime,+ // events_core's pre-truncated I/O can't fill a taller row, so ask for a+ // bounded slice of the full I/O instead.+ ...(ioCharLimit !== undefined+ ? { truncated: false as const, ioCharLimit }+ : {}),};}, [activeObservations.data?.observations,activeObservations.isPlaceholderData,projectId,+ ioCharLimit,]);// Fetch I/O datadiff --git a/web/src/features/events/server/eventsRouter.ts b/web/src/features/events/server/eventsRouter.tsindex cae4ba55ee..c830c498bb 100644--- a/web/src/features/events/server/eventsRouter.ts+++ b/web/src/features/events/server/eventsRouter.ts@@ -89,6 +89,10 @@ export const BatchIOInput = zodSchema.object({minStartTime: zodSchema.date(),maxStartTime: zodSchema.date(),truncated: zodSchema.boolean().optional(), // Defaults to true for performance+ // Caps the chars of I/O (and of each metadata value) an untruncated read+ // ships. Bounded by the char limit above which the table cell stops+ // rendering anyway (IO_TABLE_CHAR_LIMIT).+ ioCharLimit: zodSchema.number().int().positive().max(10_000).optional(),includeToolCalls: zodSchema.boolean().optional(), // Defaults to false; tool-call arrays can be large// Opts into trace-level auth (public traces) in protectedGetEventsTraceProceduretraceId: zodSchema.string().optional(),@@ -214,6 +218,7 @@ export const eventsRouter = createTRPCRouter({minStartTime: input.minStartTime,maxStartTime: input.maxStartTime,truncated: input.truncated,+ ioCharLimit: input.ioCharLimit,includeToolCallFields: input.includeToolCalls,});@@ -236,6 +241,7 @@ export const eventsRouter = createTRPCRouter({minStartTime: input.minStartTime,maxStartTime: input.maxStartTime,truncated: input.truncated,+ ioCharLimit: input.ioCharLimit,includeExperimentFields: true,includeToolCallFields: input.includeToolCalls,});diff --git a/web/src/features/events/server/eventsService.ts b/web/src/features/events/server/eventsService.tsindex fe094b808c..bfe2136c41 100644--- a/web/src/features/events/server/eventsService.ts+++ b/web/src/features/events/server/eventsService.ts@@ -846,6 +846,7 @@ interface GetEventBatchIOParams<minStartTime: Date;maxStartTime: Date;truncated?: boolean;+ ioCharLimit?: number;includeExperimentFields?: TIncludeExperiment;/** Opt-in: tool-call arrays can be large; only eval consumers need them. */includeToolCallFields?: TIncludeToolCalls;@@ -866,6 +867,7 @@ export async function getEventBatchIO<minStartTime: params.minStartTime,maxStartTime: params.maxStartTime,truncated: params.truncated,+ ioCharLimit: params.ioCharLimit,includeExperimentFields: params.includeExperimentFields,includeToolCallFields: params.includeToolCallFields,});