{"record":{"id":"df8803f5008672a8","repo":"paperclipai/paperclip","slug":"provider-reported-cost-limit-exceeded","errorCode":null,"errorMessage":"provider-reported cost limit exceeded","messagePattern":"provider-reported cost limit exceeded","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/paperclip-runner/src/cli/eval-session.ts","lineNumber":255,"sourceCode":"): EvalSessionUsage | null {\n  if (turn.status !== \"completed\") {\n    return usageIfAvailable(request, turn.snapshot);\n  }\n  const usage = evalSessionUsage(request.model, turn.snapshot);\n  if (usage.agentTurns > request.limits.maxAgentTurns) {\n    throw new Error(\"agent turn limit exceeded\");\n  }\n  if (\n    usage.estimatedCostNanodollars >\n    request.limits.maxEstimatedCostNanodollars\n  ) {\n    throw new Error(\"estimated cost limit exceeded\");\n  }\n  if (\n    usage.providerReportedCostNanodollars >\n    request.limits.maxEstimatedCostNanodollars\n  ) {\n    throw new Error(\"provider-reported cost limit exceeded\");\n  }\n  return usage;\n}\n\nasync function closeSession(\n  session: CapabilityLiveSession | null,\n  reason: string,\n): Promise<void> {\n  if (session === null || session.snapshot().status === \"closed\") return;\n  await session.shutdown(reason);\n}\n\nexport async function runEvalSessionCli(\n  args: string[],\n  options: {\n    serviceFactory?: (\n      runnerBinary: string,\n    ) => CapabilityLiveSessionService;","sourceCodeStart":237,"sourceCodeEnd":273,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/packages/paperclip-runner/src/cli/eval-session.ts#L237-L273","documentation":"runEvalSessionCli also checks provider-reported cost: when the provider itself reports the session's cost, exceeding the same maxEstimatedCostNanodollars budget aborts the run. This guards against divergence between local token-based estimates and the provider's authoritative billing figure.","triggerScenarios":"usage.providerReportedCostNanodollars > request.limits.maxEstimatedCostNanodollars in runEvalSessionCli, where providerReportedCostNanodollars comes from the provider's own cost accounting in the turn snapshot.","commonSituations":"Provider-reported cost legitimately exceeds token-based estimate (cached/hidden costs, per-request fees); the provider's pricing changed; provider returns cost in different units causing inflated figures; limit configured only for estimated cost, forgetting the provider-reported path.","solutions":["Raise request.limits.maxEstimatedCostNanodollars to cover provider-reported pricing","Compare usage.estimatedCostNanodollars vs providerReportedCostNanodollars to spot unit or pricing mismatches","Check the provider's current pricing for the requested model","Switch to a cheaper model if provider-reported costs are systematically above budget"],"exampleFix":"// before\nlimits: { maxEstimatedCostNanodollars: 10_000_000, ... }\n// after\nlimits: { maxEstimatedCostNanodollars: 50_000_000, ... } // matches provider-reported cost","handlingStrategy":"validation","validationCode":"// Reconcile estimate vs provider-reported cost after each turn\nconst usage = evalSessionUsage(request.model, turn.snapshot);\nif (usage.providerReportedCostNanodollars > request.limits.maxEstimatedCostNanodollars) {\n  console.warn(`provider-reported cost ${usage.providerReportedCostNanodollars} nd exceeds cap; estimate was ${usage.estimatedCostNanodollars} nd`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await runEvalSessionCli(request, cli);\n} catch (error) {\n  if (error instanceof Error && error.message === \"provider-reported cost limit exceeded\") {\n    console.error(\"provider billing exceeds budget; check provider pricing/unit assumptions\");\n  }\n  throw error;\n}","preventionTips":["Track providerReportedCostNanodollars vs estimatedCostNanodollars to detect pricing drift","Update limits when the provider changes pricing","Confirm the provider reports cost in nanodollars, matching the limit's unit"],"tags":["limit","cost","budget","provider"],"backgroundTag":"cost-limit-exceeded","analyzedSha":"01ad8584922b5d85292b1723cae71fa0d9b07a19","analyzedAt":"2026-09-10T03:14:50.855Z","contentChangedAt":"2026-09-10T03:14:50.855Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}