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

  1. Drop reportedCostUsd and let the framework compute cost from the catalog, or pass the catalog-derived value if you must report one.
  2. If the catalog is out of date relative to the provider's prices, update the catalog and regenerate src/catalog.ts.
  3. 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

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


AI-assisted analysis of JuliusBrussee/caveman@27d5a3981a (2026-08-15). Data as JSON: /api/errors/0194fb05ae56cc61. Report an issue: GitHub.