Skip to content

fix(agent-cli): keep pi-reported generation cost without a resolver or token usage - #131

Merged
ayush-or merged 1 commit into
mainfrom
codex/agent-cli-reported-cost
Oct 1, 2026
Merged

ayush-or merged 1 commit into
mainfrom
codex/agent-cli-reported-cost

Conversation

@ayush-or

@ayush-or ayush-or commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

TL;DR

Two gaps in the pi billed-cost path from #128 dropped cost the agent had already reported:

  1. resolveBilledCost returned undefined when no GenerationResolver was provided, ignoring reportedGenerationCosts.
  2. withBilledCost returned undefined usage when pi sent a cost but no token usage, so ori-solver fell back to ZERO_USAGE and recorded totalCost: 0.

Both were flagged by Devin Review on the vendored copy of #129 downstream; they have to land here first.

What changed?

  • resolveBilledCost sums the reported costs when no resolver is present (still undefined if none were reported).
  • withBilledCost builds a zero-token usage carrying totalCost when usage is missing but a cost resolved; existing usage is unchanged apart from totalCost.
  • Regression tests in runner.test.ts for both.

Before: resolveBilledCost(["a"], new Map([["a", 0.5]])) with no resolver → undefined; cost event + empty usage → totalCost: 0.
After: 0.5 in both cases.

How to test

  • bun test src/benchmarks: 1194 pass, 0 fail (local). format:check, check, typecheck pass locally.
  • Before the fix I reproduced both with throwaway tests against parseRun / resolveBilledCost on main.

Reviewer focus

The real runner always provides a resolver (run-by-id.ts), so fix 1 only affects callers without one; fix 2 needs pi to omit token usage while the fetch hook still captured a cost.

@ayush-or
ayush-or requested a review from a team as a code owner October 1, 2026 18:24
@ayush-or
ayush-or merged commit 7601137 into main Oct 1, 2026
4 checks passed
@ayush-or
ayush-or deleted the codex/agent-cli-reported-cost branch October 1, 2026 18:25
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