Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

chore(lane-a): verify gates — size ratchets, agent contract, goldens, structural manifest

time-attack64fac4404520
diff --git a/docs/architecture/key-files/providers.md b/docs/architecture/key-files/providers.md
index 8820d66801..d4466de0f3 100644
--- a/docs/architecture/key-files/providers.md
+++ b/docs/architecture/key-files/providers.md
@@ -49,7 +49,7 @@ Current behavior and load-bearing invariants; history belongs in Git and CHANGEL
- `src/core/model-id.ts` — `splitProviderModelId(input: string | null | undefined): {provider: string | null, model: string}` shared parser for the pricing side. Splits on `:` first, then `/`. Defensive contract: null/undefined/empty/whitespace returns `{provider: null, model: ''}`. Five sites consume it (`src/core/anthropic-pricing.ts:estimateMaxCostUsd`, `src/core/budget/budget-tracker.ts:lookupPricing`, `src/core/eval-contradictions/cost-tracker.ts:pricingFor`, `src/core/model-config.ts:isAnthropicProvider`) so the pricing + classification surface has no parallel re-implementations of `provider:model` splitting — slash-form ids (`anthropic/claude-sonnet-4-6`) classify correctly instead of falling through to "unknown model". Distinct from the gateway-side `parseModelId` in `src/core/ai/model-resolver.ts`, which throws on bare names because routing needs an explicit provider; this one returns `{provider: null, model: 'bare'}` because pricing lookups happen against bare model ids. Pinned by `test/model-id.test.ts`.
-- `src/core/model-pricing.ts` — single source of truth for paid-cloud CHAT/completion model pricing (USD per 1M tokens, input | output). `CANONICAL_PRICING` is a `provider:model`-keyed table (Anthropic Opus 5/4.8/4.7/4.6 `$5/$25`, Sonnet 4.6 `$3/$15`, Haiku 4.5 `$1/$5` both dateless + dated, plus OpenAI / Google / Together / DeepSeek panel models). Exported as `gbrain/core/model-pricing` for companion evaluators to enforce the canonical price cap. `canonicalLookup(modelId)` resolves bare (`claude-opus-4-8`), colon (`anthropic:claude-opus-4-8`), and slash (`anthropic/...`) forms — bare ids default to the `anthropic:` provider; nested OpenRouter ids (`openrouter:anthropic/...`) intentionally MISS so OpenRouter markup isn't repriced as the inner vendor; after the exact match, a case-insensitive fallback folds BOTH sides (some canonical keys carry cased model tails verbatim), safe only while no two canonical keys collide case-insensitively (pinned by the drift guard). Every other chat-pricing table is a DERIVED view of this one (NOT a hand-copied duplicate), so cross-table price drift is structurally impossible. Embeddings live separately in `embedding-pricing.ts` (different unit). DeepSeek rows (`deepseek-flash`, its legacy alias `deepseek-v4-flash`, `deepseek-v4-pro`) carry the vendor's PEAK rate so caps bound the worst case; `peakRateNote(models)` labels estimates that use them. OpenRouter rows are the router's own catalogue rate, never the vendor's. `bun run check:recipe-pricing` (`scripts/check-recipe-pricing.ts`) requires every recipe touchpoint model to price or be named in the recipe's `unpriced_models`. Pinned by `test/model-pricing.test.ts` whose drift guard asserts each derived view equals canonical and that the cross-modal panel models are all present.
+- `src/core/model-pricing.ts` — single source of truth for paid-cloud CHAT/completion model pricing (USD per 1M tokens, input | output). `CANONICAL_PRICING` is a `provider:model`-keyed table (Anthropic Opus 5/4.8/4.7/4.6 `$5/$25`, Sonnet 4.6 `$3/$15`, Haiku 4.5 `$1/$5` both dateless + dated, plus OpenAI / Google / Together / DeepSeek panel models). Exported as `gbrain/core/model-pricing` for companion evaluators to enforce the canonical price cap. `canonicalLookup(modelId)` resolves bare (`claude-opus-4-8`), colon (`anthropic:claude-opus-4-8`), and slash (`anthropic/...`) forms — bare ids default to the `anthropic:` provider; nested OpenRouter ids (`openrouter:anthropic/...`) intentionally MISS so OpenRouter markup isn't repriced as the inner vendor; after the exact match, a case-insensitive fallback folds BOTH sides (some canonical keys carry cased model tails verbatim), safe only while no two canonical keys collide case-insensitively (pinned by the drift guard). Every other chat-pricing table is a DERIVED view of this one (NOT a hand-copied duplicate), so cross-table price drift is structurally impossible. Embeddings live separately in `embedding-pricing.ts` (different unit). DeepSeek rows (`deepseek-flash`, its legacy alias `deepseek-v4-flash`, `deepseek-v4-pro`) carry the vendor's PEAK rate so caps bound the worst case; `peakRateNote(models)` in `src/core/budget/reservation-cost.ts` labels estimates that use them. OpenRouter rows are the router's own catalogue rate, never the vendor's. `bun run check:recipe-pricing` (`scripts/check-recipe-pricing.ts`) requires every recipe touchpoint model to price or be named in the recipe's `unpriced_models`. Pinned by `test/model-pricing.test.ts` whose drift guard asserts each derived view equals canonical and that the cross-modal panel models are all present.
- `src/core/post-upgrade-reembed.ts` — Pure functions backing the `gbrain upgrade` chunker-bump cost prompt. `computeReembedEstimate(engine, model)` queries real SQL (`COUNT(*)` + `COALESCE(SUM(LENGTH(compiled_truth)) + SUM(LENGTH(timeline)), 0)`) on `pages WHERE chunker_version < MARKDOWN_CHUNKER_VERSION`. `formatReembedPrompt(est)` is the stderr-line formatter (count, model, cost estimate when priced). `runPostUpgradeReembedPrompt(engine, model, opts)` re-embeds only on consent: a TTY operator must answer `y` to `[chunker-bump] Re-embed now? [y/N]`; the default, EOF and every non-TTY run decline and print `REEMBED_DEFERRED_HINT` (`gbrain reindex --markdown`, or `gbrain repair safe-chunks --apply --no-embed` then `gbrain embed --stale`), so an unattended upgrade never spends. Reasons: `no_pending`, `bypassed_no_reembed`, `consent_required`, `tty_declined`, `tty_consented`. `GBRAIN_NO_REEMBED=1` skips the prompt with a doctor-warning marker. `opts.confirm` and `opts.isTTY` are test seams.
diff --git a/scripts/function-size-baseline.tsv b/scripts/function-size-baseline.tsv
index bdbc617b5b..9dbddc0ded 100644
--- a/scripts/function-size-baseline.tsv
+++ b/scripts/function-size-baseline.tsv
@@ -24,7 +24,6 @@ src/commands/mcp-expose.ts runPublish 443 seed: W5 baseline, refactor wave 1 (de
src/commands/migrate-engine.ts runMigrateEngine 405 seed: W5 baseline, refactor wave 1 (decomposition deferred to wave 2, plan D1)
src/commands/serve.ts installStdioLifecycle 323 seed: W5 baseline, refactor wave 1 (decomposition deferred to wave 2, plan D1); +7 GBRA-40 Lane D: facts drain install call and its shutdown stop (logic in installFactsDrain); +1 engine graduation (GBRA-50 G3): onShutdownReady hook for the graduation hand-off (logic in installGraduationHandoff)
src/commands/sources.ts runAdd 365 seed: W5 baseline, refactor wave 1 (decomposition deferred to wave 2, plan D1); +3 fix wave 4 #5673: connector sources print that autopilot keeps them synced after the first sync
-src/core/ai/gateway.ts chat 313 seed: W5 baseline, refactor wave 1 (decomposition deferred to wave 2, plan D1); +2 #5490: a configured chat_fallback_chain hands the call to chatWithFallback (loop lives in ai/chat-fallback.ts)
src/core/bootstrap/harness.ts applyHarness 1167 seed: W5 baseline, refactor wave 1 (decomposition deferred to wave 2, plan D1)
src/core/brainstorm/orchestrator.ts _runBrainstormInner 413 seed: W5 baseline, refactor wave 1 (decomposition deferred to wave 2, plan D1); +1 #5890 close-set spreads INTERNAL_BREADTH_SEARCH_OPTS
src/core/check-resolvable.ts checkResolvable 419 seed: W5 baseline, refactor wave 1 (decomposition deferred to wave 2, plan D1)
diff --git a/scripts/structural-suites.tsv b/scripts/structural-suites.tsv
index 295cb8c9c3..1689fb4c65 100644
--- a/scripts/structural-suites.tsv
+++ b/scripts/structural-suites.tsv
@@ -219,7 +219,8 @@ test/migrations-v0_14_0.test.ts Bug 5 + Bug 8 — v0_14_0 module shape 3 bun-fil
test/migrations-v0_14_0.test.ts Bug 5 — Phase B host-work entry dedup 2 readFileSync
test/migrations-v0_14_0.test.ts Bug 8 — max_stalled default bumped in schema files 3 bun-file
test/migrations-v0_22_4.test.ts v0.22.4 migration (B11) 10 readFileSync
-test/model-pricing.test.ts DRIFT GUARD — derived views stay equal to canonical (re-hardcode trip-wire) 4 readFileSync
+test/model-pricing.test.ts D3 peak-rate label 1 readFileSync
+test/model-pricing.test.ts DRIFT GUARD — derived views stay equal to canonical (re-hardcode trip-wire) 6 readFileSync
test/model-pricing.test.ts no heavy import (cycle guard) 1 readFileSync
test/ocr-run-budget.test.ts doctor ocr_health surfaces the budget-skip counter (#3973) 1 doctor-source-helper
test/openclaw-plugin-manifest.test.ts bundled-skill reference closure (nothing bundled points at a non-bundled skill) 1 readFileSync
diff --git a/src/core/ai/gateway.ts b/src/core/ai/gateway.ts
index cf548a4113..2b570bd017 100644
--- a/src/core/ai/gateway.ts
+++ b/src/core/ai/gateway.ts
@@ -34,7 +34,7 @@ import { z } from 'zod';
import { DEFAULT_CHARS_PER_TOKEN, DEFAULT_SAFETY_FACTOR, embedRequestMaxInputTokens, planEmbedRequests, rerankRequestMaxInputTokens, truncateEmbedInputs } from './embed-batch-plan.ts';
export { splitByTokenBudget, capBatchItems, NO_BATCH_CAP_SUB_BATCH_ITEMS } from './embed-batch-plan.ts';
-import { BudgetTracker, type BudgetKind, type BudgetReservation } from '../budget/budget-tracker.ts';
+import { BudgetTracker, type BudgetReservation } from '../budget/budget-tracker.ts';
import { failedCallUsage, recordOnTracker } from './budget-record.ts';
import { chatWithFallback, normalizeChatFallbackChain } from './chat-fallback.ts';
import type {
@@ -1579,18 +1579,12 @@ export async function embed(texts: string[], opts?: EmbedOpts): Promise<Float32A
const sent = sendableEmbeddingInputs(truncated);
const batches = sent.length ? planEmbedRequests(sent.map(i => truncated[i]!), recipe, effectiveSafetyFactor(recipe), envCap) : [];
- // Reserve for the worst-case batch token count after every preflight that
- // can throw (dims, batch planning), so a config error leaves no hold.
- // Embeddings have no output rate, so maxOutputTokens=0. record() at the end
- // uses the actual total reported by the SDK and settles this reservation.
+ // Reserve the worst-case batch tokens after every preflight that can throw
+ // (dims, batch planning), so a config error leaves no hold; record() below settles it.
const charsPerToken = recipe.touchpoints?.embedding?.chars_per_token ?? DEFAULT_CHARS_PER_TOKEN;
const totalChars = truncated.reduce((s, t) => s + t.length, 0);
const reservation = tracker?.reserve({
- modelId: `${recipe.id}:${modelId}`,
- estimatedInputTokens: Math.ceil(totalChars / Math.max(charsPerToken, 1)),
- maxOutputTokens: 0,
- kind: 'embed',
- label: 'gateway.embed',
+ modelId: `${recipe.id}:${modelId}`, estimatedInputTokens: Math.ceil(totalChars / Math.max(charsPerToken, 1)), maxOutputTokens: 0, kind: 'embed', label: 'gateway.embed',
});
const allEmbeddings: Float32Array[] = [];
@@ -3450,27 +3444,14 @@ export async function chat(opts: ChatOpts): Promise<ChatResult> {
const estimatedInputTokens = estimateChatInputTokens(opts);
const maxOutputTokens = opts.maxTokens ?? defaultMaxOutputTokens(modelStrEarly);
- // TX5: reserve BEFORE the provider call. Throws BudgetExhausted on cost,
- // runtime, or no_pricing (when cap is set). Pre-resolution model id is
- // fine here — resolveChatProvider would map aliases the same way for the
- // cost lookup. record() uses the real result.model and settles this
- // reservation by id; the finally frees it when the attempt never billed
- // (provider resolution failed, an invocation policy refused it).
- const reservation = tracker?.reserve({
- modelId: modelStrEarly,
- estimatedInputTokens,
- maxOutputTokens,
- kind: 'chat' as BudgetKind,
- label: 'gateway.chat',
- });
+ // TX5: reserve BEFORE the provider call (BudgetExhausted on cost, runtime,
+ // or no_pricing under a user cap) with the pre-resolution model id. record()
+ // settles the reservation by id; the finally frees an attempt that never
+ // billed (provider resolution failed, an invocation policy refused it).
+ const reservation = tracker?.reserve({ modelId: modelStrEarly, estimatedInputTokens, maxOutputTokens, kind: 'chat', label: 'gateway.chat' });
+ const chatRecord = { requestedModelId: modelStrEarly, purpose: opts.purpose, label: 'gateway.chat', reservation };
try {
- return await chatAdmitted(opts, {
- tracker,
- modelStrEarly,
- estimatedInputTokens,
- maxOutputTokens,
- chatRecord: { requestedModelId: modelStrEarly, purpose: opts.purpose, label: 'gateway.chat', reservation },
- });
+ return await chatAdmitted(opts, { tracker, modelStrEarly, estimatedInputTokens, maxOutputTokens, chatRecord });
} finally {
tracker?.release(reservation);
}
@@ -3478,10 +3459,7 @@ export async function chat(opts: ChatOpts): Promise<ChatResult> {
/** One admitted chat attempt: the provider call plus its budget record. */
async function chatAdmitted(opts: ChatOpts, admitted: {
- tracker: BudgetTracker | null;
- modelStrEarly: string;
- estimatedInputTokens: number;
- maxOutputTokens: number;
+ tracker: BudgetTracker | null; modelStrEarly: string; estimatedInputTokens: number; maxOutputTokens: number;
chatRecord: { requestedModelId: string; purpose?: string; label: string; reservation?: BudgetReservation };
}): Promise<ChatResult> {
const { tracker, modelStrEarly, estimatedInputTokens, maxOutputTokens, chatRecord } = admitted;
@@ -3512,8 +3490,7 @@ async function chatAdmitted(opts: ChatOpts, admitted: {
threw = err;
throw err;
} finally {
- // A policy refusal never reached the provider: nothing to charge, and
- // chat()'s finally releases the reservation.
+ // A policy refusal never reached the provider: chat() releases its hold.
if (res || threw) {
recordOnTracker(tracker, res
? { ...chatRecord, modelId: res.model ?? modelStrEarly, inputTokens: res.usage.input_tokens, outputTokens: res.usage.output_tokens }
@@ -4307,17 +4284,12 @@ export async function rerank(input: RerankInput): Promise<RerankResult[]> {
// Reranker pricing resolves through the embedding pricing table (the default
// model is priced); an unpriced custom reranker still hits the warn-once
// (no cap) / TX2 hard-fail (cap set) path. record() below settles it by
- // id; a policy refusal releases it in the finally.
+ // id; a policy refusal releases it in the finally. The estimate honors the
+ // recipe's tokenizer density (Voyage declares ~1 char/token on dense
+ // payloads) so a cap cannot be under-reserved ~4× by CJK/JSON docs.
+ const rerankChars = input.query.length + input.documents.reduce((s, d) => s + d.length, 0);
const reservation = tracker?.reserve({
- modelId: modelStr,
- // Honor the recipe's tokenizer density (Voyage declares ~1 char/token on
- // dense payloads) so a cap cannot be under-reserved ~4× by CJK/JSON docs.
- estimatedInputTokens: Math.ceil(
- (input.query.length + input.documents.reduce((s, d) => s + d.length, 0)) / (recipe.touchpoints.embedding?.chars_per_token ?? 4),
- ),
- maxOutputTokens: 0,
- kind: 'rerank',
- label: 'gateway.rerank',
+ modelId: modelStr, estimatedInputTokens: Math.ceil(rerankChars / (recipe.touchpoints.embedding?.chars_per_token ?? 4)), maxOutputTokens: 0, kind: 'rerank', label: 'gateway.rerank',
});
// Timeout via AbortController; merges with caller-supplied signal.
diff --git a/src/core/brainstorm/orchestrator.ts b/src/core/brainstorm/orchestrator.ts
index b544692db1..90e423ea32 100644
--- a/src/core/brainstorm/orchestrator.ts
+++ b/src/core/brainstorm/orchestrator.ts
@@ -60,9 +60,8 @@ import {
type BrainstormCostGate,
} from './cost-gate.ts';
import { capNotice } from '../budget/cap-flag.ts';
-import { peakRateNote } from '../model-pricing.ts';
import { pricingSetCommand } from '../budget/no-pricing.ts';
-import type { PricingOverrides } from '../budget/reservation-cost.ts';
+import { peakRateNote, type PricingOverrides } from '../budget/reservation-cost.ts';
import { ensureWellFormed } from '../text-safe.ts';
// ---------------------------------------------------------------------------
@@ -666,10 +665,7 @@ async function _runBrainstormInner(
// ---- Phase 0: cost preview + TTY grace ----
const { aborted, estimate } = await previewCostAndWait({
- profile,
- model: plan.chatModel,
- pricingOverrides: plan.gate.pricingOverrides,
- judgeModel: plan.gate.judgeModel,
+ profile, model: plan.chatModel, pricingOverrides: plan.gate.pricingOverrides, judgeModel: plan.gate.judgeModel,
skip: opts.skipCostPreview === true,
stderrWrite: stderr, capUsd: plan.gate.ceilingUsd ?? undefined,
});
@@ -889,8 +885,7 @@ async function _runBrainstormInner(
crossModel = result.model;
// Mid-run cost guard: if running spend already exceeds the projected
// ceiling or the strict-budget multiplier, abort the remaining crosses.
- const runningUsd = chatCostUsd(
- result.model, totalUsage.input_tokens, totalUsage.output_tokens, plan.gate.pricingOverrides);
+ const runningUsd = chatCostUsd(result.model, totalUsage.input_tokens, totalUsage.output_tokens, plan.gate.pricingOverrides);
if (maxCostUsd !== null && runningUsd > maxCostUsd) {
throw new BudgetExhausted(
`${profile.label}: running cost ${fmtUsd(runningUsd)} exceeded --max-cost ${fmtUsd(maxCostUsd)} mid-run; aborting remaining crosses`,
diff --git a/src/core/budget/reservation-cost.ts b/src/core/budget/reservation-cost.ts
index dfb775e173..9e3f2198bc 100644
--- a/src/core/budget/reservation-cost.ts
+++ b/src/core/budget/reservation-cost.ts
@@ -245,3 +245,18 @@ export function reservationCostUsd(
): number | null {
return usageCostUsd(modelId, inputTokens, maxOutputTokens, kind, overrides);
}
+
+/**
+ * D3: providers whose rows carry the PEAK rate of a time-of-day price
+ * (DeepSeek bills half off-peak). A cap must bound the worst case, so caps
+ * and estimates use peak; this labels an estimate so the overstatement is
+ * never silent. Router rows (`openrouter:deepseek/...`) are the router's own
+ * flat rate and are not labelled.
+ */
+const PEAK_RATE_PROVIDERS: ReadonlySet<string> = new Set(['deepseek']);
+
+/** The label an estimate carries when any of its models prices at a peak row, else ''. */
+export function peakRateNote(models: Array<string | null | undefined>): string {
+ const peak = models.some((m) => PEAK_RATE_PROVIDERS.has(splitProviderModelId(m).provider ?? ''));
+ return peak ? ' (DeepSeek at peak rates, an upper bound; off-peak bills half)' : '';
+}
diff --git a/src/core/cycle/synthesize-concepts.ts b/src/core/cycle/synthesize-concepts.ts
index 4c30ea447f..9836cf6d54 100644
--- a/src/core/cycle/synthesize-concepts.ts
+++ b/src/core/cycle/synthesize-concepts.ts
@@ -35,7 +35,7 @@ import { createGlobalLlmHaltTracker, haltedClassOf, type GlobalLlmErrorClass } f
import { importFromContent } from '../import-file.ts';
import { serializeMarkdown } from '../markdown.ts';
import { canonicalLookup, type ModelPricing } from '../model-pricing.ts';
-import { priceFor } from '../budget/reservation-cost.ts';
+import { priceFor, type PricingOverrides } from '../budget/reservation-cost.ts';
import { loadPricingOverrides } from '../budget/budget-tracker.ts';
import { pricingSetCommand } from '../budget/no-pricing.ts';
import { createHash } from 'node:crypto';
@@ -58,6 +58,17 @@ const FALLBACK_PRICING: ModelPricing = canonicalLookup('anthropic:claude-sonnet-
input: 3.0,
output: 15.0,
};
+/** The rate a narrative call meters at: the shared resolver, else the Sonnet fallback, naming each fallback model once. */
+function narrativePricing(model: string, overrides: PricingOverrides | undefined, fallbackModels: Set<string>, budgetUsd: number): ModelPricing {
+ const priced = priceFor(model, 'chat', overrides);
+ if (priced) return priced.pricing;
+ if (!fallbackModels.has(model)) {
+ fallbackModels.add(model);
+ console.error(`[synthesize_concepts] ${model} has no pricing; metering it at Sonnet-tier rates against the $${budgetUsd.toFixed(2)} phase budget. To meter its real price, look it up and register it: ${pricingSetCommand(model, 'chat')}`);
+ }
+ return FALLBACK_PRICING;
+}
+
const TIER_T1_MIN = 10;
const TIER_T2_MIN = 5;
const TIER_T3_MIN = 2;
@@ -364,14 +375,7 @@ export async function runPhaseSynthesizeConcepts(
// refresh rate.
await maybeYield();
llmHalt.reset();
- // Price from the model that actually answered, through the shared
- // resolver. A miss → Sonnet-tier FALLBACK_PRICING (see constant above).
- const priced = priceFor(result.model, 'chat', pricingOverrides);
- if (!priced && !pricingFallbackModels.has(result.model)) {
- pricingFallbackModels.add(result.model);
- console.error(`[synthesize_concepts] ${result.model} has no pricing; metering it at Sonnet-tier rates against the $${budgetCap.toFixed(2)} phase budget. To meter its real price, look it up and register it: ${pricingSetCommand(result.model, 'chat')}`);
- }
- const pricing = priced?.pricing ?? FALLBACK_PRICING;
+ const pricing = narrativePricing(result.model, pricingOverrides, pricingFallbackModels, budgetCap);
estimatedSpendUsd +=
(result.usage.input_tokens * pricing.input +
result.usage.output_tokens * pricing.output) /
diff --git a/src/core/model-pricing.ts b/src/core/model-pricing.ts
index ce80837698..235f3daaa5 100644
--- a/src/core/model-pricing.ts
+++ b/src/core/model-pricing.ts
@@ -254,18 +254,3 @@ function canonicalFoldedView(): Record<string, ModelPricing> {
}
return _canonicalFoldedView;
}
-
-/**
- * D3: providers whose rows carry the PEAK rate of a time-of-day price
- * (DeepSeek bills half off-peak). A cap must bound the worst case, so caps
- * and estimates use peak; this labels an estimate so the overstatement is
- * never silent. Router rows (`openrouter:deepseek/...`) are the router's own
- * flat rate and are not labelled.
- */
-const PEAK_RATE_PROVIDERS: ReadonlySet<string> = new Set(['deepseek']);
-
-/** The label an estimate carries when any of its models prices at a peak row, else ''. */
-export function peakRateNote(models: Array<string | null | undefined>): string {
- const peak = models.some((m) => PEAK_RATE_PROVIDERS.has(splitProviderModelId(m).provider ?? ''));
- return peak ? ' (DeepSeek at peak rates, an upper bound; off-peak bills half)' : '';
-}
diff --git a/src/core/skillopt/orchestrator.ts b/src/core/skillopt/orchestrator.ts
index 66ecab8d4d..0dd550bd72 100644
--- a/src/core/skillopt/orchestrator.ts
+++ b/src/core/skillopt/orchestrator.ts
@@ -292,8 +292,7 @@ export async function runSkillOpt(opts: SkillOptOpts): Promise<RunSkillOptResult
throw errorFor({
class: 'BudgetExhausted',
code: 'no_pricing',
- message: preflightResult.abort_reason ?? 'no pricing for a model under the cost cap',
- hint: 'No model call was made. Register the rate with the command above and retry, or pass --max-usd off to run uncapped.',
+ message: `${preflightResult.abort_reason} No model call was made; or pass --max-usd off to run uncapped.`,
});
}
if (!preflightResult.proceed) {
diff --git a/src/core/skillopt/preflight.ts b/src/core/skillopt/preflight.ts
index 3c15197c66..4198fee4ae 100644
--- a/src/core/skillopt/preflight.ts
+++ b/src/core/skillopt/preflight.ts
@@ -39,9 +39,8 @@
*/
import { defaultMaxOutputTokens } from '../ai/gateway.ts';
-import { priceFor, reservationCostUsd, type PricingOverrides } from '../budget/reservation-cost.ts';
+import { peakRateNote, priceFor, reservationCostUsd, type PricingOverrides } from '../budget/reservation-cost.ts';
import { noPricingGuidance, noPricingMessage, type NoPricingGuidance } from '../budget/no-pricing.ts';
-import { peakRateNote } from '../model-pricing.ts';
import { skilloptOutputCap } from './output-cap.ts';
import { JUDGE_SITE_MAX_TOKENS } from './score.ts';
import { VALIDATION_RUNS_PER_TASK } from './types.ts';
diff --git a/test/fixtures/goldens/cli/tools-json.json b/test/fixtures/goldens/cli/tools-json.json
index e4859bb227..1318286705 100644
--- a/test/fixtures/goldens/cli/tools-json.json
+++ b/test/fixtures/goldens/cli/tools-json.json
@@ -2,8 +2,8 @@
"golden": {
"exitCode": 0,
"stderr": "",
- "stdoutBytes": 203079,
- "stdoutSha256": "3f2a347db6f4a41890023a83565e4a811e9fb1127b881fad419a24f3365f3d21",
+ "stdoutBytes": 203176,
+ "stdoutSha256": "c24e422ed04758b5f72cd2af066e7408efa437230f0beb4f26f19b5033136c11",
"toolNames": [
"remember",
"entity",
@@ -6213,7 +6213,7 @@
"type": "number"
},
"max_cost_usd": {
- "description": "Default 5.00",
+ "description": "Default 5.00 (an unpriced model then warns and runs). When set, an unpriced model is refused with no_pricing.",
"type": "number"
},
"no_mutate": {
diff --git a/test/fixtures/goldens/exports/types.json b/test/fixtures/goldens/exports/types.json
index 0a6ed63e01..2eda4ba153 100644
--- a/test/fixtures/goldens/exports/types.json
+++ b/test/fixtures/goldens/exports/types.json
@@ -2891,6 +2891,7 @@
"judgeModel: string",
"lr: number",
"lrSchedule: \"cosine\" | \"linear\" | \"constant\"",
+ "maxCostSource?: \"default\" | \"user\" | undefined",
"maxCostUsd: number",
"maxRuntimeMin: number",
"mode: \"patch\" | \"rewrite\"",
diff --git a/test/model-pricing.test.ts b/test/model-pricing.test.ts
index 03edb97f1a..7c161544ee 100644
--- a/test/model-pricing.test.ts
+++ b/test/model-pricing.test.ts
@@ -293,7 +293,7 @@ describe('canonicalLookup — case-insensitive fallback (#4123 / TODOS case-sens
describe('D3 peak-rate label', () => {
test('an estimate touching a deepseek row says it is a peak-rate upper bound; router rows and others do not', async () => {
- const { peakRateNote } = await import('../src/core/model-pricing.ts');
+ const { peakRateNote } = await import('../src/core/budget/reservation-cost.ts');
expect(peakRateNote(['deepseek:deepseek-flash'])).toBe(' (DeepSeek at peak rates, an upper bound; off-peak bills half)');
expect(peakRateNote(['anthropic:claude-sonnet-5-5', 'deepseek:deepseek-v4-pro'])).not.toBe('');
expect(peakRateNote(['openrouter:deepseek/deepseek-v4-flash-0731', 'anthropic:claude-sonnet-5-5', undefined])).toBe('');