fix(billing): the chat plan no longer caps a model at 1 point per run; the chat cost estimate uses the measured numbers (BUG-2231)
The chat is charged its chat.standard feature price; the plan's literal ceiling of 1 on the model's own per-run points only stopped that from being tuned. Positive whole numbers are still required. No stored price is changed. The launch page estimate for chat.standard is the 2026-11-23 measured first-turn average (about 176k input, 22.7k output tokens incl. the repair call). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DbBXp2Vp62Ur3C7yRWQdSq
This commit is contained in:
@@ -18,7 +18,11 @@ export type LaunchFeatureKey = (typeof LAUNCH_FEATURES)[number]["key"];
|
||||
|
||||
/** The only tier a model created in the admin has; premium / internal are not used anywhere. */
|
||||
export const LAUNCH_MODEL_TIER = "standard";
|
||||
/** The chat plan refuses a model whose per-run points exceed this (consultation-plan.ts). */
|
||||
/**
|
||||
* The per-run points written on a model published here. It is not the price: every billed feature, chat included, is
|
||||
* charged its 「功能价格」 (feature_pricing, chat.standard for chat). 原值注释:「The chat plan refuses a model whose per-run
|
||||
* points exceed this」;新值:计划不再设上限(BUG-2231),这个值只是模型记录上的字段。
|
||||
*/
|
||||
export const LAUNCH_MODEL_CREDIT_COST = 1;
|
||||
|
||||
export const DEFAULT_USD_TO_CNY = 7.2;
|
||||
@@ -199,9 +203,12 @@ export function launchMargin(saleCny: number | null, costCny: number | null): nu
|
||||
* Tokens one successful run typically uses, measured locally on 2026-11-16
|
||||
* (one sample each, DeepSeek flash). Used only for the estimate the launch page
|
||||
* shows while a feature has no settled usage with a price yet (BUG-1937).
|
||||
* BUG-2231: chat.standard 原值 { input: 100_000, output: 13_000 };新值:2026-11-23 本地五个首轮回答的平均(含那一次补漏调用)
|
||||
* 输入 175,768、输出 22,650 token,取整为 176_000 / 22_700;原因:BUG-2229 的写法让首轮回答变长、卡上多了预先算好的表。
|
||||
* 追问(一份)约输入 185,000、输出 6,400 token:输入和首轮相近、输出少得多,按首轮估是上限。
|
||||
*/
|
||||
export const LAUNCH_TYPICAL_TOKENS: Readonly<Record<LaunchFeatureKey, { input: number; output: number }>> = {
|
||||
"chat.standard": { input: 100_000, output: 13_000 },
|
||||
"chat.standard": { input: 176_000, output: 22_700 },
|
||||
"report.full": { input: 126_000, output: 33_000 },
|
||||
"annual.full": { input: 108_000, output: 86_000 },
|
||||
"synastry.full": { input: 360_000, output: 102_000 },
|
||||
|
||||
@@ -12,7 +12,11 @@ export const consultationDepthValues = ["concise", "standard", "deep", "research
|
||||
export const consultationTimingHorizonValues = ["next_3_months", "next_12_months", "next_24_months", "long_term"] as const;
|
||||
export const consultationEvidenceCategoryValues = ["natal_foundation", "domain", "timing", "validation"] as const;
|
||||
export const consultationPlanVersion = "consultation-plan-v2" as const;
|
||||
export const consultationPlanMaxCreditCost = 1 as const;
|
||||
// 原值:consultationPlanMaxCreditCost = 1,计划只接受每次点数不超过 1 的模型;新值:去掉这个上限,计划记下这次模型的点数(正整数);
|
||||
// 原因:BUG-2231,负责人想把聊天定在 10 点左右。实际扣的点一直来自后台「功能价格」里的 chat.standard(consult/settlement.ts
|
||||
// reserveCredit → resolveFeaturePricing),模型自己的点数(后台上线配置固定写 1)只用来过这道门,上限 1 让它无法和价格分开调。
|
||||
/** The model's per-run points when the caller does not say (research scripts, tests). */
|
||||
export const consultationPlanDefaultCreditCost = 1;
|
||||
|
||||
const consultationPrecisionBoundaryValues = ["server_evidence_required", "precise_timing_blocked"] as const;
|
||||
|
||||
@@ -30,7 +34,7 @@ export const consultationPlanSchema = z.object({
|
||||
"general_no_birth_time",
|
||||
]),
|
||||
precisionBoundary: z.enum(consultationPrecisionBoundaryValues),
|
||||
maxCreditCost: z.literal(consultationPlanMaxCreditCost),
|
||||
maxCreditCost: z.number().int().positive(),
|
||||
}).strict();
|
||||
|
||||
type DeepReadonly<T> = T extends (...args: never[]) => unknown
|
||||
@@ -87,7 +91,8 @@ export function validateConsultationPlan(
|
||||
if (plan.precisionBoundary !== precisionBoundaryFor(input.consultationMode)) {
|
||||
throw new ConsultationPlanValidationError("plan_precision_mismatch");
|
||||
}
|
||||
if (!Number.isInteger(input.modelCreditCost) || input.modelCreditCost < 1 || input.modelCreditCost > plan.maxCreditCost) {
|
||||
// BUG-2231: only a positive whole number of points is meaningful; no upper bound (the price is chat.standard).
|
||||
if (!Number.isInteger(input.modelCreditCost) || input.modelCreditCost < 1) {
|
||||
throw new ConsultationPlanValidationError("plan_cost_ceiling_exceeded");
|
||||
}
|
||||
return plan;
|
||||
@@ -112,7 +117,7 @@ export function createConsultationPlan(input: {
|
||||
requiredEvidenceCategories: [...consultationEvidenceCategoryValues],
|
||||
birthTimeMode: consultationMode,
|
||||
precisionBoundary: precisionBoundaryFor(consultationMode),
|
||||
maxCreditCost: consultationPlanMaxCreditCost,
|
||||
maxCreditCost: Number.isInteger(input.modelCreditCost) && (input.modelCreditCost ?? 0) >= 1 ? input.modelCreditCost! : consultationPlanDefaultCreditCost,
|
||||
}));
|
||||
return input.modelCreditCost === undefined
|
||||
? plan
|
||||
|
||||
@@ -3,7 +3,7 @@ import test from "node:test";
|
||||
import { z } from "zod";
|
||||
import {
|
||||
ConsultationPlanValidationError,
|
||||
consultationPlanMaxCreditCost,
|
||||
consultationPlanDefaultCreditCost,
|
||||
createConsultationPlan,
|
||||
validateConsultationPlan,
|
||||
} from "../src/lib/consultation-plan.ts";
|
||||
@@ -20,7 +20,7 @@ for (const theme of consultationDomainIds) {
|
||||
assert.equal(plan.plan_version, "consultation-plan-v2");
|
||||
assert.equal(plan.birthTimeMode, "verified_chart");
|
||||
assert.equal(plan.precisionBoundary, "server_evidence_required");
|
||||
assert.equal(plan.maxCreditCost, consultationPlanMaxCreditCost);
|
||||
assert.equal(plan.maxCreditCost, consultationPlanDefaultCreditCost);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -77,20 +77,18 @@ test("rejects mode or precision tampering", () => {
|
||||
);
|
||||
});
|
||||
|
||||
test("rejects model cost above the release consultation ceiling", () => {
|
||||
assert.throws(
|
||||
() => createConsultationPlan({
|
||||
userIntent: "事业如何",
|
||||
theme: "career",
|
||||
consultationMode: "verified_chart",
|
||||
modelCreditCost: consultationPlanMaxCreditCost + 1,
|
||||
}),
|
||||
(error: unknown) => error instanceof ConsultationPlanValidationError
|
||||
&& error.code === "plan_cost_ceiling_exceeded",
|
||||
);
|
||||
// 原值:「rejects model cost above the release consultation ceiling」——模型点数 2 被 plan_cost_ceiling_exceeded 拒绝;
|
||||
// 新值:点数 10 照常建计划,计划记下 10;原因:BUG-2231,上限 1 去掉,聊天的价格来自后台 chat.standard 功能价格。
|
||||
test("BUG-2231: a model's per-run points above 1 are accepted and recorded on the plan", () => {
|
||||
const plan = createConsultationPlan({
|
||||
userIntent: "事业如何",
|
||||
theme: "career",
|
||||
consultationMode: "verified_chart",
|
||||
modelCreditCost: 10,
|
||||
});
|
||||
assert.equal(plan.maxCreditCost, 10);
|
||||
});
|
||||
|
||||
|
||||
test("rejects non-positive or fractional model costs", () => {
|
||||
for (const modelCreditCost of [0, -1, 0.5, Number.NaN, Number.POSITIVE_INFINITY]) {
|
||||
assert.throws(
|
||||
|
||||
@@ -161,7 +161,8 @@ test("consultation plans are server-owned and bounded", () => {
|
||||
assert.match(tools, /modelOutput: toModelOutput\(agentContext, domainPlan, domain\)/);
|
||||
assert.match(tools, /modelOutput: toModelOutput[\s\S]*ctx\.state\.consultationToolCompleted = true/);
|
||||
assert.match(plan, /precisionBoundary/);
|
||||
assert.match(plan, /consultationPlanMaxCreditCost = 1/);
|
||||
// 原值:/consultationPlanMaxCreditCost = 1/;新值:计划只要求正整数点数、不设上限;原因:BUG-2231(聊天价格来自 chat.standard)。
|
||||
assert.match(plan, /maxCreditCost: z\.number\(\)\.int\(\)\.positive\(\)/);
|
||||
const modelToolInput = tools.slice(tools.indexOf("const consultationToolInputSchema"), tools.indexOf("const MAX_RECORDED_STEPS"));
|
||||
assert.doesNotMatch(modelToolInput, /birth|latitude|longitude|engine|script|credit/i);
|
||||
const prepareCall = route.slice(route.indexOf("prepared = await prepareConsultationRoute"), route.indexOf("const modelSelection"));
|
||||
|
||||
Reference in New Issue
Block a user