fix: sanitize existing prompt images · openclaw/openclaw@347b51b
steipete
·
2026-05-07
·
via Recent Commits to openclaw:main
File tree
src/agents/pi-embedded-runner/run
| Original file line number | Diff line number | Diff line change |
|---|
@@ -166,6 +166,7 @@ Docs: https://docs.openclaw.ai
|
166 | 166 | - Memory/dreaming: read OpenAI-style `output_text` assistant parts from narrative subagent transcripts, so light-phase Dream Diary entries are not dropped as empty. Thanks @BunsDev. |
167 | 167 | - OpenAI-compatible providers: honor `compat.supportsTools=false` by stripping tool payload fields before dispatch to chat-only endpoints. Fixes #74664. |
168 | 168 | - OpenAI-compatible providers: apply model-declared unsupported tool-schema keyword stripping to native OpenAI transport payloads and mark Fireworks Kimi K2.5 as rejecting `not` schemas. Fixes #75467. |
| 169 | +- OpenAI-compatible gateway: sanitize images supplied through request content even when the prompt text contains no image file references, preventing oversized attachment payloads from bypassing the resize/drop pipeline. Fixes #59913. |
169 | 170 | - llm-task: resolve configured model aliases before embedded dispatch so `model="gemini-flash"` and other aliases route to the intended provider instead of the agent default. Fixes #54166. |
170 | 171 | - Media generation: resolve slash-containing model-only overrides like `fal-ai/flux/dev` through registered provider model metadata so FAL image/video models do not get misparsed as provider `fal-ai`. Fixes #77444. |
171 | 172 | - Commands/BTW: show the `/btw` missing-question usage placeholder with brackets so outbound channel sanitization keeps it visible. Fixes #62877. Thanks @RajvardhanPatil07. |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -298,6 +298,18 @@ describe("detectAndLoadPromptImages", () => {
|
298 | 298 | expectNoPromptImages(result); |
299 | 299 | }); |
300 | 300 | |
| 301 | +it("sanitizes existing images even when prompt has no image references", async () => { |
| 302 | +const result = await detectAndLoadPromptImages({ |
| 303 | +prompt: "describe the attached image", |
| 304 | +workspaceDir: "/tmp", |
| 305 | +model: { input: ["text", "image"] }, |
| 306 | +existingImages: [{ type: "image", data: "not-valid-base64", mimeType: "image/png" }], |
| 307 | +}); |
| 308 | + |
| 309 | +expect(result.images).toHaveLength(0); |
| 310 | +expect(result.detectedRefs).toHaveLength(0); |
| 311 | +}); |
| 312 | + |
301 | 313 | it("preserves attachment order when offloaded refs and inline images are mixed", async () => { |
302 | 314 | const merged = mergePromptAttachmentImages({ |
303 | 315 | imageOrder: ["offloaded", "inline"], |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -467,8 +467,13 @@ export async function detectAndLoadPromptImages(params: {
|
467 | 467 | const allRefs = detectImageReferences(params.prompt); |
468 | 468 | |
469 | 469 | if (allRefs.length === 0) { |
| 470 | +const sanitizedExistingImages = await sanitizeImagesWithLog( |
| 471 | +params.existingImages ?? [], |
| 472 | +"prompt:images", |
| 473 | +{ maxDimensionPx: params.maxDimensionPx }, |
| 474 | +); |
470 | 475 | return { |
471 | | -images: params.existingImages ?? [], |
| 476 | +images: sanitizedExistingImages, |
472 | 477 | detectedRefs: [], |
473 | 478 | loadedCount: 0, |
474 | 479 | skippedCount: 0, |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。