Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(model-providers): enable Fast for custom GPT-5.6 Sol (#3852)

xujun0915403e50615117
diff --git a/packages/model-providers/src/__tests__/user-provider.test.ts b/packages/model-providers/src/__tests__/user-provider.test.ts
index e01f3ca37a..a110b5f42b 100644
--- a/packages/model-providers/src/__tests__/user-provider.test.ts
+++ b/packages/model-providers/src/__tests__/user-provider.test.ts
@@ -223,6 +223,40 @@ describe("buildUserProvider (per-runtime)", () => {
});
});
+ it("inherits Registry Fast support only for an exact Codex route model id", () => {
+ const provider = buildUserProvider(
+ {
+ id: "fast-relay",
+ name: "Fast Relay",
+ runtimes: {
+ codex: {
+ baseUrl: "https://relay.example/v1",
+ models: [
+ { id: "gpt-5.6-sol", name: "GPT-5.6-Sol" },
+ { id: "openai/gpt-5.6-sol", name: "Prefixed GPT-5.6-Sol" },
+ { id: "unregistered-model", name: "Unregistered" },
+ ],
+ },
+ "claude-code": {
+ baseUrl: "https://relay.example/anthropic",
+ models: [{ id: "gpt-5.6-sol", name: "GPT-5.6-Sol" }],
+ },
+ },
+ },
+ { modelRegistry: BUNDLED_CATALOG.modelRegistry },
+ );
+
+ expect(provider.models.codex?.[0]).toMatchObject({
+ id: "gpt-5.6-sol",
+ supportsFastMode: true,
+ });
+ expect(provider.models.codex?.[1]?.supportsFastMode).toBeUndefined();
+ expect(provider.models.codex?.[2]?.supportsFastMode).toBeUndefined();
+ expect(
+ provider.models["claude-code"]?.[0]?.supportsFastMode,
+ ).toBeUndefined();
+ });
+
it('strips xd/ prefix to match registry effort metadata (entry.id ≠ custom id)', () => {
const p = buildUserProvider(
{
diff --git a/packages/model-providers/src/user-provider.ts b/packages/model-providers/src/user-provider.ts
index c122463f52..11a5d2cf9c 100644
--- a/packages/model-providers/src/user-provider.ts
+++ b/packages/model-providers/src/user-provider.ts
@@ -154,6 +154,34 @@ function registryEffortMetadata(
return consensusRegistryEffortMetadata(fallbackMatches, agent);
}
+/**
+ * Fast mode is a Codex service-tier capability, so a user provider may inherit it only when the
+ * configured model id exactly matches a Registry route for Codex. Prefix fallback is intentionally
+ * excluded: aliases can point at gateways with different billing or service-tier behavior.
+ */
+function registrySupportsFastMode(
+ registry: ModelRegistry | null | undefined,
+ modelId: string,
+ agent: AgentKind,
+): boolean {
+ if (agent !== "codex" || !registry) return false;
+
+ const matches = registry.models.filter((entry) =>
+ entry.routes.some(
+ (route) =>
+ route.agents.includes(agent) && route.modelId === modelId,
+ ),
+ );
+ return (
+ matches.length > 0 &&
+ matches.every(
+ (entry) =>
+ (entry.perAgent?.[agent]?.supportsFastMode ??
+ entry.supportsFastMode) === true,
+ )
+ );
+}
+
/** 固定 agent 顺序:保证派生出的 provider.agents / routing / models 顺序稳定。 */
const AGENT_ORDER: readonly AgentKind[] = ["claude-code", "codex", "pi"];
@@ -178,6 +206,11 @@ function toCatalogModel(
m.reasoning !== undefined
? undefined
: registryEffortMetadata(modelRegistry, m.id, agent);
+ const supportsFastMode = registrySupportsFastMode(
+ modelRegistry,
+ m.id,
+ agent,
+ );
const effectiveEfforts = registryEfforts?.efforts ?? efforts;
const defaultEffort =
registryEfforts?.defaultEffort ??
@@ -209,6 +242,7 @@ function toCatalogModel(
// 图片能力必须由用户/预设明确确认;缺省不猜,防止 Pi 静默把截图降级成占位文本。
...(m.supportsImageInput === true ? { supportsImageInput: true } : {}),
...(m.thinkingToggle === true ? { thinkingToggle: true } : {}),
+ ...(supportsFastMode ? { supportsFastMode: true } : {}),
};
}