:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(llma): stop truncating fetched ai event payloads to a preview (#68571)
Carlos Marchalcf4be16b7a75
diff --git a/products/ai_observability/frontend/aiObservabilityAIDataLogic.test.ts b/products/ai_observability/frontend/aiObservabilityAIDataLogic.test.tsindex 7943f806d1ee..d06cbf4e9142 100644--- a/products/ai_observability/frontend/aiObservabilityAIDataLogic.test.ts+++ b/products/ai_observability/frontend/aiObservabilityAIDataLogic.test.ts@@ -132,6 +132,40 @@ describe('aiObservabilityAIDataLogic', () => {expect(mockApi.queryHogQL.mock.calls[1][0]).toContain('FROM events')})+ it('parses fetched heavy props in full instead of collapsing them into a truncated preview', async () => {+ const fullInput = [+ { role: 'system', content: `You are a data extraction specialist. ${'detail '.repeat(60)}` },+ { role: 'user', content: 'analyze this page' },+ ]+ jest.spyOn(mockApi, 'queryHogQL').mockResolvedValue({+ results: [[JSON.stringify(fullInput), null, null, null, null, null]],+ } as any)++ const logic = aiObservabilityAIDataLogic()+ logic.mount()++ await expectLogic(logic, () => {+ logic.actions.loadAIDataForEvent({+ eventId: 'event-1',+ input: fullInput,+ output: undefined,+ tools: undefined,+ traceId: 'trace-1',+ timestamp: '2026-04-30T10:00:00Z',+ })+ })+ .toFinishAllListeners()+ .toMatchValues({+ aiDataCache: {+ 'event-1': {+ input: fullInput,+ output: undefined,+ tools: undefined,+ },+ },+ })+ })+it('degrades gracefully to the passed-in values when the lookup throws', async () => {jest.spyOn(mockApi, 'queryHogQL').mockRejectedValue(new Error('network down'))diff --git a/products/ai_observability/frontend/aiObservabilityAIDataLogic.ts b/products/ai_observability/frontend/aiObservabilityAIDataLogic.tsindex 3e9a0bddab4d..7e2729e09d1b 100644--- a/products/ai_observability/frontend/aiObservabilityAIDataLogic.ts+++ b/products/ai_observability/frontend/aiObservabilityAIDataLogic.ts@@ -8,7 +8,7 @@ import { ProductKey } from '~/queries/schema/schema-general'import { hogql } from '~/queries/utils'import type { aiObservabilityAIDataLogicType } from './aiObservabilityAIDataLogicType'-import { parseJSONPreview } from './utils'+import { parsePartialJSON } from './utils'const AI_DATA_QUERY_TAGS = {productKey: ProductKey.AI_OBSERVABILITY,@@ -75,10 +75,17 @@ function parseHeavyValue(value: unknown): unknown {if (!isUsableValue(value)) {return undefined}+ if (typeof value !== 'string') {+ return value+ }try {- return parseJSONPreview(value)+ return JSON.parse(value)} catch {- return value+ try {+ return parsePartialJSON(value)+ } catch {+ return value+ }}}