JuliusBrussee/caveman · error · Error
cave_provider_cost_mismatch
Error message
cave_provider_cost_mismatch
What it means
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.
Source
Thrown at packages/agent/src/execution-kernel.ts:168
throw new Error("cave_provider_usage_incomplete");
}
const priced = catalogCost({
provider: evidence.provider,
model: evidence.model,
inputTokens: evidence.inputTokens,
outputTokens: evidence.outputTokens,
cacheReadTokens: evidence.cacheReadTokens,
cacheWriteTokens: evidence.cacheWriteTokens,
reasoningTokens: evidence.reasoningTokens,
});
if (!priced.priced && options.requirePriced === true) {
throw new Error("cave_provider_usage_unpriced");
}
if (options.reportedCostUsd !== undefined &&
(!priced.priced || !Number.isFinite(options.reportedCostUsd) ||
options.reportedCostUsd < 0 ||
Math.abs(options.reportedCostUsd - priced.usd) > 1e-12)) {
throw new Error("cave_provider_cost_mismatch");
}
return Object.freeze({
...evidence,
priced: priced.priced,
catalogCostUsd: priced.priced ? priced.usd : 0,
});
}
View on GitHub (pinned to 27d5a3981a)
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.
Example fix
// before
validateProviderUsage(evidence, { reportedCostUsd: adapterClaimedUsd });
// after
const priced = catalogCost(evidence);
validateProviderUsage(evidence, priced.priced ? { reportedCostUsd: priced.usd } : {}); Defensive patterns
Strategy: validation
Validate before calling
const priced = catalogCost(evidence);
const okReported = options.reportedCostUsd === undefined ||
(priced.priced && Number.isFinite(options.reportedCostUsd) &&
options.reportedCostUsd >= 0 &&
Math.abs(options.reportedCostUsd - priced.usd) <= 1e-12);
if (!okReported) options = { ...options, reportedCostUsd: undefined }; // let the catalog figure stand Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- cave_provider_identity_missing
- cave_provider_usage_incomplete
- ${label}: ${key} has no pricing block
- ${label}: ${field} must be a finite non-negative number
- ${label}: no priced region-agnostic rows found
AI-assisted analysis of JuliusBrussee/caveman@27d5a3981a (2026-08-15).
Data as JSON: /api/errors/0194fb05ae56cc61.
Report an issue: GitHub.