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

推荐订阅源

V
Visual Studio Blog
量子位
大猫的无限游戏
大猫的无限游戏
Hugging Face - Blog
Hugging Face - Blog
S
SegmentFault 最新的问题
Blog — PlanetScale
Blog — PlanetScale
月光博客
月光博客
Google DeepMind News
Google DeepMind News
小众软件
小众软件
WordPress大学
WordPress大学
宝玉的分享
宝玉的分享
MongoDB | Blog
MongoDB | Blog
B
Blog RSS Feed
博客园 - Franky
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
B
Blog
博客园 - 聂微东
The GitHub Blog
The GitHub Blog
Recent Announcements
Recent Announcements
Y
Y Combinator Blog
Microsoft Security Blog
Microsoft Security Blog
雷峰网
雷峰网
Jina AI
Jina AI
酷 壳 – 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(pdf-tool): defer PDF model resolution (#76728) · open...
hclsys · 2026-05-03 · via Recent Commits to openclaw:main

@@ -5,10 +5,12 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";

55

import type { OpenClawConfig } from "../../config/config.js";

66

import * as pdfExtractModule from "../../media/pdf-extract.js";

77

import * as webMedia from "../../media/web-media.js";

8+

import type { AuthProfileStore } from "../auth-profiles/types.js";

89

import * as modelAuth from "../model-auth.js";

910

import * as modelsConfig from "../models-config.js";

1011

import * as modelDiscovery from "../pi-model-discovery.js";

1112

import * as pdfNativeProviders from "./pdf-native-providers.js";

13+

import * as pdfModelConfigModule from "./pdf-tool.model-config.js";

1214

import { resetPdfToolAuthEnv, withTempPdfAgentDir } from "./pdf-tool.test-support.js";

13151416

const completeMock = vi.hoisted(() => vi.fn());

@@ -71,6 +73,12 @@ function withPdfModel(primary: string): OpenClawConfig {

7173

} as OpenClawConfig;

7274

}

737576+

function withDefaultModel(primary: string): OpenClawConfig {

77+

return {

78+

agents: { defaults: { model: { primary } } },

79+

} as OpenClawConfig;

80+

}

81+7482

async function stubPdfToolInfra(

7583

agentDir: string,

7684

params?: {

@@ -159,6 +167,77 @@ describe("createPdfTool", () => {

159167

});

160168

});

161169170+

it("defers automatic model config resolution during registration (#76644)", async () => {

171+

const resolveSpy = vi.spyOn(pdfModelConfigModule, "resolvePdfModelConfigForTool");

172+

const cfg = withDefaultModel("openai/gpt-5.4");

173+

const authProfileStore = {

174+

version: 1,

175+

profiles: {

176+

"anthropic:default": {

177+

type: "api_key",

178+

provider: "anthropic",

179+

key: "test-key",

180+

},

181+

},

182+

} satisfies AuthProfileStore;

183+

const createTool = await loadCreatePdfTool();

184+

await withTempPdfAgentDir(async (agentDir) => {

185+

expect(

186+

createTool({

187+

config: cfg,

188+

agentDir,

189+

authProfileStore,

190+

deferAutoModelResolution: true,

191+

})?.name,

192+

).toBe("pdf");

193+

expect(resolveSpy).not.toHaveBeenCalled();

194+

});

195+

resolveSpy.mockRestore();

196+

});

197+198+

it("keeps explicit model config resolution eager even when automatic resolution is deferred", async () => {

199+

const resolveSpy = vi.spyOn(pdfModelConfigModule, "resolvePdfModelConfigForTool");

200+

const createTool = await loadCreatePdfTool();

201+

await withTempPdfAgentDir(async (agentDir) => {

202+

expect(

203+

createTool({

204+

config: withPdfModel(ANTHROPIC_PDF_MODEL),

205+

agentDir,

206+

deferAutoModelResolution: true,

207+

})?.name,

208+

).toBe("pdf");

209+

expect(resolveSpy).toHaveBeenCalledTimes(1);

210+

});

211+

resolveSpy.mockRestore();

212+

});

213+214+

it("resolves deferred model config on execution before loading PDFs", async () => {

215+

const resolveSpy = vi

216+

.spyOn(pdfModelConfigModule, "resolvePdfModelConfigForTool")

217+

.mockReturnValue(null);

218+

const loadSpy = vi.spyOn(webMedia, "loadWebMediaRaw");

219+

const createTool = await loadCreatePdfTool();

220+

const cfg = withDefaultModel("openai/gpt-5.4");

221+

await withTempPdfAgentDir(async (agentDir) => {

222+

const tool = requirePdfTool(

223+

createTool({

224+

config: cfg,

225+

agentDir,

226+

deferAutoModelResolution: true,

227+

}),

228+

);

229+

await expect(

230+

tool.execute("t1", {

231+

prompt: "summarize",

232+

pdf: "/tmp/doc.pdf",

233+

}),

234+

).rejects.toThrow("No PDF model configured.");

235+

});

236+

expect(resolveSpy).toHaveBeenCalledTimes(1);

237+

expect(loadSpy).not.toHaveBeenCalled();

238+

resolveSpy.mockRestore();

239+

});

240+162241

it("rejects when no pdf input provided", async () => {

163242

await withConfiguredPdfTool(async (tool) => {

164243

await expect(tool.execute("t1", { prompt: "test" })).rejects.toThrow("pdf required");