Skip to content

fix: hydrate current turn image attachments - #84812

Merged
steipete merged 1 commit into
openclaw:mainfrom
marchpure:fix/image-tool-active-vision
May 25, 2026
Merged

steipete merged 1 commit into
openclaw:mainfrom
marchpure:fix/image-tool-active-vision

Conversation

@marchpure

@marchpure marchpure commented May 21, 2026 •

Copy link
Copy Markdown
Contributor

Root cause

Current inbound images from Feishu/IM can arrive with structured MediaPaths but without reliable image/* MIME metadata. After #76659 limited prompt image scanning to the visible prompt, those images should be passed through the current-turn media path instead of being rediscovered by scanning reply/runtime context text.

Fix

  • Keep detectAndLoadPromptImages scoped to the visible prompt; this does not restore runtime/reply context scanning.
  • In current-turn-images.ts, infer an image MIME from the current-turn MediaPath/MediaPaths extension only when the declared media type is missing or generic binary.
  • Preserve explicit non-image MIME values such as application/pdf, audio/*, or video/*; those are not upgraded to images based on extension.
  • Pass the narrowed, current-turn-only MIME hint into the existing resolveAgentTurnAttachments path; agent-turn-attachments.ts stays unchanged.

Real behavior proof

  • Behavior or issue addressed: Feishu/IM-style current-turn image attachments with MediaPaths but no MediaTypes are hydrated as native image input instead of relying on prompt/runtime-context path scanning.
  • Real environment tested: Local OpenClaw checkout at PR head b338d73c97, macOS, Node.js v22.22.2, pnpm/tsx from the repository install.
  • Exact steps or command run after this patch: Created a temporary 1x1 PNG file, then invoked resolveCurrentTurnImages from src/auto-reply/reply/current-turn-images.ts with a Feishu-like context containing MediaPaths: [imagePath], MediaWorkspaceDir, and no MediaTypes.
  • Evidence after fix (terminal output from the local OpenClaw checkout):
{
  "images": 1,
  "mimeType": "image/png",
  "imageOrder": [
    "inline"
  ],
  "base64Length": 92
}
  • Observed result after fix: The current-turn attachment path produced one native image input with MIME image/png and inline image order, proving the attachment no longer depends on scanning reply/runtime context text.
  • What was not tested: A live Feishu production message was not sent from the real Feishu bot; this proof exercises the OpenClaw current-turn media hydration path with the same structured fields that Feishu/IM provide.

Verification

  • PATH=/opt/homebrew/opt/node@22/bin:$PATH pnpm exec oxfmt --check --threads=1 src/auto-reply/reply/current-turn-images.ts src/auto-reply/reply/get-reply-run.media-only.test.ts
  • PATH=/opt/homebrew/opt/node@22/bin:$PATH pnpm exec vitest run src/auto-reply/reply/get-reply-run.media-only.test.ts --testNamePattern "hydrates current image MediaPaths by extension" --reporter=verbose
  • PATH=/opt/homebrew/opt/node@22/bin:$PATH pnpm exec vitest run src/auto-reply/reply/dispatch-acp.test.ts --testNamePattern "does not fall back to recent history images when the current turn has non-image media" --reporter=verbose
  • PATH=/opt/homebrew/opt/node@22/bin:$PATH pnpm exec vitest run src/auto-reply/reply/get-reply-run.media-only.test.ts src/auto-reply/reply/agent-runner.media-paths.test.ts src/agents/pi-embedded-runner/run/attempt.spawn-workspace.context-engine.test.ts --reporter=verbose
  • Direct module check: MediaTypes: ["application/pdf"] with a .png path returns { "images": 0, "imageOrder": [] }.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 21, 2026
@clawsweeper

clawsweeper Bot commented May 21, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed May 25, 2026, 12:51 PM ET / 16:51 UTC.

Summary
The PR infers image MIME types for current-turn MediaPath/MediaPaths entries when MIME metadata is missing or generic, and updates media-only regression coverage.

PR surface: Source +25, Tests -2. Total +23 across 2 files.

Reproducibility: yes. source inspection gives a high-confidence reproduction path: current main ignores MediaPaths images unless the media type already starts with image/, and the PR proof exercises the same missing-MIME input shape. I did not execute tests because this review was read-only.

Review metrics: none identified.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🦞 diamond lobster ✨ media proof bonus
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Wait for the in-progress required checks to complete before merge.

Risk before merge

  • Latest head still had in-progress GitHub checks during review, so merge should wait for required check completion even though the code review found no blocker.

Maintainer options:

  1. Decide the mitigation before merge
    Land the focused hydration fix after maintainer review and required checks complete, keeping prompt image scanning scoped to the visible prompt.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge
No ClawSweeper repair lane is needed because the branch is focused and has no actionable review findings; the next step is maintainer and check gating.

Security
Cleared: The diff does not touch dependencies, workflows, secrets, auth, or package execution, and it keeps attachment reads behind the existing media attachment resolver.

Review details

Best possible solution:

Land the focused hydration fix after maintainer review and required checks complete, keeping prompt image scanning scoped to the visible prompt.

Do we have a high-confidence way to reproduce the issue?

Yes, source inspection gives a high-confidence reproduction path: current main ignores MediaPaths images unless the media type already starts with image/, and the PR proof exercises the same missing-MIME input shape. I did not execute tests because this review was read-only.

Is this the best way to solve the issue?

Yes, this is the narrow maintainable fix: infer only current-turn image MIME hints for missing or generic binary metadata, preserve explicit non-image MIME values, and reuse the existing attachment resolver.

AGENTS.md: found and applied where relevant.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 5cfa577778df.

Label changes

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR includes after-fix terminal output for the hydration path and inspected before/after screenshots showing image handling improving in the IM flow.
  • add proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. The PR includes after-fix terminal output for the hydration path and inspected before/after screenshots showing image handling improving in the IM flow.

Label justifications:

  • P2: This fixes a real current-turn image hydration bug with limited blast radius in the auto-reply media path.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (screenshot): The PR includes after-fix terminal output for the hydration path and inspected before/after screenshots showing image handling improving in the IM flow.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR includes after-fix terminal output for the hydration path and inspected before/after screenshots showing image handling improving in the IM flow.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. The PR includes after-fix terminal output for the hydration path and inspected before/after screenshots showing image handling improving in the IM flow.
Evidence reviewed

PR surface:

Source +25, Tests -2. Total +23 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 27 2 +25
Tests 1 1 3 -2
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 28 5 +23

What I checked:

  • Current main behavior: Current main collects current-turn image attachments only when the normalized media type already starts with image/, so MediaPaths with missing or generic MIME metadata do not enter native image hydration. (src/auto-reply/reply/current-turn-images.ts:34, 5cfa577778df)
  • PR implementation: The PR head adds a helper that accepts existing image MIME values, rejects explicit non-image types, and infers an image MIME from the file path only when the declared type is missing or generic binary. (src/auto-reply/reply/current-turn-images.ts:17, ecc1bbdd9236)
  • Regression coverage: The PR head updates the media-only test to omit MediaTypes and still expect one inline image/png followup image with base64 data. (src/auto-reply/reply/get-reply-run.media-only.test.ts:881, ecc1bbdd9236)
  • Attachment boundary: The existing resolver still reads only image-typed, path-backed attachments through the current media attachment cache, and the current-turn caller keeps recent-history fallback disabled for this hydration path. (src/auto-reply/reply/agent-turn-attachments.ts:99, 5cfa577778df)
  • Real behavior proof: The PR body includes terminal output showing images: 1, mimeType: image/png, and inline image order; the attached before/after screenshots were downloaded and inspected, with the after screenshot showing the IM bot describing the sent image. (ecc1bbdd9236)
  • History provenance: GitHub commit history for the central file shows the current-turn hydration file was added by 8725364cf0be867b040469dfe68e83a3a0d3436a, with a later related WebChat image-understanding touch in 55a0c9b1f47453b0a5b78a20cec033843c73bae4. (src/auto-reply/reply/current-turn-images.ts:1, 8725364cf0be)

Likely related people:

  • steipete: GitHub commit history shows 8725364cf0be867b040469dfe68e83a3a0d3436a added current-turn-images.ts and related media-only coverage, and later commits show repeated work in this reply/media area. (role: introduced current-turn hydration; confidence: high; commits: 8725364cf0be; files: src/auto-reply/reply/current-turn-images.ts, src/auto-reply/reply/get-reply-run.media-only.test.ts)
  • joshavant: GitHub history for agent-turn-attachments.ts shows recent work on native PI image attachment routing in 491ce8b7535baadbb73191587453ac1124c9b6c2, which is the resolver path this PR feeds. (role: recent adjacent contributor; confidence: medium; commits: 491ce8b7535b; files: src/auto-reply/reply/agent-turn-attachments.ts)
  • NianJiuZst: GitHub history shows a recent current-turn image-understanding routing fix touching the same current-turn-images.ts surface before this PR. (role: recent area contributor; confidence: medium; commits: 55a0c9b1f474; files: src/auto-reply/reply/current-turn-images.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. labels May 21, 2026
@clawsweeper

clawsweeper Bot commented May 21, 2026 •

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg

✨ Hatched: 🥚 common Pearl Clawlet

Hatch command

Comment @clawsweeper hatch when this PR is hatchable.

Hatchability rules:

  • Merged PRs are hatchable.
  • Open PRs are hatchable when they are status: 👀 ready for maintainer look, status: 🚀 automerge armed, or labeled clawsweeper:automerge.
  • Closed unmerged PRs are hatchable only when one of those hatchable labels is still present in the durable record.

Rarity: 🥚 common.
Trait: hums during re-review.
Image traits: location review cove; accessory release bell; palette amber, ink, and glacier blue; mood sleepy but ready; pose nestled inside a glowing shell; shell frosted glass shell; lighting subtle sparkle highlights; background small green status lights.
Share on X: post this hatch
Copy: My PR egg hatched a 🥚 common Pearl Clawlet in ClawSweeper.

What is this egg doing here?
  • Eggs appear after the PR passes real-behavior proof. It is here for vibes, not verdicts: it does not change labels, ratings, merge decisions, or automation.
  • The shell reacts to review momentum: open follow-up work warms it up, re-review makes it wobble, and a clean final review lets it hatch.
  • Hatchability usually comes from sufficient real-behavior proof, no blocking P0/P1/P2 findings, no security attention needed, and clean correctness. A merged PR is already final, so merge makes the egg hatchable independently.
  • The hatch is seeded from this repository and PR number, so the same PR keeps the same creature; the reviewed head SHA can only change safe visual details.
  • Rarity is just collectible sparkle: 🥚 common, 🌱 uncommon, 💎 rare, ✨ glimmer, and 🌈 legendary.

@marchpure
marchpure force-pushed the fix/image-tool-active-vision branch from 619c152 to c3f55a2 Compare May 21, 2026 05:30
@marchpure

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented May 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels May 21, 2026
@marchpure
marchpure force-pushed the fix/image-tool-active-vision branch from 17fa98c to a18a9ff Compare May 22, 2026 02:55
@openclaw-barnacle openclaw-barnacle Bot added size: S and removed agents Agent runtime and tooling size: M labels May 22, 2026
@marchpure marchpure changed the title fix: use active vision model for image tool fallback fix: hydrate current turn image attachments May 22, 2026
@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 22, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. labels May 22, 2026
@marchpure
marchpure force-pushed the fix/image-tool-active-vision branch from 2671e7e to e5cc701 Compare May 25, 2026 12:26
@openclaw-barnacle openclaw-barnacle Bot added size: XS and removed app: web-ui App: web-ui gateway Gateway runtime extensions: diagnostics-otel Extension: diagnostics-otel cli CLI command changes scripts Repository scripts agents Agent runtime and tooling extensions: qa-lab extensions: codex extensions: diffs proof: sufficient ClawSweeper judged the real behavior proof convincing. size: XL labels May 25, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels May 25, 2026
@marchpure

Copy link
Copy Markdown
Contributor Author

@steipete would you pls review this pr?

@marchpure

Copy link
Copy Markdown
Contributor Author

@steipete sorry to ping directly here. I noticed there have been a few pushes on this PR, and I wanted to share a bit more context from our side.

We have seen this issue affect multiple Volcano Engine customers. After testing this PR, those customers confirmed that it resolves the problem for them. If it is convenient, could you help take a look and help us move this fix forward?

One more question: is there currently any restriction on review approval or merge permissions for this repository? fangyaozheng is a maintainer on our side, but it looks like he is currently unable to approve this PR. We are not sure whether this is due to permission settings or something else.

Happy to discuss and provide any additional context that would be helpful. Thanks!

@steipete

Copy link
Copy Markdown
Contributor

Verification before landing:

  • Rebased head: ecc1bbd
  • Focused proof: node scripts/run-vitest.mjs src/auto-reply/reply/get-reply-run.media-only.test.ts src/auto-reply/reply/dispatch-acp.test.ts src/auto-reply/reply/agent-runner.media-paths.test.ts --reporter=dot (129 tests passed)
  • Auto Review: clean, no accepted/actionable findings
  • GitHub CI: green on the exact pushed head
  • Current main merge sanity: clean merge-tree against origin/main

Thanks @marchpure!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants