{"record":{"id":"ac48c34afaa6ff68","repo":"JuliusBrussee/caveman","slug":"cave-budget-on-exhausted-invalid","errorCode":"cave_budget_on_exhausted_invalid","errorMessage":"cave_budget_on_exhausted_invalid","messagePattern":"cave_budget_on_exhausted_invalid","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/agent/src/budget.ts","lineNumber":116,"sourceCode":"    throw new Error(\"cave_budget_max_invalid\");\n  }\n  const wrongInitial = denomination === \"usd\" ? budget.initialTokens : budget.initialUsd;\n  if (wrongInitial !== undefined) throw new Error(\"cave_budget_denomination_ambiguous\");\n  const declaredInitial = denomination === \"usd\" ? budget.initialUsd : budget.initialTokens;\n  const initial = declaredInitial ?? max;\n  if (!Number.isFinite(initial) || initial <= 0 || initial > max) {\n    throw new Error(\"cave_budget_initial_invalid\");\n  }\n  if (denomination === \"tokens\" && !Number.isSafeInteger(initial)) {\n    throw new Error(\"cave_budget_initial_invalid\");\n  }\n  const outputFloorTokens = budget.outputFloorTokens ?? OUTPUT_CLAMP_FLOOR_TOKENS;\n  if (!Number.isSafeInteger(outputFloorTokens) || outputFloorTokens <= 0) {\n    throw new Error(\"cave_budget_output_floor_invalid\");\n  }\n  const onExhausted = budget.onExhausted ?? \"compact\";\n  if (onExhausted !== \"compact\" && onExhausted !== \"stop\") {\n    throw new Error(\"cave_budget_on_exhausted_invalid\");\n  }\n  return Object.freeze({\n    denomination,\n    max,\n    initial,\n    outputFloorTokens,\n    onExhausted,\n    compaction: normalizeCompaction(budget.compaction),\n  });\n}\n\n/** Identity and shape of one prospective provider call. */\nexport interface CallCeiling {\n  readonly provider: string;\n  readonly model: string;\n  /** Upper bound on the request's input tokens. Never an estimate that can be low. */\n  readonly inputTokenCeiling: number;\n  /** The output allowance this call would ask for. */","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/agent/src/budget.ts#L98-L134","documentation":"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.","triggerScenarios":"Thrown at packages/agent/src/budget.ts:116 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set onExhausted to one of the supported actions documented on RunBudget (e.g. the recognized throw/stop literals)","Check for typos or a stale literal from an older caveman version","Omit the field to accept the default exhaustion behavior"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}