























@@ -811,7 +811,7 @@ describe("describeImageWithModel", () => {
811811expect(context.messages).toHaveLength(1);
812812expect(Object.keys(options).toSorted()).toEqual(["apiKey", "maxTokens", "signal", "timeoutMs"]);
813813expect(options.apiKey).toBe("oauth-test");
814-expect(options.maxTokens).toBe(512);
814+expect(options.maxTokens).toBe(4096);
815815expect(options.signal).toBeInstanceOf(AbortSignal);
816816expect(options.timeoutMs).toBeGreaterThan(0);
817817expect(options.timeoutMs).toBeLessThanOrEqual(1000);
@@ -1290,4 +1290,77 @@ describe("describeImageWithModel", () => {
12901290expect(contentTypes).not.toContain("text");
12911291expect(contentTypes).toContain("image");
12921292});
1293+1294+it("defaults image-describe maxTokens to 4096 for reasoning-capable VLMs", async () => {
1295+discoverModelsMock.mockReturnValue({
1296+find: vi.fn(() => ({
1297+api: "openai-completions",
1298+provider: "agent-plan",
1299+id: "doubao-seed-2.0-pro",
1300+input: ["text", "image"],
1301+baseUrl: "https://ark.cn-beijing.volces.com/api/plan/v3",
1302+})),
1303+});
1304+completeMock.mockResolvedValue({
1305+role: "assistant",
1306+api: "openai-completions",
1307+provider: "agent-plan",
1308+model: "doubao-seed-2.0-pro",
1309+stopReason: "stop",
1310+timestamp: Date.now(),
1311+content: [{ type: "text", text: "ok" }],
1312+});
1313+1314+await describeImageWithModel({
1315+cfg: {},
1316+agentDir: "/tmp/openclaw-agent",
1317+provider: "agent-plan",
1318+model: "doubao-seed-2.0-pro",
1319+buffer: Buffer.from("png-bytes"),
1320+fileName: "image.png",
1321+mime: "image/png",
1322+prompt: "Describe the image.",
1323+timeoutMs: 1000,
1324+});
1325+1326+const [, , options] = requireFirstMockCall(completeMock, "image completion");
1327+expect(options.maxTokens).toBe(4096);
1328+});
1329+1330+it("caps image-describe maxTokens by the resolved model's own maxTokens", async () => {
1331+discoverModelsMock.mockReturnValue({
1332+find: vi.fn(() => ({
1333+api: "openai-completions",
1334+provider: "fake",
1335+id: "small-vlm",
1336+input: ["text", "image"],
1337+baseUrl: "https://example.test",
1338+maxTokens: 1024,
1339+})),
1340+});
1341+completeMock.mockResolvedValue({
1342+role: "assistant",
1343+api: "openai-completions",
1344+provider: "fake",
1345+model: "small-vlm",
1346+stopReason: "stop",
1347+timestamp: Date.now(),
1348+content: [{ type: "text", text: "ok" }],
1349+});
1350+1351+await describeImageWithModel({
1352+cfg: {},
1353+agentDir: "/tmp/openclaw-agent",
1354+provider: "fake",
1355+model: "small-vlm",
1356+buffer: Buffer.from("png-bytes"),
1357+fileName: "image.png",
1358+mime: "image/png",
1359+prompt: "Describe the image.",
1360+timeoutMs: 1000,
1361+});
1362+1363+const [, , options] = requireFirstMockCall(completeMock, "image completion");
1364+expect(options.maxTokens).toBe(1024);
1365+});
12931366});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。