fix(cost): restored cost reporting for agent block in console entry (#1253)

This commit is contained in:
Waleed
2025-09-04 21:12:15 -07:00
committed by GitHub
parent 0e8e8c7a47
commit 53dd277cfe
2 changed files with 3 additions and 12 deletions
+1 -1
View File
@@ -86,7 +86,7 @@ export async function executeProviderRequest(
const { prompt: promptTokens = 0, completion: completionTokens = 0 } = response.tokens
const useCachedInput = !!request.context && request.context.length > 0
if (shouldBillModelUsage(response.model, request.apiKey)) {
if (shouldBillModelUsage(response.model)) {
response.cost = calculateCost(response.model, promptTokens, completionTokens, useCachedInput)
} else {
response.cost = {
+2 -11
View File
@@ -548,20 +548,11 @@ export function getHostedModels(): string[] {
* Determine if model usage should be billed to the user
*
* @param model The model name
* @param userProvidedApiKey Whether the user provided their own API key
* @returns true if the usage should be billed to the user
*/
export function shouldBillModelUsage(model: string, userProvidedApiKey?: string): boolean {
export function shouldBillModelUsage(model: string): boolean {
const hostedModels = getHostedModels()
if (!hostedModels.includes(model)) {
return false
}
if (userProvidedApiKey && userProvidedApiKey.trim() !== '') {
return false
}
return true
return hostedModels.includes(model)
}
/**