Skip to content

fix(report-generator): wait for an evaluable run before generating - #1576

Open
Naveen Chatlapalli (1aifanatic) wants to merge 1 commit into
microsoft:mainfrom
1aifanatic:fix/1287-report-waits-for-run
Open

Naveen Chatlapalli (1aifanatic) wants to merge 1 commit into
microsoft:mainfrom
1aifanatic:fix/1287-report-waits-for-run

Conversation

@1aifanatic

Copy link
Copy Markdown

Fixes #1287.

A report triggered while its run was still pending/processing was generated immediately. It completed as a "run not executed, 0 turns, Overall Score 0%" report that stayed around after the run later succeeded, which inflated completed-report counts and skewed aggregates.

The gate lives in the report-generator worker, so it covers every way a report is created (POST /reports, bulk create, trigger, bulk trigger):

  • Run not finished → wait. After the template resolves, the worker fetches the run. If run.status is pending, queued, processing or paused, the report stays pending. The worker logs Waiting for run <id> to finish (status: …) on the report's log stream and hides the queue message for RUN_NOT_FINISHED_DEFER_SECONDS (60s) via the base processor's safeDeferMessage. It never runs an LLM session or writes a completed report for an unfinished run.
  • Run finished with no turns → non-evaluable. The report is marked failed with error: "Non-evaluable run: Run finished (<outcome>) without any turns …", including the run's own error when present, instead of producing a 0% implementation score. A new report_generator.run_non_evaluable event tracks these.
  • Run finished with turns → generate as before, including failed runs that still produced turns to assess.

Not in this PR: the issue's last acceptance item, a canonical-report marker when a run has several reports. bulk-summary already counts only the latest report per template. With premature reports no longer completing, the stale-duplicate case this item addresses should largely go away, so I'd keep any further UI/API work for a follow-up.

Documented in docs/architecture/app-design.md (report queue section) and docs/architecture/observability.md (new event).

Validation: pnpm exec vitest run apps/workers/report-generator (43 passed). New tests cover readiness classification for pending/queued/processing/paused/no-run/done states, defer-and-stay-pending, and non-evaluable failure without an LLM session. Also pnpm --filter report-generator exec tsc --noEmit and git diff --check.

🤖 Generated with Claude Code

A report triggered while its run was still pending or processing
completed immediately as a stale "0 turns / 0%" report that later looked
like the real result. The worker now keeps such reports pending and
re-checks the run every 60s, and fails reports for runs that finished
without any turn with an explicit non-evaluable reason instead of
scoring them.

Fixes microsoft#1287.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

Report generation should wait for terminal/evaluable runs and not produce stale 0-turn reports

1 participant