Skip to content

: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.

fix(trials): Avoid error blinking (#113604)

Alex Lebedeva0a960bd7c17
diff --git a/docs/internal/scout-online-evals-devbox.md b/docs/internal/scout-online-evals-devbox.md
index 588ea2c24ec3..0ca7727a8b06 100644
--- a/docs/internal/scout-online-evals-devbox.md
+++ b/docs/internal/scout-online-evals-devbox.md
@@ -41,7 +41,7 @@ Revoke or expire private tokens before rolling the gateway back to a version wit
1. Open `/project/2/inbox/scout-trials`, search for and select the scout, then select **New trial**. Resolve any setup blocker shown. The picker lists scouts by display name; the old `/project/2/scout-trials` address redirects here. Trials have a separate path so existing scout names remain valid.
2. Start with two versions and one run per version. Change the second version's model, effort or prompt.
-3. Select **Start trial**. Scouts run and judging follows automatically; closing the page does not stop them.
+3. Select **Start trial**. Runs show **Queued** while an active trial starts them; this is not a failure. Scouts run and judging follows automatically; closing the page does not stop them.
4. Compare the results, then open a run to inspect its report and evidence for each rubric check. Cost and speed are shown separately from rubric results.
5. Reopen the saved trial or export its JSON report. Reading saved results makes no further model calls.
diff --git a/products/signals/frontend/inbox/logics/scoutTrialsLogic.test.ts b/products/signals/frontend/inbox/logics/scoutTrialsLogic.test.ts
index 540482c3954c..66d333248012 100644
--- a/products/signals/frontend/inbox/logics/scoutTrialsLogic.test.ts
+++ b/products/signals/frontend/inbox/logics/scoutTrialsLogic.test.ts
@@ -319,6 +319,7 @@ describe('scoutTrialsLogic', () => {
...trialFixtureResult,
status: 'not_started',
task_status: null,
+ error: 'The scout trial has not started. Retry the launch with the same ID.',
})
logic = scoutTrialsLogic({ teamId: 2, userId: 42 })
await expectLogic(logic, () => {
@@ -326,7 +327,32 @@ describe('scoutTrialsLogic', () => {
}).toFinishAllListeners()
await expectLogic(logic, () => logic.actions.submitComparison()).toFinishAllListeners()
expect(logic.values.comparisonRows.every((row) => row.status === 'not_started')).toBe(true)
+ expect(logic.values.comparisonRows.every((row) => row.error === null)).toBe(true)
+ const launchId = logic.values.comparisonRows[0].launchId
+ logic.actions.selectResult(launchId)
+ expect(logic.values.selectedResult?.error).toBeNull()
+ expect(logic.values.results[launchId].error).toContain('has not started')
+ logic.actions.setResults({}, { [launchId]: 'Status unavailable.' })
+ expect(logic.values.comparisonRows[0].error).toBe('Status unavailable.')
+ logic.actions.setResults({ [launchId]: logic.values.results[launchId] }, {})
const saved = logic.values.comparisonState.value!
+ jest.mocked(signalsScoutConfigTrialComparisonHistory).mockResolvedValue({
+ results: [
+ { ...saved, status: 'not_started' },
+ { ...saved, comparison_id: 'older-trial', status: 'completed', variants: [] },
+ ],
+ has_more: false,
+ })
+ await expectLogic(logic, () =>
+ logic.actions.loadComparisonHistory(trialFixtureConfig.id)
+ ).toFinishAllListeners()
+ expect(logic.values.comparisonState.value?.status).toBe(saved.status)
+ expect(logic.values.selectedResult?.error).toBeNull()
+ expect(logic.values.comparisonsForConfig.map((comparison) => comparison.id)).toEqual([
+ saved.comparison_id,
+ 'older-trial',
+ ])
+
jest.mocked(signalsScoutConfigTrialComparisonRetrieve).mockResolvedValue({ ...saved, status: 'judging' })
jest.mocked(signalsScoutConfigTrialResult).mockImplementation(async (_, __, params) => ({
...trialFixtureResult,
@@ -363,6 +389,50 @@ describe('scoutTrialsLogic', () => {
}
})
+ test.each(['not_started', 'failed', 'unknown'] as const)(
+ 'keeps launch errors actionable when the trial itself is %s',
+ async (status) => {
+ jest.mocked(signalsScoutConfigTrialResult).mockImplementation(async (_, __, params) => ({
+ ...trialFixtureResult,
+ launch_id: params.launch_id,
+ status: 'not_started',
+ task_status: null,
+ error: 'The scout trial has not started. Retry the launch with the same ID.',
+ }))
+ await expectLogic(logic, () => logic.actions.submitComparison()).toFinishAllListeners()
+ const comparison = logic.values.comparisonState.value!
+ const launchId = logic.values.comparisonRows[0].launchId
+ logic.actions.selectResult(launchId)
+ expect(logic.values.selectedResult?.error).toBeNull()
+
+ jest.mocked(signalsScoutConfigTrialComparisonRetrieve).mockResolvedValue({ ...comparison, status })
+ await expectLogic(logic, () =>
+ logic.actions.loadComparison(comparison.comparison_id)
+ ).toFinishAllListeners()
+
+ expect(logic.values.comparisonRows[0].error).toContain('has not started')
+ expect(logic.values.selectedResult?.error).toContain('has not started')
+ }
+ )
+
+ test.each([
+ ['failed', true],
+ ['not_started', false],
+ ] as const)('keeps run errors for status=%s and owned by an active trial=%s', async (status, owned) => {
+ await expectLogic(logic, () => logic.actions.submitComparison()).toFinishAllListeners()
+ const launchId = owned ? logic.values.comparisonRows[0].launchId : 'unrelated-launch'
+ const result = { ...trialFixtureResult, launch_id: launchId, status, error: 'Run needs attention.' }
+ logic.actions.trackLaunches([{ configId: trialFixtureConfig.id, launchId }])
+ logic.actions.setResults({ [launchId]: result }, {})
+ logic.actions.selectResult(launchId)
+
+ expect(logic.values.rows.find((row) => row.launchId === launchId)?.error).toBe(result.error)
+ expect(logic.values.selectedResult?.error).toBe(result.error)
+
+ logic.actions.untrackLaunches([launchId])
+ expect(logic.values.selectedResult?.error).toBe(result.error)
+ })
+
it('reuses completed results during background refresh and reloads them on explicit refresh', async () => {
await expectLogic(logic, () => logic.actions.submitComparison()).toFinishAllListeners()
jest.mocked(signalsScoutConfigTrialResult).mockClear()
diff --git a/products/signals/frontend/inbox/logics/scoutTrialsLogic.ts b/products/signals/frontend/inbox/logics/scoutTrialsLogic.ts
index 447ed0e5c018..08c3ce327096 100644
--- a/products/signals/frontend/inbox/logics/scoutTrialsLogic.ts
+++ b/products/signals/frontend/inbox/logics/scoutTrialsLogic.ts
@@ -397,6 +397,7 @@ export interface scoutTrialsLogicMeta {
hasUnaccepted: (batch: ScoutTrialBatch | null) => boolean
selectedResult: (
selectedLaunchId: string | null,
+ rows: ScoutTrialRow[],
results: Record<string, ScoutTrialResultApi>
) => ScoutTrialResultApi | null
rows: (
@@ -807,9 +808,13 @@ export const scoutTrialsLogic: LogicWrapper<scoutTrialsLogicType> = kea<scoutTri
(batch: ScoutTrialBatch | null): boolean => !!batch?.submissions.some((submission) => !submission.accepted),
],
selectedResult: [
- (s) => [s.selectedLaunchId, s.results],
- (launchId: string | null, results: Record<string, ScoutTrialResultApi>): ScoutTrialResultApi | null =>
- launchId ? (results[launchId] ?? null) : null,
+ (s) => [s.selectedLaunchId, s.rows, s.results],
+ (
+ launchId: string | null,
+ rows: ScoutTrialRow[],
+ results: Record<string, ScoutTrialResultApi>
+ ): ScoutTrialResultApi | null =>
+ launchId ? (rows.find((row) => row.launchId === launchId)?.result ?? results[launchId] ?? null) : null,
],
rows: [
(s) => [
@@ -844,12 +849,18 @@ export const scoutTrialsLogic: LogicWrapper<scoutTrialsLogicType> = kea<scoutTri
]),
]
return ids.map((launchId) => {
- const result = results[launchId] ?? null
+ const savedResult = results[launchId] ?? null
const saved = relevantHistory.find((entry) => entry.launch_id === launchId)
const submission = batch?.submissions.find((entry) => entry.request.launch_id === launchId)
- const variant = Object.values(comparisonStates)
- .flatMap((state) => state.value?.variants ?? [])
- .find((variant) => variant.launch_ids.includes(launchId))
+ const comparison = Object.values(comparisonStates).find((state) =>
+ state.value?.variants.some((variant) => variant.launch_ids.includes(launchId))
+ )?.value
+ const variant = comparison?.variants.find((variant) => variant.launch_ids.includes(launchId))
+ // An active trial can still be dispatching this run's workflow.
+ const result =
+ savedResult?.status === 'not_started' && comparison && comparisonIsActive(comparison.status)
+ ? { ...savedResult, error: null }
+ : savedResult
const repeat = variant ? variant.launch_ids.indexOf(launchId) + 1 : null
const status = result?.status || saved?.status || (submission?.accepted ? 'pending' : 'unknown')
// The row's Stop run button is the retry, so the failure only shows while that button does.
@@ -916,7 +927,13 @@ export const scoutTrialsLogic: LogicWrapper<scoutTrialsLogicType> = kea<scoutTri
return
}
for (const comparison of [...comparisonHistory.results].reverse()) {
- actions.registerServerComparison(comparison)
+ // History can be read before the running workflow writes its first progress update.
+ const current = values.comparisonStates[comparison.comparison_id]?.value
+ actions.registerServerComparison(
+ comparison.status === 'not_started' && current && current.status !== 'not_started'
+ ? current
+ : comparison
+ )
}
},
loadComparison: async ({ comparisonId }) => {
@@ -1395,7 +1412,10 @@ export const scoutTrialsLogic: LogicWrapper<scoutTrialsLogicType> = kea<scoutTri
}
},
downloadResults: () => {
- const results = values.rows.flatMap((row) => (row.result ? [{ variant: row.variant, ...row.result }] : []))
+ const results = values.rows.flatMap((row) => {
+ const result = values.results[row.launchId]
+ return result ? [{ variant: row.variant, ...result }] : []
+ })
downloadFile(
new File(
[JSON.stringify({ config_id: values.selectedConfigId, results }, null, 2)],