paperclipai/paperclip · error

provider-reported cost limit exceeded

Error message

provider-reported cost limit exceeded

What it means

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.

Source

Thrown at packages/paperclip-runner/src/cli/eval-session.ts:255

): EvalSessionUsage | null {
  if (turn.status !== "completed") {
    return usageIfAvailable(request, turn.snapshot);
  }
  const usage = evalSessionUsage(request.model, turn.snapshot);
  if (usage.agentTurns > request.limits.maxAgentTurns) {
    throw new Error("agent turn limit exceeded");
  }
  if (
    usage.estimatedCostNanodollars >
    request.limits.maxEstimatedCostNanodollars
  ) {
    throw new Error("estimated cost limit exceeded");
  }
  if (
    usage.providerReportedCostNanodollars >
    request.limits.maxEstimatedCostNanodollars
  ) {
    throw new Error("provider-reported cost limit exceeded");
  }
  return usage;
}

async function closeSession(
  session: CapabilityLiveSession | null,
  reason: string,
): Promise<void> {
  if (session === null || session.snapshot().status === "closed") return;
  await session.shutdown(reason);
}

export async function runEvalSessionCli(
  args: string[],
  options: {
    serviceFactory?: (
      runnerBinary: string,
    ) => CapabilityLiveSessionService;

View on GitHub (pinned to 01ad858492)

Solutions

  1. Raise request.limits.maxEstimatedCostNanodollars to cover provider-reported pricing
  2. Compare usage.estimatedCostNanodollars vs providerReportedCostNanodollars to spot unit or pricing mismatches
  3. Check the provider's current pricing for the requested model
  4. Switch to a cheaper model if provider-reported costs are systematically above budget

Example fix

// before
limits: { maxEstimatedCostNanodollars: 10_000_000, ... }
// after
limits: { maxEstimatedCostNanodollars: 50_000_000, ... } // matches provider-reported cost
Defensive patterns

Strategy: validation

Validate before calling

// Reconcile estimate vs provider-reported cost after each turn
const usage = evalSessionUsage(request.model, turn.snapshot);
if (usage.providerReportedCostNanodollars > request.limits.maxEstimatedCostNanodollars) {
  console.warn(`provider-reported cost ${usage.providerReportedCostNanodollars} nd exceeds cap; estimate was ${usage.estimatedCostNanodollars} nd`);
}

Try / catch

try {
  await runEvalSessionCli(request, cli);
} catch (error) {
  if (error instanceof Error && error.message === "provider-reported cost limit exceeded") {
    console.error("provider billing exceeds budget; check provider pricing/unit assumptions");
  }
  throw error;
}

Prevention

When it happens

Trigger: usage.providerReportedCostNanodollars > request.limits.maxEstimatedCostNanodollars in runEvalSessionCli, where providerReportedCostNanodollars comes from the provider's own cost accounting in the turn snapshot.

Common situations: 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.

Related errors


AI-assisted analysis of paperclipai/paperclip@01ad858492 (2026-09-10). Data as JSON: /api/errors/df8803f5008672a8. Report an issue: GitHub.