Skip to content

fix(web): show Codex round usage metadata - #1685

Open
techotaku39 wants to merge 2 commits into
tiann:mainfrom
techotaku39:investigate/agent-usage-metadata
Open

fix(web): show Codex round usage metadata#1685
techotaku39 wants to merge 2 commits into
tiann:mainfrom
techotaku39:investigate/agent-usage-metadata

Conversation

@techotaku39

@techotaku39 techotaku39 commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Mark Codex token usage events explicitly and convert them into round metadata.
  • Display Codex usage as Round: <duration> · <turns> turn(s).
  • Derive live Codex round duration from HAPI user invocation to final assistant completion.
  • Exclude replayed local Codex history from derived Round duration because replay timestamps do not represent the original turn timing.
  • Preserve the existing Claude Code usage display behavior.

Validation

  • bun typecheck — passed.
  • bun run test:e2e -- terminal-wrap-fidelity.spec.ts — 2 passed.
  • Codex launcher tests — 105 passed.
  • Related Web tests — 103 passed.
  • bun run build — passed.
  • Live Codex round demonstrations — 4 passed, covering 1.8 seconds, 65 seconds, 65 minutes, and 26 hours.

Related Issues

None

AI Disclosure

Implemented and tested with OpenAI Codex (GPT-5.6).

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Findings

  • [Major] Imported local Codex history receives replay-time Round durations. See the inline finding at cli/src/codex/codexLocalLauncher.ts:220.

Summary

  • Review mode: initial
  • One correctness issue found: replayed transcript usage is promoted to Codex round metadata even though its timestamps are hub replay stamps rather than original turn timing.

Testing

  • Not run (automation; PR content was not executed). GitHub test, integration, and drift-gate checks are passing. Add a regression for imported local history that asserts no derived duration unless original timestamps are available.

HAPI Bot

Comment thread cli/src/codex/codexLocalLauncher.ts Outdated
? message
: context.replayedHistory
? { ...message, model: transcriptModel, hapiUsageScope: 'imported-history' }
? { ...message, flavor: 'codex', model: transcriptModel, hapiUsageScope: 'imported-history' }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[MAJOR] Imported history gets fabricated Round durations

This branch now adds flavor: codex to replayed token counts, so the web normalizer marks them as Codex and aggregateResponseGroups derives a duration. However replayed user/agent entries are sent without their original createdAt; the hub therefore gives each no-localId row replay-time createdAt/invokedAt (hub/src/store/messages.ts:145). The displayed value measures replay/loader speed, not the historical turn.

Suggested fix:

? { ...message, model: transcriptModel, hapiUsageScope: imported-history }

Keep the Codex flavor only on managed/live usage, or propagate the scope and skip duration derivation for imported history. Add an import regression covering this path.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Findings

  • None.

Summary
Review mode: follow-up after new commits

  • The previous imported-history duration issue is resolved at cli/src/codex/codexLocalLauncher.ts:220: replayed token counts no longer carry the Codex marker, and web/src/chat/reducerTimeline.test.ts:239 covers the no-summary behavior.
  • No additional issues found in the latest full diff.
  • Residual risk: duration is covered by separate reducer/runtime tests rather than one full normalize-to-render pipeline test.

Testing

  • Not run (automation; PR content was not executed). GitHub integration and drift-gate pass; test was still in progress at review time.
  • Suggested: add a normalize → reduceTimelineaggregateResponseGroups regression asserting imported history has no Round while live usage derives duration from the user invocation.

HAPI Bot

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