Skip to content

(MOT-4407) fix(harness): report context usage truthfully - #802

Open
rohitg00 wants to merge 1 commit into
mainfrom
fix/harness-context-accounting
Open

(MOT-4407) fix(harness): report context usage truthfully#802
rohitg00 wants to merge 1 commit into
mainfrom
fix/harness-context-accounting

Conversation

@rohitg00

Copy link
Copy Markdown
Contributor

Refs MOT-4407

What

  • make the Harness context chip provider-agnostic and explicit about where each number comes from
  • separate provider-reported prompt totals from provider-tokenizer, local-tokenizer, or chars-per-four breakdowns
  • show cache creation, cache hits, and reasoning only when the provider reports them
  • derive session cost from the complete assistant transcript and report it as unavailable when any generation lacks pricing
  • exclude the deterministic current assistant entry during redelivery so a retried step cannot be double-counted
  • add focused presentation tests and update the metrics schema

Why

The context popover previously described mixed accounting as exact · tokenizer, rendered absent cache fields as zero, and could present a partial or missing price as a complete session total. GLM-5.3 made the mismatch visible, but the issue was in the shared Harness layer.

This applies to every current and future provider through the common Usage contract. Provider adapters remain responsible only for accurately parsing the usage fields their API returns.

Verification

  • cargo fmt --manifest-path harness/Cargo.toml --all -- --check
  • SKIP_UI_BUILD=1 cargo clippy --manifest-path harness/Cargo.toml -p harness --all-targets --all-features -- -D warnings
  • SKIP_UI_BUILD=1 cargo test --manifest-path harness/Cargo.toml -p harness --all-features (329 tests)
  • pnpm --dir harness/ui test (8 tests)
  • pnpm --dir harness/ui build
  • isolated Harness integration playground UI-001 scenario passed in Chromium; the popover showed provider usage, local breakdown, truthful cache/cost state, and no console warnings or errors
  • git diff --check

@vercel

vercel Bot commented Aug 14, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
workers Ready Ready Preview Aug 14, 2026 12:23pm
workers-tech-spec Ready Ready Preview Aug 14, 2026 12:23pm

Request Review

@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@rohitg00, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 5 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6f4d0ab4-31a4-48b8-9bd4-ad4bb8e969ea

📥 Commits

Reviewing files that changed from the base of the PR and between 9d0df97 and 32efce9.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (8)
  • harness/src/context_snapshot.rs
  • harness/src/turn_loop.rs
  • harness/tests/golden/schemas/harness.metrics.json
  • harness/ui/package.json
  • harness/ui/src/context-chip/index.tsx
  • harness/ui/src/context-chip/presentation.test.ts
  • harness/ui/src/context-chip/presentation.ts
  • harness/ui/src/lib/metrics.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

skill-check — worker

0 verified, 59 skipped (no docs/).

Layer Result
structure
vale
ai
render

Four for four. Nicely done.

@rohitg00
rohitg00 marked this pull request as ready for review August 14, 2026 12:24
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