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

推荐订阅源

量子位
博客园_首页
Google DeepMind News
Google DeepMind News
博客园 - Franky
The GitHub Blog
The GitHub Blog
GbyAI
GbyAI
有赞技术团队
有赞技术团队
Microsoft Azure Blog
Microsoft Azure Blog
G
Google Developers Blog
Recent Announcements
Recent Announcements
A
About on SuperTechFans
博客园 - 【当耐特】
博客园 - 三生石上(FineUI控件)
酷 壳 – CoolShell
酷 壳 – CoolShell
美团技术团队
罗磊的独立博客
IT之家
IT之家
博客园 - 聂微东
Stack Overflow Blog
Stack Overflow Blog
Jina AI
Jina AI
腾讯CDC
P
Proofpoint News Feed
Hugging Face - Blog
Hugging Face - Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com

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(gateway): restore WebChat image understanding routing...
NianJiuZst · 2026-05-23 · via Recent Commits to openclaw:main

@@ -7,7 +7,13 @@ import { normalizeOptionalString } from "../../shared/string-coerce.js";

77

import type { MsgContext } from "../templating.js";

88

import { resolveAgentTurnAttachments } from "./agent-turn-attachments.js";

9910-

function countCurrentImageAttachmentCandidates(ctx: MsgContext): number {

10+

type CurrentImageAttachment = {

11+

index: number;

12+

path: string;

13+

mediaType: string;

14+

};

15+16+

function collectCurrentImageAttachments(ctx: MsgContext): CurrentImageAttachment[] {

1117

const pathsFromArray = Array.isArray(ctx.MediaPaths) ? ctx.MediaPaths : undefined;

1218

const paths =

1319

pathsFromArray && pathsFromArray.length > 0

@@ -16,21 +22,43 @@ function countCurrentImageAttachmentCandidates(ctx: MsgContext): number {

1622

? [ctx.MediaPath]

1723

: [];

1824

if (paths.length === 0) {

19-

return 0;

25+

return [];

2026

}

2127

const types =

2228

Array.isArray(ctx.MediaTypes) && ctx.MediaTypes.length === paths.length

2329

? ctx.MediaTypes

2430

: undefined;

25-

let count = 0;

31+

const attachments: CurrentImageAttachment[] = [];

2632

for (const [index, pathValue] of paths.entries()) {

2733

const mediaPath = normalizeOptionalString(pathValue);

2834

const mediaType = normalizeOptionalString(types?.[index] ?? ctx.MediaType);

2935

if (mediaPath && mediaType?.startsWith("image/")) {

30-

count++;

36+

attachments.push({ index, path: mediaPath, mediaType });

3137

}

3238

}

33-

return count;

39+

return attachments;

40+

}

41+42+

function collectDescribedImageAttachmentIndexes(ctx: MsgContext): Set<number> {

43+

return new Set(

44+

ctx.MediaUnderstanding?.filter((output) => output.kind === "image.description").map(

45+

(output) => output.attachmentIndex,

46+

) ?? [],

47+

);

48+

}

49+50+

function createUndescribedImageContext(

51+

ctx: MsgContext,

52+

undescribedAttachments: CurrentImageAttachment[],

53+

): MsgContext {

54+

const first = undescribedAttachments[0];

55+

return {

56+

...ctx,

57+

MediaPath: first?.path,

58+

MediaType: first?.mediaType,

59+

MediaPaths: undescribedAttachments.map((attachment) => attachment.path),

60+

MediaTypes: undescribedAttachments.map((attachment) => attachment.mediaType),

61+

};

3462

}

35633664

export async function resolveCurrentTurnImages(params: {

@@ -46,14 +74,21 @@ export async function resolveCurrentTurnImages(params: {

4674

return { images: params.images, imageOrder: params.imageOrder };

4775

}

487649-

const currentImageCandidateCount = countCurrentImageAttachmentCandidates(params.ctx);

50-

if (currentImageCandidateCount === 0) {

77+

const currentImageAttachments = collectCurrentImageAttachments(params.ctx);

78+

if (currentImageAttachments.length === 0) {

79+

return { images: params.images, imageOrder: params.imageOrder };

80+

}

81+

const describedImageIndexes = collectDescribedImageAttachmentIndexes(params.ctx);

82+

const undescribedImageAttachments = currentImageAttachments.filter(

83+

(attachment) => !describedImageIndexes.has(attachment.index),

84+

);

85+

if (undescribedImageAttachments.length === 0) {

5186

return { images: params.images, imageOrder: params.imageOrder };

5287

}

53885489

try {

5590

const resolved = await resolveAgentTurnAttachments({

56-

ctx: params.ctx,

91+

ctx: createUndescribedImageContext(params.ctx, undescribedImageAttachments),

5792

cfg: params.cfg,

5893

includeRecentHistoryImages: false,

5994

});

@@ -64,9 +99,9 @@ export async function resolveCurrentTurnImages(params: {

6499

mimeType: attachment.mediaType,

65100

}),

66101

);

67-

if (images.length < currentImageCandidateCount) {

102+

if (images.length < undescribedImageAttachments.length) {

68103

logVerbose(

69-

`agent-runner: native PI media resolution produced ${images.length}/${currentImageCandidateCount} current image attachment(s); falling back to prompt image refs`,

104+

`agent-runner: native PI media resolution produced ${images.length}/${undescribedImageAttachments.length} current image attachment(s); falling back to prompt image refs`,

70105

);

71106

return { images: params.images, imageOrder: params.imageOrder };

72107

}