Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

feat(pricing): D3 label DeepSeek-priced estimates as peak-rate upper bounds

time-attackf48d0c6bae77
diff --git a/src/core/brainstorm/orchestrator.ts b/src/core/brainstorm/orchestrator.ts
index 5f1640a124..b544692db1 100644
--- a/src/core/brainstorm/orchestrator.ts
+++ b/src/core/brainstorm/orchestrator.ts
@@ -60,6 +60,7 @@ 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 { ensureWellFormed } from '../text-safe.ts';
@@ -343,7 +344,7 @@ export async function previewCostAndWait(opts: {
const estimate = estimateCost(opts.profile, opts.model, opts.pricingOverrides, opts.judgeModel);
const interactive = opts.interactive ?? isInteractive();
opts.stderrWrite(
- `[${opts.profile.label}] estimated cost: ${fmtUsd(estimate)} (${opts.profile.k_close}×${opts.profile.m_far} = ${opts.profile.k_close * opts.profile.m_far} crosses × ${opts.profile.ideas_per_cross} ideas + judge)\n`
+ `[${opts.profile.label}] estimated cost: ${fmtUsd(estimate)}${peakRateNote([opts.model, opts.judgeModel])} (${opts.profile.k_close}×${opts.profile.m_far} = ${opts.profile.k_close * opts.profile.m_far} crosses × ${opts.profile.ideas_per_cross} ideas + judge)\n`
);
if (opts.skip) return { aborted: false, estimate };
if (!interactive) {
diff --git a/src/core/model-pricing.ts b/src/core/model-pricing.ts
index 235f3daaa5..ce80837698 100644
--- a/src/core/model-pricing.ts
+++ b/src/core/model-pricing.ts
@@ -254,3 +254,18 @@ 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/preflight.ts b/src/core/skillopt/preflight.ts
index c746fb12ee..3c15197c66 100644
--- a/src/core/skillopt/preflight.ts
+++ b/src/core/skillopt/preflight.ts
@@ -41,6 +41,7 @@
import { defaultMaxOutputTokens } from '../ai/gateway.ts';
import { 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';
@@ -251,7 +252,7 @@ export function formatPreflightReport(est: PreflightEstimate, opts: PreflightOpt
` Reflects: ${est.reflect_calls.toLocaleString()} calls`,
` Judges: ${est.judge_calls.toLocaleString()} calls`,
` Tokens: ~${(est.est_input_tokens / 1000).toFixed(0)}K in / ~${(est.est_output_tokens / 1000).toFixed(0)}K out`,
- ` Est. cost: ${est.est_cost_usd === null ? `unpriced (no price for ${est.unpriced_models.join(', ')}; register a rate with gbrain pricing set)` : `$${est.est_cost_usd.toFixed(2)}`} (cap: ${opts.maxCostUsd > 0 ? `$${opts.maxCostUsd.toFixed(2)}${opts.maxCostSource === 'default' ? ' default' : ''}` : 'uncapped'})`,
+ ` Est. cost: ${est.est_cost_usd === null ? `unpriced (no price for ${est.unpriced_models.join(', ')}; register a rate with gbrain pricing set)` : `$${est.est_cost_usd.toFixed(2)}${peakRateNote([opts.targetModel, opts.optimizerModel, ...(opts.judgeModels ?? [opts.judgeModel])])}`} (cap: ${opts.maxCostUsd > 0 ? `$${opts.maxCostUsd.toFixed(2)}${opts.maxCostSource === 'default' ? ' default' : ''}` : 'uncapped'})`,
est.largest_reservation
? ` Per call: largest single call reserves $${est.largest_reservation.reservation_usd!.toFixed(2)} (${est.largest_reservation.role} ${est.largest_reservation.model}, ${est.largest_reservation.max_output_tokens} output tokens)`
: '',
diff --git a/test/model-pricing.test.ts b/test/model-pricing.test.ts
index 4580ab04a2..03edb97f1a 100644
--- a/test/model-pricing.test.ts
+++ b/test/model-pricing.test.ts
@@ -290,3 +290,12 @@ 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');
+ 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('');
+ });
+});
diff --git a/test/skillopt/preflight-pricing-5563.test.ts b/test/skillopt/preflight-pricing-5563.test.ts
index 994b1ec2a4..3396b38f0d 100644
--- a/test/skillopt/preflight-pricing-5563.test.ts
+++ b/test/skillopt/preflight-pricing-5563.test.ts
@@ -120,3 +120,11 @@ describe('D19 skillopt cap flags (real parser)', () => {
expect(parseFlags([SKILL, '--max-cost-usd', '3', '--max-usd', '3']).maxCostUsd).toBe(3);
});
});
+
+describe('D3 the preflight labels DeepSeek peak-rate estimates', () => {
+ test('a deepseek target prints the peak-rate label next to the estimate', () => {
+ const opts = { ...base, targetModel: 'deepseek:deepseek-flash', optimizerModel: 'deepseek:deepseek-flash', judgeModel: 'deepseek:deepseek-flash' };
+ const report = formatPreflightReport(estimateCost(opts), opts);
+ expect(report).toMatch(/Est\. cost: \$\d+\.\d\d \(DeepSeek at peak rates, an upper bound; off-peak bills half\)/);
+ });
+});