惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Martin Fowler
Martin Fowler
有赞技术团队
有赞技术团队
博客园_首页
H
Help Net Security
GbyAI
GbyAI
aimingoo的专栏
aimingoo的专栏
V
Visual Studio Blog
The Cloudflare Blog
腾讯CDC
Jina AI
Jina AI
Last Week in AI
Last Week in AI
月光博客
月光博客
博客园 - 叶小钗
Google DeepMind News
Google DeepMind News
B
Blog RSS Feed
Blog — PlanetScale
Blog — PlanetScale
人人都是产品经理
人人都是产品经理
Engineering at Meta
Engineering at Meta
Y
Y Combinator Blog
Hugging Face - Blog
Hugging Face - Blog
博客园 - 聂微东
爱范儿
爱范儿
N
Netflix TechBlog - Medium
F
Fortinet All Blogs

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(vercel-ai-gateway): resolve dynamic model selections ...
vincentkoc · 2026-06-22 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -0,0 +1,22 @@

1+

// Vercel Ai Gateway tests cover provider runtime hooks.

2+

import { registerSingleProviderPlugin } from "openclaw/plugin-sdk/plugin-test-runtime";

3+

import { describe, expect, it } from "vitest";

4+

import plugin from "./index.js";

5+
6+

describe("vercel ai gateway provider hooks", () => {

7+

it("resolves live-only model ids for the embedded runner", async () => {

8+

const provider = await registerSingleProviderPlugin(plugin);

9+

const model = provider.resolveDynamicModel?.({

10+

provider: "vercel-ai-gateway",

11+

modelId: "custom/provider-model",

12+

modelRegistry: { find: () => null },

13+

} as never);

14+
15+

expect(model).toMatchObject({

16+

id: "custom/provider-model",

17+

provider: "vercel-ai-gateway",

18+

api: "anthropic-messages",

19+

baseUrl: "https://ai-gateway.vercel.sh",

20+

});

21+

});

22+

});

Original file line numberDiff line numberDiff line change

@@ -4,6 +4,7 @@ import { applyVercelAiGatewayConfig, VERCEL_AI_GATEWAY_DEFAULT_MODEL_REF } from

44

import {

55

buildStaticVercelAiGatewayProvider,

66

buildVercelAiGatewayProvider,

7+

resolveVercelAiGatewayModel,

78

} from "./provider-catalog.js";

89

import { resolveVercelAiGatewayThinkingProfile } from "./thinking.js";

910

@@ -37,6 +38,7 @@ export default defineSingleProviderPluginEntry({

3738

buildProvider: buildVercelAiGatewayProvider,

3839

buildStaticProvider: buildStaticVercelAiGatewayProvider,

3940

},

41+

resolveDynamicModel: ({ modelId }) => resolveVercelAiGatewayModel(modelId),

4042

resolveThinkingProfile: ({ modelId }) => resolveVercelAiGatewayThinkingProfile(modelId),

4143

},

4244

});

Original file line numberDiff line numberDiff line change

@@ -142,6 +142,21 @@ function getStaticFallbackModel(id: string): ModelDefinitionConfig | undefined {

142142

return fallback ? buildStaticModelDefinition(fallback) : undefined;

143143

}

144144
145+

/** Builds runtime metadata for models returned by the live gateway catalog. */

146+

export function resolveVercelAiGatewayDynamicModel(modelId: string): ModelDefinitionConfig {

147+

return (

148+

getStaticFallbackModel(modelId) ?? {

149+

id: modelId,

150+

name: modelId,

151+

reasoning: false,

152+

input: ["text"],

153+

contextWindow: VERCEL_AI_GATEWAY_DEFAULT_CONTEXT_WINDOW,

154+

maxTokens: VERCEL_AI_GATEWAY_DEFAULT_MAX_TOKENS,

155+

cost: VERCEL_AI_GATEWAY_DEFAULT_COST,

156+

}

157+

);

158+

}

159+
145160

export function getStaticVercelAiGatewayModelCatalog(): ModelDefinitionConfig[] {

146161

return STATIC_VERCEL_AI_GATEWAY_MODEL_CATALOG.map(buildStaticModelDefinition);

147162

}

Original file line numberDiff line numberDiff line change

@@ -20,9 +20,11 @@ import {

2020

VERCEL_AI_GATEWAY_DEFAULT_CONTEXT_WINDOW,

2121

VERCEL_AI_GATEWAY_DEFAULT_MAX_TOKENS,

2222

} from "./api.js";

23+

import { resolveVercelAiGatewayDynamicModel } from "./models.js";

2324

import {

2425

buildStaticVercelAiGatewayProvider,

2526

buildVercelAiGatewayProvider,

27+

resolveVercelAiGatewayModel,

2628

} from "./provider-catalog.js";

2729
2830

const STATIC_MODEL_IDS = [

@@ -83,6 +85,42 @@ describe("vercel ai gateway provider catalog", () => {

8385

});

8486

});

8587
88+

it("builds runtime metadata for live-only model ids", () => {

89+

expect(resolveVercelAiGatewayDynamicModel("custom/provider-model")).toEqual({

90+

id: "custom/provider-model",

91+

name: "custom/provider-model",

92+

reasoning: false,

93+

input: ["text"],

94+

contextWindow: VERCEL_AI_GATEWAY_DEFAULT_CONTEXT_WINDOW,

95+

maxTokens: VERCEL_AI_GATEWAY_DEFAULT_MAX_TOKENS,

96+

cost: {

97+

input: 0,

98+

output: 0,

99+

cacheRead: 0,

100+

cacheWrite: 0,

101+

},

102+

});

103+

});

104+
105+

it("adds transport metadata for runtime model resolution", () => {

106+

expect(resolveVercelAiGatewayModel("custom/provider-model")).toMatchObject({

107+

id: "custom/provider-model",

108+

provider: "vercel-ai-gateway",

109+

api: "anthropic-messages",

110+

baseUrl: VERCEL_AI_GATEWAY_BASE_URL,

111+

});

112+

});

113+
114+

it("preserves provider thinking metadata for known live-only upstream models", () => {

115+

expect(resolveVercelAiGatewayModel("openai/gpt-5.5")).toMatchObject({

116+

reasoning: true,

117+

input: ["text", "image"],

118+

});

119+

expect(resolveVercelAiGatewayModel("anthropic/claude-sonnet-4-6")).toMatchObject({

120+

input: ["text", "image"],

121+

});

122+

});

123+
86124

it("falls back to the static catalog for malformed successful model list payloads", async () => {

87125

for (const payload of [[], { data: {} }, { data: [null] }]) {

88126

clearLiveCatalogCacheForTests();

Original file line numberDiff line numberDiff line change

@@ -3,8 +3,43 @@ import type { ModelProviderConfig } from "openclaw/plugin-sdk/provider-model-sha

33

import {

44

discoverVercelAiGatewayModels,

55

getStaticVercelAiGatewayModelCatalog,

6+

resolveVercelAiGatewayDynamicModel,

67

VERCEL_AI_GATEWAY_BASE_URL,

8+

VERCEL_AI_GATEWAY_PROVIDER_ID,

79

} from "./models.js";

10+

import { resolveVercelAiGatewayThinkingProfile } from "./thinking.js";

11+
12+

const VERCEL_AI_GATEWAY_IMAGE_MODEL_IDS = new Set([

13+

"openai/gpt-5.5",

14+

"openai/gpt-5.5-pro",

15+

"openai/gpt-5.4",

16+

"openai/gpt-5.4-pro",

17+

"openai/gpt-5.4-mini",

18+

"openai/gpt-5.4-nano",

19+

"openai/gpt-5.3-codex",

20+

"openai/gpt-5.3-codex-spark",

21+

"openai/gpt-5.2",

22+

"openai/gpt-5.2-codex",

23+

"openai/gpt-5.1-codex",

24+

]);

25+
26+

export function resolveVercelAiGatewayModel(modelId: string) {

27+

const model = resolveVercelAiGatewayDynamicModel(modelId);

28+

const input: Array<"text" | "image"> = model.input.includes("image")

29+

? ["text", "image"]

30+

: VERCEL_AI_GATEWAY_IMAGE_MODEL_IDS.has(modelId) ||

31+

/^anthropic\/claude-(?:opus|sonnet|haiku)-/.test(modelId)

32+

? ["text", "image"]

33+

: ["text"];

34+

return {

35+

...model,

36+

reasoning: model.reasoning || Boolean(resolveVercelAiGatewayThinkingProfile(modelId)),

37+

input,

38+

api: "anthropic-messages" as const,

39+

provider: VERCEL_AI_GATEWAY_PROVIDER_ID,

40+

baseUrl: VERCEL_AI_GATEWAY_BASE_URL,

41+

};

42+

}

843
944

export function buildStaticVercelAiGatewayProvider(): ModelProviderConfig {

1045

return {