Skip to content

review eval: keep usage and outcomes in agent transcripts - #424

Closed
jwbron wants to merge 1 commit into
mainfrom
agent/review-transcript-metadata
Closed

jwbron wants to merge 1 commit into
mainfrom
agent/review-transcript-metadata

Conversation

@jwbron

@jwbron jwbron commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

An eval transcript shows what a reviewer did, but diagnosing its cost or failure still means finding the matching report entry. Failed dispatches can leave no report usage at all. Each transcript now keeps the SDK result's cost, turns, and per-model token/cache totals beside its completion status, wall time, last assistant stop reason, and available error detail.

  • Error results are captured before the runner rejects them. Transport failures and timeouts keep the message usage received before the failure, and an SDK stream that closes on abort without throwing still records a timeout.
  • Messages retain their ids, models, and raw usage snapshots. Totals come only from the SDK result, so repeated message snapshots aren't double-counted. Missing totals stay absent, not zero, and no reasoning-token split is inferred.
  • The fields are additive. Prompt, model, tool policy, retry behavior, and report pricing are unchanged. The eval README describes the new fields.

This extracts the remaining transcript metadata idea from #406 onto the SDK runner after #417 and #418, without bringing over pi code.

Test plan

  • pnpm exec vitest run: 2,401 tests pass across 124 files. Seven new mocked-SDK tests cover repeated message snapshots, error-result metering, transport failure, both timeout endings, missing versus zero totals, and a stream failure after a metered success result. Existing tests still cover per-attempt files, tool results, and a failed transcript write not losing the review result.
  • pnpm run lint and pnpm run typecheck pass.
  • No live model run was started locally. The SDK is mocked in these tests.

KORE-2663

@changeset-bot

changeset-bot Bot commented Sep 8, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 84cab75

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
review Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@khan-actions-bot
khan-actions-bot requested review from a team, jeresig and kevinb-khan and removed request for a team September 8, 2026 17:33
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Review live A/B

No reviewable delta: review.md is byte-identical in both arms (baseline origin/main, sha 3b4f69f79dac), so the extracted prompts and the orchestrator body match and no arms were run. Pass --force-arms for a deliberate wobble control.

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Guidance for reviewers

Triage notes for reviewers: risky files by owning team, repeated changes, and files excluded from review.

github-actions (2 files)
File Reason
live-runner.ts Records the cost and outcome data the eval's A/B reviewer decisions read, so mis-recorded metadata would mislead those calls.
transcripts.ts Defines the transcript artifact schema the eval's diagnosis reads; this change widens two exported types.
review details review-v1.25.0 | schema 2 | depth full | re-review scoped blocking-medium | enable holistic,completeness,test-adequacy,first-principles,conventions,documentation

@khan-actions-bot
khan-actions-bot requested a review from a team September 8, 2026 17:56

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lower-confidence observations (7; top: `workflows/review/eval/live-runner.ts:358` question (non-blocking): The `finally` block overwrites `outcome.status` with `"timeout"` whenever `abort.signal.aborted` is true, with no guard...)
  • workflows/review/eval/live-runner.ts:358 question (non-blocking): The finally block overwrites outcome.status with "timeout" whenever abort.signal.aborted is true, with no guard for the "success" status set at line 304, so a dispatch that returned a successful result can still be recorded as a timeout. (skill-auditor (out-of-lane))
  • workflows/review/eval/live-runner.ts:321 suggestion (non-blocking): The new outcome.errorMessage capture from a result-level error field has no test; add one scripting a success result that carries error. (test-adequacy)
  • workflows/review/eval/live-runner.ts:293 suggestion (non-blocking): The result branch now keeps two parallel accumulators for the same values — consider deriving the returned fields from outcome instead. (first-principles)
  • .changeset/review-transcript-metadata.md:5 suggestion (non-blocking): Changeset body starts without the review eval: summary line every other eval changeset in this folder uses. (conventions)
  • workflows/review/eval/live-runner.ts:284 question (non-blocking): Should a failed attempt's cost/usage also be carried on LiveAgentError.partial so the report stops under-counting, instead of being recorded only in the transcript? (first-principles)
  • workflows/review/eval/live-runner.ts:296 question (non-blocking): Does the SDK result message actually carry an errors: string[] field, or is this branch only reachable from the mock? (completeness)
  • workflows/review/eval/transcripts.ts:46 suggestion (non-blocking): usage names two incompatible shapes in one transcript file — the raw per-message snapshot and the SDK result totals — with the "don't sum these" rule living only in README prose; consider renaming the message-level field. (holistic)
review details review-v1.25.0 | schema 2 | depth full | re-review scoped blocking-medium | enable holistic,completeness,test-adequacy,first-principles,conventions,documentation
review fingerprint pr-reviewer:rereview v=1 depth=full verdict=APPROVE anchor-draft=false hunks=eyIuY2hhbmdlc2V0L3Jldmlldy10cmFuc2NyaXB0LW1ldGFkYXRhLm1kIjpbImQ3ODg3NmY2OWI1ODhhMGYiXSwid29ya2Zsb3dzL3Jldmlldy9ldmFsL1JFQURNRS5tZCI6WyI3MjRmNmZhYjk4ODUxNDI0Il0sIndvcmtmbG93cy9yZXZpZXcvZXZhbC9saXZlLXJ1bm5lci50ZXN0LnRzIjpbIjFlY2JhNmY5MDEzNmYxNDciLCI3Yjg2NWQwMjI3ODAwNzEyIiwiYjNhYmFlMTExYmI0Y2VhYiJdLCJ3b3JrZmxvd3MvcmV2aWV3L2V2YWwvbGl2ZS1ydW5uZXIudHMiOlsiOWI1M2FiMzc1YjhlMjkwZiIsImY3NzRlYjdhYTIyNDBmYWQiLCJkMWRhMTY4ZmNjYzM1NmZiIiwiODBkY2EzNTA5MTE2YTQ2OCIsImQwNGI4Y2UxNTlmMzQyODMiLCI4NTE0Njc5NmI0Y2M0NGIxIiwiYzFiOGVkM2MzYzQ3NTA4OCIsIjRjNzBjNTY3ZmEyY2FhMzUiLCI2NGI2MGZiZjIwZGNmODExIl0sIndvcmtmbG93cy9yZXZpZXcvZXZhbC90cmFuc2NyaXB0cy50cyI6WyIwYzA5MTg2MGNlOTI0ZDY3IiwiYjYxOTlhYmNiMDFmYWFkNSIsImY2MWRmNWNhMDRkMWRiMjIiLCJhOTVjOGEyNzhhNTFiNDA1Il19

// An SDK stream can close on abort without throwing.
if (abort.signal.aborted) {
outcome.status = "timeout";
outcome.errorMessage ??= String(abort.signal.reason).slice(0, 500);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (non-blocking): The finally-path timeout message keeps the "Error: " prefix that the catch path strips, so the same timeout is recorded under two different strings.

context

The finally-path timeout message keeps the "Error: " prefix that the catch path strips, so the same timeout is recorded under two different strings. abort.abort() at line 121 passes an Error as the abort reason. The catch path at line 341-343 unwraps it with error.message; the new finally path at line 359 stringifies the reason object instead (String(abort.signal.reason)), which yields "Error: " + message. Both branches describe the identical event — the wall-clock timer fired — but write different text into the same outcome.errorMessage field the README says is the bounded error detail. The new tests enshrine both spellings: live-runner.test.ts:246 expects "sub-agent timed out after 5ms" and live-runner.test.ts:258 expects "Error: sub-agent timed out after 5ms", so the suggested fix needs that second expectation updated too. Introduced by this change.

found by correctness-reviewer | also flagged by skill-auditor (out-of-lane); completeness; holistic

Suggested change
outcome.errorMessage ??= String(abort.signal.reason).slice(0, 500);
outcome.errorMessage ??= (
abort.signal.reason instanceof Error
? abort.signal.reason.message
: String(abort.signal.reason)
).slice(0, 500);

/* -------------------------------------------------------------------------- */

type Script = {messages: unknown[]; throwAfter?: Error};
type Script = {messages: unknown[]; throwAfter?: Error; waitForAbort?: boolean};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (non-blocking): Script gained waitForAbort but not finishOnAbort, so the second new flag is untyped and nothing checks its spelling.

context

Script gained waitForAbort but not finishOnAbort, so the second new flag is untyped and nothing checks its spelling. The mock reads current.finishOnAbort at live-runner.test.ts:45 and :52 and the abort-close test sets it at :251, but the Script type on line 31 only declares waitForAbort. I grepped the whole workflows/ tree for finishOnAbort and it appears only in those three lines, so there is no declaration merge or augmentation supplying it. Nothing catches this today because tsconfig.json's include lists only actions/, utils/, types/, config/, and vitest.config.ts — workflows/** is outside pnpm typecheck, and vitest transpiles without type checking — which is why the PR's clean typecheck is not evidence here. Introduced by this change (the same hunk added the sibling waitForAbort field).

found by correctness-reviewer | also flagged by skill-auditor (out-of-lane) (at line 45): The mock branches on current.finishOnAbort and the test at line 251 passes {messages: [], finishOnAbort: true}, but the Script type at line 31 declares only waitForAbort?: boolean — the new flag is never added to the type.; test-adequacy (at line 45)

Suggested change
type Script = {messages: unknown[]; throwAfter?: Error; waitForAbort?: boolean};
type Script = {
messages: unknown[];
throwAfter?: Error;
waitForAbort?: boolean;
finishOnAbort?: boolean;
};

);
} finally {
clearTimeout(timer);
outcome.wallMs = Date.now() - started;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (non-blocking): No test distinguishes a recorded wall time from the placeholder wallMs: 0; assert a lower bound in the timeout test.

context

No test distinguishes a recorded wall time from the placeholder wallMs: 0; assert a lower bound in the timeout test. outcome is initialized {status: "incomplete", wallMs: 0} (live-runner.ts:171) and wallMs is written in exactly one place, the finally at line 355. Every assertion on it in the new tests is wallMs: expect.any(Number) (grep for wallMs in live-runner.test.ts returns only lines 177, 205, 227, 244, 257, 267, 273 — all expect.any(Number)), which the placeholder 0 satisfies, so the only line that gives the field meaning is unguarded. The two timeout tests are the stable place to pin it: they pass timeoutMs: 5 and the mock generator waits on the abort signal, so elapsed time is necessarily >= 5ms — unlike the fast success paths, where Date.now() - started can legitimately be 0.

found by test-adequacy

Suggested change
outcome.wallMs = Date.now() - started;
const transcript = recorded("timeout");
expect(transcript.messages[0].usage).toEqual(rawUsage);
expect(transcript.outcome.wallMs).toBeGreaterThanOrEqual(5);
expect(transcript.outcome).toEqual({

@jwbron
jwbron requested review from mojadem and rjcorwin September 8, 2026 18:50
@kevinb-khan

Copy link
Copy Markdown
Contributor

Review-bot is moving into a private repo and this PR is stale.

@kevinb-khan kevinb-khan closed this Dec 2, 2026
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.

4 participants