From 15251469e1d4d97139df885119c8d585144599d8 Mon Sep 17 00:00:00 2001 From: ZouR-Ma <2605315944@qq.com> Date: Fri, 27 Nov 2026 19:27:37 +0800 Subject: [PATCH] fix(providers): read the Step model output limit from max_output_tokens The Step catalog set maxTokens to the context window because /v1/models did not report an output limit, so the model picker showed the same value for context and output. Read max_output_tokens when the endpoint reports a positive value; models without it keep falling back to max_input_tokens. --- packages/coding-agent/test/step-provider.test.ts | 3 ++- packages/providers/src/step-provider/index.ts | 15 ++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/coding-agent/test/step-provider.test.ts b/packages/coding-agent/test/step-provider.test.ts index 7aec3a6fd..7c48385ba 100644 --- a/packages/coding-agent/test/step-provider.test.ts +++ b/packages/coding-agent/test/step-provider.test.ts @@ -480,6 +480,7 @@ describe("Step dynamic model discovery", () => { id: "step-vision", model_type: "大语言模型", max_input_tokens: 131072, + max_output_tokens: 8192, enable_reason: false, enable_vision_input: true, }, @@ -506,7 +507,7 @@ describe("Step dynamic model discovery", () => { expect.objectContaining({ id: "step-vision", contextWindow: 131072, - maxTokens: 131072, + maxTokens: 8192, reasoning: false, input: ["text", "image"], }), diff --git a/packages/providers/src/step-provider/index.ts b/packages/providers/src/step-provider/index.ts index 8f76a8941..54ec5a019 100644 --- a/packages/providers/src/step-provider/index.ts +++ b/packages/providers/src/step-provider/index.ts @@ -112,6 +112,8 @@ const STEP_MODEL_DEFAULTS = { interface StepModelMeta { /** `max_input_tokens` -> context window. */ contextWindow?: number; + /** `max_output_tokens` -> output limit (only models configured with one report it). */ + maxTokens?: number; /** `enable_reason` -> extended-thinking support. */ reasoning?: boolean; /** `enable_vision_input` -> image input support. */ @@ -135,8 +137,9 @@ function stepModelConfig(id: string, name: string, baseUrl?: string, meta?: Step input: meta?.vision ? ["text", "image"] : ["text"], cost: { ...STEP_MODEL_DEFAULTS.cost }, contextWindow, - // The endpoint reports no max-output; default it to the input window. - maxTokens: contextWindow, + // Models without a configured output limit omit `max_output_tokens`; + // the input window is then the only known bound. + maxTokens: meta?.maxTokens ?? contextWindow, // When the list endpoint reports supported efforts (e.g. step_plan), carry // them so `/effort` is correct without a per-model lookup. ...(hasEfforts ? { thinkingLevelMap: stepThinkingLevelMap(meta!.efforts!) } : {}), @@ -445,9 +448,10 @@ export function stepModelsDetailBaseUrl(baseUrl: string): string { * Discover the chat-capable models the current credential can use from * `{base}/v1/models`, filtered by the endpoint's `model_type` (see * {@link STEP_USABLE_MODEL_TYPES}). Per-model capabilities are taken from the - * response where present: `max_input_tokens` -> context window, `enable_reason` - * -> thinking support, `enable_vision_input` -> image input; missing fields use - * the metadata defaults. + * response where present: `max_input_tokens` -> context window, + * `max_output_tokens` -> output limit, `enable_reason` -> thinking support, + * `enable_vision_input` -> image input; missing fields use the metadata + * defaults. * * When discovery is unavailable — offline, unauthenticated, on any * transport/parse failure, or when the endpoint returns no usable models — it @@ -488,6 +492,7 @@ export async function fetchStepModels( modelType: readString(record, "model_type"), meta: { contextWindow: readPositiveNumber(record, "max_input_tokens"), + maxTokens: readPositiveNumber(record, "max_output_tokens"), reasoning: readBoolean(record, "enable_reason"), vision: readBoolean(record, "enable_vision_input"), efforts: readStringArray(record, "reasoning_effort_support_list"),