-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Yield the cost in usage data for Anthropic #4849
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| import { RepoPerTaskCheckpointService } from "../RepoPerTaskCheckpointService" | ||
|
|
||
| vitest.setConfig({ testTimeout: 10_000 }) | ||
| vitest.setConfig({ testTimeout: 20_000 }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is flaking for the win32 GHA runner.
| cost: totalCost, | ||
| cost: | ||
| totalCost ?? | ||
| calculateApiCostAnthropic( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally we'd require all providers to emit a totalCost, but there's no enforcement mechanism for that right now, so we'll re-use this fallback.
Description
Some providers aren't set up to yield costs in real-time. In some of these cases we sum the cost ourselves and yield a final usage with the total cost. For providers that don't do this there is a final fallback:
This incorrectly assumes that the total cost calculation is the Anthropic variant, and it also happens after we emit the
LLM Completionevent that Roo Code Cloud uses.The option that makes sense to me is to have our provider classes emit a
usagewith the total cost. Here's the fix for the Anthropic provider and I'm having Roo Code audit all of the others.Important
Ensure Anthropic provider yields usage data with total cost by updating
AnthropicHandlerandTaskclasses.AnthropicHandlerinanthropic.tsnow accumulates token usage and yields a finalusageevent withtotalCostusingcalculateApiCostAnthropic().TaskinTask.tsupdates telemetry capture to calculate cost usingcalculateApiCostAnthropic()iftotalCostis undefined.ShadowCheckpointService.spec.tsfrom 10,000 to 20,000 milliseconds.This description was created by
for 53f048c. You can customize this summary. It will automatically update as commits are pushed.