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

推荐订阅源

Blog — PlanetScale
Blog — PlanetScale
Vercel News
Vercel News
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
量子位
Y
Y Combinator Blog
IT之家
IT之家
博客园 - 聂微东
L
LangChain Blog
爱范儿
爱范儿
H
Help Net Security
GbyAI
GbyAI
F
Fortinet All Blogs
B
Blog
Microsoft Security Blog
Microsoft Security Blog
罗磊的独立博客
C
Check Point Blog
博客园 - 三生石上(FineUI控件)
小众软件
小众软件
D
DataBreaches.Net
Last Week in AI
Last Week in AI
WordPress大学
WordPress大学
B
Blog RSS Feed
酷 壳 – 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(agents): honor completions token aliases (#82278) · o...
steipete · 2026-05-16 · via Recent Commits to openclaw:main

@@ -4,6 +4,7 @@ import { createPiAiStreamSimpleMock } from "../../../test/helpers/agents/pi-ai-s

44

import {

55

__testing as extraParamsTesting,

66

applyExtraParamsToAgent,

7+

resolveExtraParams,

78

resolvePreparedExtraParams,

89

} from "./extra-params.js";

910

@@ -63,6 +64,100 @@ describe("createStreamFnWithExtraParams sampling overrides", () => {

6364

expect(callOptions?.maxTokens).toBe(512);

6465

});

656667+

it("forwards OpenAI completions token aliases into the underlying streamFn options", () => {

68+

const underlying = vi.fn(() => ({

69+

push: vi.fn(),

70+

result: vi.fn(async () => undefined),

71+

[Symbol.asyncIterator]: vi.fn(async function* () {

72+

// empty stream

73+

}),

74+

})) as unknown as StreamFn;

75+

const agent: { streamFn?: StreamFn } = { streamFn: underlying };

76+77+

applyExtraParamsToAgent(agent, undefined, "dashscope", "kimi-k2.6", {

78+

max_completion_tokens: 64_000,

79+

});

80+81+

if (!agent.streamFn) {

82+

throw new Error("expected extra params to wrap streamFn");

83+

}

84+85+

void agent.streamFn(

86+

{ id: "kimi-k2.6", api: "openai-completions", provider: "dashscope" } as never,

87+

{ messages: [], tools: [] } as never,

88+

undefined,

89+

);

90+91+

const callOptions = (underlying as unknown as { mock: { calls: unknown[][] } }).mock

92+

.calls[0]?.[2] as { maxTokens?: number } | undefined;

93+

expect(callOptions?.maxTokens).toBe(64_000);

94+

});

95+96+

it("keeps runtime maxTokens ahead of OpenAI completions token alias defaults", () => {

97+

const underlying = vi.fn(() => ({

98+

push: vi.fn(),

99+

result: vi.fn(async () => undefined),

100+

[Symbol.asyncIterator]: vi.fn(async function* () {

101+

// empty stream

102+

}),

103+

})) as unknown as StreamFn;

104+

const agent: { streamFn?: StreamFn } = { streamFn: underlying };

105+106+

applyExtraParamsToAgent(agent, undefined, "dashscope", "kimi-k2.6", {

107+

max_completion_tokens: 64_000,

108+

});

109+110+

if (!agent.streamFn) {

111+

throw new Error("expected extra params to wrap streamFn");

112+

}

113+114+

void agent.streamFn(

115+

{ id: "kimi-k2.6", api: "openai-completions", provider: "dashscope" } as never,

116+

{ messages: [], tools: [] } as never,

117+

{ maxTokens: 32_000 } as never,

118+

);

119+120+

const callOptions = (underlying as unknown as { mock: { calls: unknown[][] } }).mock

121+

.calls[0]?.[2] as { maxTokens?: number } | undefined;

122+

expect(callOptions?.maxTokens).toBe(32_000);

123+

});

124+125+

it("canonicalizes token aliases with config precedence before preparing stream params", () => {

126+

const resolved = resolveExtraParams({

127+

cfg: {

128+

agents: {

129+

defaults: {

130+

params: {

131+

maxTokens: 32_000,

132+

},

133+

models: {

134+

"dashscope/kimi-k2.6": {

135+

params: {

136+

max_completion_tokens: 64_000,

137+

},

138+

},

139+

},

140+

},

141+

list: [

142+

{

143+

id: "bot",

144+

params: {

145+

max_tokens: 48_000,

146+

},

147+

},

148+

],

149+

},

150+

} as never,

151+

provider: "dashscope",

152+

modelId: "kimi-k2.6",

153+

agentId: "bot",

154+

});

155+156+

expect(resolved?.maxTokens).toBe(48_000);

157+

expect(resolved).not.toHaveProperty("max_completion_tokens");

158+

expect(resolved).not.toHaveProperty("max_tokens");

159+

});

160+66161

it("lets runtime options override the wrapper sampling defaults", () => {

67162

const underlying = vi.fn(() => ({

68163

push: vi.fn(),