fix(agent-cli): keep pi-reported generation cost without a resolver or token usage - #131
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TL;DR
Two gaps in the pi billed-cost path from #128 dropped cost the agent had already reported:
resolveBilledCostreturnedundefinedwhen noGenerationResolverwas provided, ignoringreportedGenerationCosts.withBilledCostreturnedundefinedusage when pi sent a cost but no token usage, soori-solverfell back toZERO_USAGEand recordedtotalCost: 0.Both were flagged by Devin Review on the vendored copy of #129 downstream; they have to land here first.
What changed?
resolveBilledCostsums the reported costs when no resolver is present (stillundefinedif none were reported).withBilledCostbuilds a zero-token usage carryingtotalCostwhen usage is missing but a cost resolved; existing usage is unchanged apart fromtotalCost.runner.test.tsfor both.Before:
resolveBilledCost(["a"], new Map([["a", 0.5]]))with no resolver →undefined; cost event + empty usage →totalCost: 0.After:
0.5in both cases.How to test
bun test src/benchmarks: 1194 pass, 0 fail (local).format:check,check,typecheckpass locally.parseRun/resolveBilledCostonmain.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.