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

推荐订阅源

J
Java Code Geeks
小众软件
小众软件
博客园 - 叶小钗
宝玉的分享
宝玉的分享
博客园_首页
Hugging Face - Blog
Hugging Face - Blog
人人都是产品经理
人人都是产品经理
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
S
SegmentFault 最新的问题
B
Blog RSS Feed
Engineering at Meta
Engineering at Meta
N
Netflix TechBlog - Medium
Google DeepMind News
Google DeepMind News
U
Unit 42
F
Fortinet All Blogs
IT之家
IT之家
Y
Y Combinator Blog
Martin Fowler
Martin Fowler
T
The Blog of Author Tim Ferriss
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The GitHub Blog
The GitHub Blog
Stack Overflow Blog
Stack Overflow Blog
Blog — PlanetScale
Blog — PlanetScale
酷 壳 – CoolShell
酷 壳 – CoolShell

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 copilot model token limits · openclaw/openc...
steipete · 2026-05-29 · via Recent Commits to openclaw:main

File tree

  • extensions/github-copilot

Original file line numberDiff line numberDiff line change

@@ -611,6 +611,59 @@ describe("fetchCopilotModelCatalog", () => {

611611

expect(out[0].name).toBe("GPT-5.5");

612612

});

613613
614+

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

615+

const fetchImpl = vi.fn().mockResolvedValue({

616+

ok: true,

617+

status: 200,

618+

json: async () => ({

619+

data: [

620+

{

621+

id: "gpt-bad-window",

622+

name: "GPT Bad Window",

623+

object: "model",

624+

capabilities: {

625+

type: "chat",

626+

limits: {

627+

max_context_window_tokens: -1,

628+

max_output_tokens: 128000.5,

629+

},

630+

},

631+

},

632+

{

633+

id: "gpt-bad-output",

634+

name: "GPT Bad Output",

635+

object: "model",

636+

capabilities: {

637+

type: "chat",

638+

limits: {

639+

max_context_window_tokens: Number.POSITIVE_INFINITY,

640+

max_output_tokens: 0,

641+

},

642+

},

643+

},

644+

],

645+

}),

646+

});

647+
648+

const out = await fetchCopilotModelCatalog({

649+

copilotApiToken: "tid=test",

650+

baseUrl: "https://api.githubcopilot.com",

651+

fetchImpl: fetchImpl as unknown as typeof fetch,

652+

});

653+
654+

expect(out).toHaveLength(2);

655+

expect(out[0]).toMatchObject({

656+

id: "gpt-bad-window",

657+

contextWindow: 128000,

658+

maxTokens: 8192,

659+

});

660+

expect(out[1]).toMatchObject({

661+

id: "gpt-bad-output",

662+

contextWindow: 128000,

663+

maxTokens: 8192,

664+

});

665+

});

666+
614667

it("throws on non-2xx HTTP responses so the caller can fall back to the static catalog", async () => {

615668

const fetchImpl = vi.fn().mockResolvedValue({

616669

ok: false,

Original file line numberDiff line numberDiff line change

@@ -6,7 +6,10 @@ import { buildCopilotIdeHeaders, COPILOT_INTEGRATION_ID } from "openclaw/plugin-

66

import { readProviderJsonArrayFieldResponse } from "openclaw/plugin-sdk/provider-http";

77

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

88

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

9-

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

9+

import {

10+

asPositiveSafeInteger,

11+

normalizeOptionalLowercaseString,

12+

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

1013

import {

1114

resolveCopilotModelCompat,

1215

resolveCopilotTransportApi,

@@ -169,13 +172,8 @@ function mapCopilotApiModelToDefinition(

169172

const input: ModelDefinitionConfig["input"] = supportsVision ? ["text", "image"] : ["text"];

170173
171174

const contextWindow =

172-

typeof limits?.max_context_window_tokens === "number" && limits.max_context_window_tokens > 0

173-

? limits.max_context_window_tokens

174-

: DEFAULT_CONTEXT_WINDOW;

175-

const maxTokens =

176-

typeof limits?.max_output_tokens === "number" && limits.max_output_tokens > 0

177-

? limits.max_output_tokens

178-

: DEFAULT_MAX_TOKENS;

175+

asPositiveSafeInteger(limits?.max_context_window_tokens) ?? DEFAULT_CONTEXT_WINDOW;

176+

const maxTokens = asPositiveSafeInteger(limits?.max_output_tokens) ?? DEFAULT_MAX_TOKENS;

179177

const compat = resolveCopilotModelCompat(id);

180178
181179

const definition: ModelDefinitionConfig = {