JuliusBrussee/caveman · error · Error

cave_reasoning_usage_unavailable

cave_reasoning_usage_unavailable

Error message

cave_reasoning_usage_unavailable

What it means

When running under an efficiency plan, reasoning (thinking) token usage is mandatory for budget accounting. If the provider did not report reasoning usage, the run fails closed rather than enforcing budgets against partial numbers.

Solutions

  1. Use a model/provider configuration that reports reasoning token usage
  2. Remove the efficiencyPlan requirement or run without the plan
  3. Update the provider adapter/gateway so reasoning usage fields pass through
Defensive patterns

Strategy: fallback

Validate before calling

if (efficiencyPlan && !model.supportsReasoningUsage) {
  throw new Error("plan requires a model that reports reasoning usage");
}

Try / catch

try { await runWithPlan(); } catch (e) { if (e.message === "cave_reasoning_usage_unavailable") return runWithoutPlan(); throw e; }

Prevention

When it happens

Trigger: streamAgent called with an efficiencyPlan while reasoningUsageUnavailable is true at the next model call — i.e. the provider/model did not return reasoning-token counts for the previous turn.

Common situations: Using a model or provider endpoint that omits reasoning usage fields (older API versions, non-thinking models, proxy gateways that strip usage details) while an efficiency plan is active.

Understand the failure class

Background: "invalid response format", "malformed payload", "missing data field": when an API returns 200 but the response shape is wrong — this error's family across 23 libraries.

Related errors


AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20). Data as JSON: /api/errors/ef903defbd9033bd. Report an issue: GitHub.

Appendix: source

Thrown at packages/agent/src/runtime.ts:1585

            );
          }
        }
        if (reservation !== undefined && reservation.length > 0) {
          markSpendIncomplete(reservation.map((item) => item.ledger));
          spendFailure ??= failure;
        }
      }
      finalMessage = message;
    };
    const streamFn: StreamFn = async (selected, context, streamOptions) => {
      if (options.signal?.aborted) {
        throw options.signal.reason ?? new Error("cave_run_aborted");
      }
      if (spendFailure) throw spendFailure;
      if (usageFailure) throw usageFailure;
      if (nestedUsage.incomplete) throw new Error("cave_nested_usage_incomplete");
      if (efficiencyPlan && reasoningUsageUnavailable) {
        throw new Error("cave_reasoning_usage_unavailable");
      }
      if (efficiencyPlan) {
        enforceSemanticBudgets(contextBill(lowered.ir), outputTokens, efficiencyPlan);
        if (reasoningTokens > efficiencyPlan.budgets.reasoning) {
          throw new Error("cave_reasoning_budget_exceeded");
        }
      }
      // The hard model-call ceiling is a stop condition, not a failure: ending
      // the run through the same graceful path as every other stop keeps the
      // partial work and the receipt intact. Checked before the
      // increment so exactly `maxModelCalls` calls are allowed.
      if (modelCalls >= maxModelCalls) {
        stopReason = "call_budget_exhausted";
        refusalPending = true;
        throw new Error("cave_run_stopped");
      }
      modelCalls++;
      // Between-calls stop point. Nothing is in flight here: the previous turn

View on GitHub (pinned to 3ee70a1026)