JuliusBrussee/caveman · error

cave_budget_on_exhausted_invalid

cave_budget_on_exhausted_invalid

Error message

cave_budget_on_exhausted_invalid

What it means

Raised by normalizeRunBudget when budget.onExhausted holds a value outside the supported set of exhaustion actions. The field selects what happens when the run exhausts its budget, so an unrecognized spelling cannot be silently defaulted.

Solutions

  1. Set onExhausted to one of the supported actions documented on RunBudget (e.g. the recognized throw/stop literals)
  2. Check for typos or a stale literal from an older caveman version
  3. Omit the field to accept the default exhaustion behavior
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/agent/src/budget.ts:116 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at packages/agent/src/budget.ts:116

    throw new Error("cave_budget_max_invalid");
  }
  const wrongInitial = denomination === "usd" ? budget.initialTokens : budget.initialUsd;
  if (wrongInitial !== undefined) throw new Error("cave_budget_denomination_ambiguous");
  const declaredInitial = denomination === "usd" ? budget.initialUsd : budget.initialTokens;
  const initial = declaredInitial ?? max;
  if (!Number.isFinite(initial) || initial <= 0 || initial > max) {
    throw new Error("cave_budget_initial_invalid");
  }
  if (denomination === "tokens" && !Number.isSafeInteger(initial)) {
    throw new Error("cave_budget_initial_invalid");
  }
  const outputFloorTokens = budget.outputFloorTokens ?? OUTPUT_CLAMP_FLOOR_TOKENS;
  if (!Number.isSafeInteger(outputFloorTokens) || outputFloorTokens <= 0) {
    throw new Error("cave_budget_output_floor_invalid");
  }
  const onExhausted = budget.onExhausted ?? "compact";
  if (onExhausted !== "compact" && onExhausted !== "stop") {
    throw new Error("cave_budget_on_exhausted_invalid");
  }
  return Object.freeze({
    denomination,
    max,
    initial,
    outputFloorTokens,
    onExhausted,
    compaction: normalizeCompaction(budget.compaction),
  });
}

/** Identity and shape of one prospective provider call. */
export interface CallCeiling {
  readonly provider: string;
  readonly model: string;
  /** Upper bound on the request's input tokens. Never an estimate that can be low. */
  readonly inputTokenCeiling: number;
  /** The output allowance this call would ask for. */

View on GitHub (pinned to 3ee70a1026)