Skip to content

feat(harness): stop sharing agent $ cost with the client#871

Merged
korutx merged 2 commits into
trunkfrom
based/not-showing-cost
Jul 1, 2026
Merged

feat(harness): stop sharing agent $ cost with the client#871
korutx merged 2 commits into
trunkfrom
based/not-showing-cost

Conversation

@odtorres

@odtorres odtorres commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

What & why

The harness computed the LLM dollar cost (cost_usd) per turn and streamed it to the client in the usage.recorded SSE event, where miot-chat rendered it in the TUI footer as $0.0123. We don't want tenants to see how much each query costs us.

This stops the dollar cost from ever leaving the server, while keeping it tracked internally so we still measure our own spend.

Changes

Boundary fix (backend)

  • miot-harness/.../observability/callbacks.py — no longer attaches cost_usd to the usage.recorded event. The cost is still computed and kept as the server-side span attribute (gen_ai.usage.cost_usd), so eval reports and provenance logs are unchanged.

Client cleanup (token counts untouched)

  • miot-harness-client/src/types.ts — dropped cost_usd from UsageRecordedData.
  • miot-chat/.../session/types.ts — removed costUsd / lastCostUsd from UsageTotals + ZERO_USAGE.
  • miot-chat/.../transcript/project.ts — removed cost accumulation.
  • miot-chat/.../chrome/FooterLine.tsx — footer now shows 1234→56 with no $ figure.

Left intentionally untouched (internal-only): report.py, run_golden.py eval totals, provenance.py plan_cost, and the Postgres EXPLAIN total_cost (a query-planner estimate, not dollars).

Verification

  • Harness: test_usage_recorded_event.py + test_callbacks.py10 passed (event omits cost_usd; span attribute retained).
  • TUI: FooterLine.test.tsx + transcript.project.test.ts29 passed (footer shows tokens, no $).
  • tsc --noEmit on miot-chat and miot-harness-clientexit 0.
  • Grep confirms no cost_usd/costUsd references remain in turbo-repo.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Removed dollar-cost values from client-facing usage events and summaries.
    • Updated usage tracking to keep token counts and agent details without showing pricing information.
    • Simplified the TUI footer so usage now displays token totals only, with no dollar amount.
    • Adjusted related test coverage to reflect the new usage display and event payload behavior.

The harness computed the LLM dollar cost (cost_usd) per turn and streamed
it to the client in the usage.recorded SSE event, where miot-chat rendered
it in the TUI footer as $0.0123. We don't want tenants to see per-query
cost.

Stop emitting cost_usd to the client and remove the client-side plumbing
that displayed it. The dollar cost is still computed and retained
server-side (span attribute, eval reports, provenance logs) so we keep
tracking our own spend. Token counts remain visible; only the $ figure is
removed.

Untouched: the Postgres EXPLAIN total_cost (a query-planner estimate, not
dollars) in nexo/generic_pg.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

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

Next review available in: 49 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

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: defaults

Review profile: CHILL

Plan: Pro

Run ID: d8c169e9-5583-48b5-8b6e-9a5e017f5ff5

📥 Commits

Reviewing files that changed from the base of the PR and between 9e481d3 and fa0ecd4.

📒 Files selected for processing (1)
  • turbo-repo/packages/miot-chat/src/tui/__tests__/transcript.project.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch based/not-showing-cost

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.

@odtorres

odtorres commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

Tracked by #872.

@odtorres odtorres linked an issue Jul 1, 2026 that may be closed by this pull request
5 tasks
@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
{}

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@turbo-repo/packages/miot-chat/src/tui/__tests__/transcript.project.test.ts`:
- Around line 478-479: Update the transcript projector test in
transcript.project.test to assert that client-side usage totals do not include
both monetary fields: keep the existing costUsd check and add a matching absence
assertion for lastCostUsd on s2.usageTotals. Use the existing usageTotals
expectation block in the test to ensure the client contract stays free of both
money-related properties.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0b128f6c-ef03-4136-a595-871e621d3918

📥 Commits

Reviewing files that changed from the base of the PR and between bb37f23 and 9e481d3.

📒 Files selected for processing (8)
  • miot-harness/src/miot_harness/observability/callbacks.py
  • miot-harness/tests/observability/test_usage_recorded_event.py
  • turbo-repo/packages/miot-chat/src/tui/__tests__/components/FooterLine.test.tsx
  • turbo-repo/packages/miot-chat/src/tui/__tests__/transcript.project.test.ts
  • turbo-repo/packages/miot-chat/src/tui/chrome/FooterLine.tsx
  • turbo-repo/packages/miot-chat/src/tui/session/types.ts
  • turbo-repo/packages/miot-chat/src/tui/transcript/project.ts
  • turbo-repo/packages/miot-harness-client/src/types.ts
💤 Files with no reviewable changes (2)
  • turbo-repo/packages/miot-harness-client/src/types.ts
  • turbo-repo/packages/miot-chat/src/tui/transcript/project.ts

Symmetric with the costUsd absence check — both monetary fields were
removed from UsageTotals, so the client-contract test should verify
neither leaks.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@sonarqubecloud

sonarqubecloud Bot commented Jul 1, 2026

Copy link
Copy Markdown

@korutx korutx merged commit 979cbb2 into trunk Jul 1, 2026
19 checks passed
@korutx korutx deleted the based/not-showing-cost branch July 1, 2026 20:27
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.

Do not expose harness agent $ cost to the client/tenant

2 participants