Skip to content

feat(summary): auto-enqueue a trajectory summary for every finished trial - #1277

Open
stateofkate wants to merge 1 commit into
stagingfrom
kate/auto-trajectory-summary
Open

feat(summary): auto-enqueue a trajectory summary for every finished trial#1277
stateofkate wants to merge 1 commit into
stagingfrom
kate/auto-trajectory-summary

Conversation

@stateofkate

Copy link
Copy Markdown
Collaborator

What

A trajectory summary only ever existed where something asked for one: the post-trial classifier's component map (which runs only on run_analysis tasks), or a dashboard / share-page read. Trials on tasks with QA off carried no summary until a human opened them.

_run_post_trial_hooks now enqueues one per finished trial, behind ODDISH_AUTO_TRAJECTORY_SUMMARY, off by default — so merging this changes nothing until the env var is set.

Eligibility

Real agent trials only: terminal (SUCCESS/FAILED), not cancelled, not superseded, not a probe, not a nop/oracle baseline, and with a fetchable trajectory (which includes old grok-build trials whose grok-build.json synthesizes to ATIF). Baselines and probes are excluded because their trajectories are near-empty or sanctioned-harness noise, and each would still pay for a full LLM call.

Why it delegates instead of enqueueing directly

The job itself (ANALYZER + payload.mode = "trajectory_summary") already exists from #1261. The enqueue shape stays in get_or_enqueue_summary_job, reached from oddish/ through a new enqueuer seam, because that function owns the payload and its schema_version idempotency key — and only backend/ knows SCHEMA_VERSION.

A second enqueue site with its own key would not find the first one's job, so a page view after a trial finished would have paid for the same summary twice. For the same reason, eligibility deliberately does not skip a trial that already has a mirrored trials.trajectory_summary: the mirror can be at an older schema, and only the seam knows the current one.

Placement

The call runs in the hook's own transaction, after the stage transition. A hook that rolls back leaves no paid job behind, and the QA job enqueued just above it finds the summary cached rather than building its own.

Standalone oddish registers no enqueuer, so the whole path is a no-op there — correct, since there is no generator to reach.

Cost

One streamed LLM call per eligible trial. On run_analysis=True tasks this mostly moves existing spend earlier (generation is read-through cached, so the classifier then pays nothing); the genuinely new spend is trials on tasks with QA off.

Existing cancellation covers these for free: cancel_tasks_runs matches on subject_table='trials' regardless of kind, so cancelling a sweep retires its pending summary jobs. No UI change either — the frontend only special-cases job kinds trial/qa/analysis, so nothing mistakes these for a running analysis.

Testing

  • oddish/tests/test_trajectory_summary_auto_enqueue.py — 17 tests: flag on/off, unregistered enqueuer, the 9-case eligibility table, FAILED-trial and grok-build inclusion, stale-mirror pass-through, and the hook wiring.
  • backend/tests/test_trajectory_summary_auto_enqueue_seam.py — importing the worker's provider module installs the enqueuer, and the enqueuer delegates to get_or_enqueue_summary_job. A missing registration is otherwise silent: the oddish side just stops enqueueing.

Each guard was proven by mutation — the flag check, the unregistered-enqueuer check, the eligibility gate, the hook call, and the registration line were each removed in turn and the matching test watched go red.

Full oddish and backend suites were run against this branch and against clean staging; the failure sets are identical, so no regressions. (The test_new_model_reruns teardown errors flake at the same rate on both — 20 errored instances across 6 runs either way.)

…rial

A trajectory summary only ever existed where something asked for one: the
post-trial classifier's component map, which runs on `run_analysis` tasks, or a
dashboard/share page read. Trials on tasks with QA off carried no summary until
a human opened them.

`_run_post_trial_hooks` now enqueues one per finished trial, behind
`ODDISH_AUTO_TRAJECTORY_SUMMARY` (off by default). Eligibility is real agent
trials only -- terminal, not cancelled, not superseded, not a probe, not a
nop/oracle baseline, and with a fetchable trajectory. Baselines and probes are
excluded because their trajectories are near-empty or harness noise and each
would still pay for a full LLM call.

The enqueue itself is delegated to `get_or_enqueue_summary_job` through a seam,
because that function owns the payload and its `schema_version` idempotency
key. A second enqueue site with its own key would not find the first one's job,
so a page view after a trial finished would pay for the same summary twice.
Eligibility deliberately does not skip a trial that already has a mirrored
summary: the mirror can be at an older schema, and only the seam knows the
current one.

Runs in the hook's own transaction, after the stage transition, so a hook that
rolls back leaves no paid job behind and the QA job enqueued above it finds the
summary cached rather than building its own.
@vercel

vercel Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
oddish-app Ready Ready Preview Aug 17, 2026 10:07pm

@github-actions

Copy link
Copy Markdown
Contributor

Oddish preview

Commit: 37aebe8b0e97aaf445d6973d9f840b197b2627dd

Surface Link Target
Frontend https://pr-1277.oddish.app Vercel preview for 37aebe8
Backend oddish-pr-1277 oddish-pr-1277
Database project mhcaqgyxjdynjgoaofnt project mhcaqgyxjdynjgoaofnt

Vercel deployment URL: https://oddish-1f4ot593j.oddish.app

Plan:

  • Frontend deploy: true
  • Backend deploy: true
  • Migrations: false

This comment is updated by the PR Preview workflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant