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

推荐订阅源

H
Help Net Security
G
Google Developers Blog
aimingoo的专栏
aimingoo的专栏
博客园 - 聂微东
酷 壳 – CoolShell
酷 壳 – CoolShell
小众软件
小众软件
Stack Overflow Blog
Stack Overflow Blog
美团技术团队
博客园_首页
T
Tailwind CSS Blog
博客园 - 三生石上(FineUI控件)
B
Blog
D
DataBreaches.Net
腾讯CDC
C
Check Point Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
U
Unit 42
月光博客
月光博客
V
V2EX
Vercel News
Vercel News
T
The Blog of Author Tim Ferriss
The Cloudflare Blog
博客园 - 叶小钗
Y
Y Combinator Blog

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: validate vercel gateway model token metadata · openc...
steipete · 2026-05-29 · via Recent Commits to openclaw:main

File tree

  • extensions/vercel-ai-gateway

Original file line numberDiff line numberDiff line change

@@ -3,6 +3,7 @@ import { readProviderJsonArrayFieldResponse } from "openclaw/plugin-sdk/provider

33

import type { ModelDefinitionConfig } from "openclaw/plugin-sdk/provider-model-shared";

44

import { createSubsystemLogger } from "openclaw/plugin-sdk/runtime-env";

55

import { fetchWithSsrFGuard } from "openclaw/plugin-sdk/ssrf-runtime";

6+

import { asPositiveSafeInteger } from "openclaw/plugin-sdk/string-coerce-runtime";

67
78

export const VERCEL_AI_GATEWAY_PROVIDER_ID = "vercel-ai-gateway";

89

export const VERCEL_AI_GATEWAY_BASE_URL = "https://ai-gateway.vercel.sh";

@@ -151,13 +152,13 @@ function buildDiscoveredModelDefinition(

151152
152153

const fallback = getStaticFallbackModel(id);

153154

const contextWindow =

154-

typeof model.context_window === "number" && Number.isFinite(model.context_window)

155-

? model.context_window

156-

: (fallback?.contextWindow ?? VERCEL_AI_GATEWAY_DEFAULT_CONTEXT_WINDOW);

155+

asPositiveSafeInteger(model.context_window) ??

156+

fallback?.contextWindow ??

157+

VERCEL_AI_GATEWAY_DEFAULT_CONTEXT_WINDOW;

157158

const maxTokens =

158-

typeof model.max_tokens === "number" && Number.isFinite(model.max_tokens)

159-

? model.max_tokens

160-

: (fallback?.maxTokens ?? VERCEL_AI_GATEWAY_DEFAULT_MAX_TOKENS);

159+

asPositiveSafeInteger(model.max_tokens) ??

160+

fallback?.maxTokens ??

161+

VERCEL_AI_GATEWAY_DEFAULT_MAX_TOKENS;

161162

const normalizedCost = normalizeCost(model.pricing);

162163
163164

return {

Original file line numberDiff line numberDiff line change

@@ -12,6 +12,8 @@ import {

1212

discoverVercelAiGatewayModels,

1313

getStaticVercelAiGatewayModelCatalog,

1414

VERCEL_AI_GATEWAY_BASE_URL,

15+

VERCEL_AI_GATEWAY_DEFAULT_CONTEXT_WINDOW,

16+

VERCEL_AI_GATEWAY_DEFAULT_MAX_TOKENS,

1517

} from "./api.js";

1618

import {

1719

buildStaticVercelAiGatewayProvider,

@@ -93,4 +95,47 @@ describe("vercel ai gateway provider catalog", () => {

9395

});

9496

}

9597

});

98+
99+

it("falls back from malformed live token metadata", async () => {

100+

fetchWithSsrFGuardMock.mockResolvedValueOnce({

101+

response: {

102+

ok: true,

103+

status: 200,

104+

json: async () => ({

105+

data: [

106+

{

107+

id: "anthropic/claude-opus-4.6",

108+

name: "Claude Opus 4.6",

109+

context_window: -1,

110+

max_tokens: 128_000.5,

111+

tags: ["vision", "reasoning"],

112+

},

113+

{

114+

id: "custom/provider-model",

115+

name: "Custom model",

116+

context_window: Number.POSITIVE_INFINITY,

117+

max_tokens: 0,

118+

tags: ["reasoning"],

119+

},

120+

],

121+

}),

122+

},

123+

release: async () => {},

124+

});

125+
126+

await withLiveDiscovery(async () => {

127+

const models = await discoverVercelAiGatewayModels();

128+
129+

expect(models[0]).toMatchObject({

130+

id: "anthropic/claude-opus-4.6",

131+

contextWindow: 1_000_000,

132+

maxTokens: 128_000,

133+

});

134+

expect(models[1]).toMatchObject({

135+

id: "custom/provider-model",

136+

contextWindow: VERCEL_AI_GATEWAY_DEFAULT_CONTEXT_WINDOW,

137+

maxTokens: VERCEL_AI_GATEWAY_DEFAULT_MAX_TOKENS,

138+

});

139+

});

140+

});

96141

});