{"record":{"id":"0194fb05ae56cc61","repo":"JuliusBrussee/caveman","slug":"cave-provider-cost-mismatch","errorCode":null,"errorMessage":"cave_provider_cost_mismatch","messagePattern":"cave_provider_cost_mismatch","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/agent/src/execution-kernel.ts","lineNumber":168,"sourceCode":"    throw new Error(\"cave_provider_usage_incomplete\");\n  }\n  const priced = catalogCost({\n    provider: evidence.provider,\n    model: evidence.model,\n    inputTokens: evidence.inputTokens,\n    outputTokens: evidence.outputTokens,\n    cacheReadTokens: evidence.cacheReadTokens,\n    cacheWriteTokens: evidence.cacheWriteTokens,\n    reasoningTokens: evidence.reasoningTokens,\n  });\n  if (!priced.priced && options.requirePriced === true) {\n    throw new Error(\"cave_provider_usage_unpriced\");\n  }\n  if (options.reportedCostUsd !== undefined &&\n      (!priced.priced || !Number.isFinite(options.reportedCostUsd) ||\n        options.reportedCostUsd < 0 ||\n        Math.abs(options.reportedCostUsd - priced.usd) > 1e-12)) {\n    throw new Error(\"cave_provider_cost_mismatch\");\n  }\n  return Object.freeze({\n    ...evidence,\n    priced: priced.priced,\n    catalogCostUsd: priced.priced ? priced.usd : 0,\n  });\n}\n","sourceCodeStart":150,"sourceCodeEnd":176,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/27d5a3981a347890211bb1bf2439e5c821a63bc9/packages/agent/src/execution-kernel.ts#L150-L176","documentation":"Thrown by validateProviderUsage (packages/agent/src/execution-kernel.ts:168): a reportedCostUsd was supplied but it is not finite/non-negative, the model is unpriced, or it differs from the catalog-computed USD cost by more than 1e-12. The framework cross-checks every claimed dollar figure against the public catalog; a mismatch means the reported cost is not honest list-price accounting.","triggerScenarios":"Passing options.reportedCostUsd (e.g. the cost an adapter/provider reported) that disagrees with catalogCost() computed from the same token counts — different rates, NEGATIVE_INFINITY/NaN, or a non-zero figure for an unpriced model.","commonSituations":"Upstream reports cost with negotiated/discounted rates while the catalog enforces public list prices; stale catalog after a provider price change; adapter multiplying wrong token tiers; passing 0 for a priced model or a positive number for an unpriced one.","solutions":["Drop reportedCostUsd and let the framework compute cost from the catalog, or pass the catalog-derived value if you must report one.","If the catalog is out of date relative to the provider's prices, update the catalog and regenerate src/catalog.ts.","Check that reportedCostUsd is a finite non-negative number produced from the same token counts you pass in evidence."],"exampleFix":"// before\nvalidateProviderUsage(evidence, { reportedCostUsd: adapterClaimedUsd });\n\n// after\nconst priced = catalogCost(evidence);\nvalidateProviderUsage(evidence, priced.priced ? { reportedCostUsd: priced.usd } : {});","handlingStrategy":"validation","validationCode":"const priced = catalogCost(evidence);\nconst okReported = options.reportedCostUsd === undefined ||\n  (priced.priced && Number.isFinite(options.reportedCostUsd) &&\n   options.reportedCostUsd >= 0 &&\n   Math.abs(options.reportedCostUsd - priced.usd) <= 1e-12);\nif (!okReported) options = { ...options, reportedCostUsd: undefined }; // let the catalog figure stand","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer omitting reportedCostUsd and using the framework's catalog-derived cost.","Never mix negotiated-rate dollar figures with the public-list-price catalog.","Keep the generated catalog current with provider price sheets."],"tags":["pricing","cost","validation","billing"],"backgroundTag":null,"analyzedSha":"27d5a3981a347890211bb1bf2439e5c821a63bc9","analyzedAt":"2026-08-15T09:26:11.751Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}