Skip to content

feat(zalouser): surface inbound photo attachments via media array - #84924

Closed
JOY wants to merge 3 commits into
openclaw:mainfrom
JOY:feat/zalouser-inbound-images
Closed

JOY wants to merge 3 commits into
openclaw:mainfrom
JOY:feat/zalouser-inbound-images

Conversation

@JOY

@JOY JOY commented May 21, 2026 •

Copy link
Copy Markdown

Summary

Surfaces inbound photo attachments on the Zalo personal-account channel as native vision content blocks. Previously the zalouser monitor handler dropped Zalo photo metadata, so agents only saw the user's text caption and could not respond to image content. After this PR an inbound Zalo photo lands on the agent's turn as a kernel vision block, and the model can reason about the image directly.

What changes

  • extensions/zalouser/src/zalo-js.ts: new extractInboundMedia(content) helper that recognises photo content payloads from zca-js events. Detects via type === 'photo', image-extension URL pattern, or non-empty thumb. Returns { kind: 'image', url, thumbUrl? } for downstream pickup.
  • extensions/zalouser/src/zalo-js.ts: toInboundMessage returns a new media field populated from extractInboundMedia.
  • extensions/zalouser/src/monitor.ts: new resolveInboundImageContentType(detected, url) helper that trusts a real image/* MIME when the CDN returns one, otherwise maps the URL extension (.jpg|.png|.gif|.webp|.bmp) to the correct image MIME. Falls back to image/jpeg when both signals are absent. Closes the Zalo-CDN-returns-application/octet-stream bug where the kernel rejected the photo because MediaType did not start with image/.
  • extensions/zalouser/src/monitor.ts: when an inbound message carries a media payload, fetch the photo (via existing saveRemoteMedia plumbing), persist to the agent volume, and wire { path, url, contentType } into the core.channel.turn.buildContext({ media: [...] }) call. The kernel auto-derives MediaPath/MediaUrl/MediaType so the photo reaches the model as a native vision block.
  • extensions/zalouser/src/monitor.ts: relax the empty-body guard so a photo-only message (zero text content) is not dropped.

Tests

  • extensions/zalouser/src/monitor.media.test.ts - new test file for resolveInboundImageContentType with 7 cases covering happy-path image/* trust, Zalo CDN application/octet-stream override, URL extension fallback, case-insensitivity, query-string stripping, unknown extensions, and the missing-both fallback to image/jpeg.

Real behavior proof

Behavior or issue addressed: Inbound Zalo photo attachments arriving via the @openclaw/zalouser channel were silently dropped by monitor.ts - the model saw only the user's text caption, never the image. Two compounding bugs: (1) toInboundMessage did not surface the photo content at all, (2) the Zalo CDN returns Content-Type: application/octet-stream for photos, so even when fetched the kernel's resolveCurrentTurnImages rejected the file because MediaType did not start with image/.

Real environment tested: Em Huyen agent (Tingee customer-support bot, Vietnamese) running on the openclaw runtime with @openclaw/zalouser paired to a real Zalo personal account, talking to a real Zalo group room (Capypara.AI). Channel zalouser, model dos-ai/dos-ai (Qwen3.6-35B-a3b). Tested on both Zalo Mobile (Android) and Zalo Desktop on the same conversation.

Exact steps or command run after this patch:

  1. Apply this PR's zalo-js.ts + monitor.ts changes to the running zalouser plugin.
  2. Restart the agent container so the plugin reloads.
  3. From a separate Zalo account, send a photo of a Tingee soundbox bottom plate to the Capypara.AI group with the text @Em Huyền reset loa cho anh. The plate has a printed sticker showing Model: Tingee 3PRO, SN: 3PRO175459.
  4. Wait for Em Huyen to reply.
  5. Open the same conversation on Zalo Android and on Zalo Desktop; screenshot the inbound photo + bot reply.

Evidence after fix:

Zalo Android (Capypara.AI group, dark theme):

Em Huyen extracts SN from inbound photo on Zalo Android

Zalo Desktop (same conversation):

Em Huyen extracts SN from inbound photo on Zalo Desktop

Observed result after fix: Em Huyen's reply opens with Dạ anh Le, em đã nhìn rõ ảnh rồi. Mã thiết bị của anh là: SN: 3PRO175459 (Model: Tingee 3PRO). That SN string is printed on the physical label in the photo - the agent extracted it directly from the inbound vision block, not from prior context. Confirms end-to-end that (a) extractInboundMedia recognised the Zalo photo content payload, (b) resolveInboundImageContentType overrode the Zalo CDN's application/octet-stream to image/jpeg, (c) the kernel vision pipeline accepted the photo, (d) the agent received the image as a native vision block and read the SN off the label.

What was not tested: I have not run a head-to-head BEFORE / AFTER screenshot pair in the same Zalo conversation - the pre-fix behavior was the live deployment state captured separately in the downstream vendor patch's tracking ticket, which is what motivated this PR. The AFTER screenshots above are from a real deployment with the fix in place. Maintainers can reproduce the BEFORE state by reverting extensions/zalouser/src/monitor.ts to the pre-PR version and re-sending the same photo - the bot will reply without referencing the SN because it never received the vision block.

Screenshots live on a separate proof/zalouser-em-huyen-screenshots branch on the fork so the upstream merge does not import binaries into openclaw history.

Refs

Companion outbound PR: #85039 (Zalo client markdown normalizer).

@openclaw-barnacle openclaw-barnacle Bot added channel: zalouser Channel integration: zalouser size: M 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 changes before merge. Reviewed July 31, 2026, 10:05 PM ET / August 1, 2026, 02:05 UTC.

ClawSweeper review

What this changes

The PR adds photo detection, download, MIME normalization, and native image context for inbound messages on the Zalo personal-account plugin.

Merge readiness

⚠️ Needs maintainer review before merge - 7 items remain

Keep open: the PR addresses a real missing inbound-photo capability, and the supplied Zalo screenshots directly show the bot reading the serial number from the pictured label. The branch has two concrete merge blockers: its new fetch can hold a durable inbound delivery far too long, and its failure path logs the full attachment URL.

Likely related people:

  • steipete — medium confidence; recently merged adjacent Zalo personal-account runtime work.
  • zw-xysk — low confidence; current local history attributes the surrounding Zalouser monitor and normalization files to this contributor.

Priority: P2
Reviewed head: 2d10b3c07ab0929c6ccf2cd1a56f7ca2d00a44fd

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The PR has credible real Zalo proof and a sound plugin-local direction, but two focused P1 fixes are required before it is merge-ready.
Proof confidence 🐚 platinum hermit (4/6) ✨ media proof bonus Sufficient (screenshot): Prepared Android and Desktop screenshots visibly show the inbound device-label photo and an after-fix bot response extracting its serial and model; redact any further proof artifacts of personal or private details.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Verified Sufficient (screenshot): Prepared Android and Desktop screenshots visibly show the inbound device-label photo and an after-fix bot response extracting its serial and model; redact any further proof artifacts of personal or private details.
Evidence reviewed 6 items Current-main behavior: Current main returns immediately for an empty inbound body and provides no media field or inbound-media facts in the Zalouser agent context, so a photo-only message cannot reach the model as native image input.
PR delivery change: The PR allows a photo-only event through, resolves a local saved attachment, and passes normalized media facts into the inbound context.
Availability contract: The shared downloader supports total, response-header, and read-idle timeouts, but its default header deadline is 15 minutes; the PR passes only URL, filename hint, and size cap.
Findings 2 actionable findings [P1] Bound the new attachment download
[P1] Redact attachment URLs before logging failures
Security Needs attention Full attachment URL leaks through verbose failure log: The failure handler logs the unredacted event-provided URL, which can disclose signed query parameters or private media identifiers to operator logs.
Inbound fetch lacks caller-level deadlines: The plugin calls the guarded downloader without total, header, or idle deadline options despite the request sitting in a durable inbound-delivery path.

How this fits together

The Zalo personal-account plugin turns vendor message events into durable inbound channel deliveries and then dispatches agent turns. This change inserts photo extraction and guarded media download so a received image reaches a vision-capable model as turn context.

flowchart LR
  A[Zalo message event] --> B[Zalouser normalization]
  B --> C[Photo attachment detection]
  C --> D[Guarded media download]
  D --> E[Inbound media facts]
  E --> F[Agent turn context]
  F --> G[Vision-capable model response]
Loading

Before merge

  • Bound the new attachment download (P1) - Pass finite response-header, read-idle, and total deadlines here. saveRemoteMedia defaults its header deadline to 15 minutes and has no body-idle or whole-operation limit unless a caller supplies them; this awaited call runs inside ordered durable ingress delivery, so a stalled CDN can hold the affected lane instead of falling through to the intended text-only context.
  • Redact attachment URLs before logging failures (P1) - Do not interpolate params.media.url into the failure log. Attachment URLs can contain signed query data or identifying paths, and this new error path writes the complete value even though the shared fetch layer redacts its own diagnostic URL; log a redacted representation or origin instead.
  • Resolve security concern: Full attachment URL leaks through verbose failure log - The failure handler logs the unredacted event-provided URL, which can disclose signed query parameters or private media identifiers to operator logs.
  • Resolve security concern: Inbound fetch lacks caller-level deadlines - The plugin calls the guarded downloader without total, header, or idle deadline options despite the request sitting in a durable inbound-delivery path.
  • Resolve merge risk (P2) - An unresponsive photo URL can delay a durable Zalouser inbound delivery for the shared downloader's 15-minute default response-header timeout, with no per-read or total deadline supplied by this PR.
  • Resolve merge risk (P1) - The new verbose failure log includes the complete incoming attachment URL; CDN URLs can contain signed query parameters or other sensitive identifiers.
  • Resolve merge risk (P2) - The installed [email protected] source was unavailable locally and network resolution failed, so the claimed fallback event shapes could not be independently verified against the vendor dependency.

Findings

  • [P1] Bound the new attachment download — extensions/zalouser/src/monitor.ts:1007-1011
  • [P1] Redact attachment URLs before logging failures — extensions/zalouser/src/monitor.ts:1030-1031
  • [medium] Full attachment URL leaks through verbose failure log — extensions/zalouser/src/monitor.ts:1031
  • [medium] Inbound fetch lacks caller-level deadlines — extensions/zalouser/src/monitor.ts:1007
Agent review details

Security

Needs attention: The shared downloader preserves SSRF and response-size protections, but this PR still exposes full inbound attachment URLs in logs and does not supply channel-appropriate fetch deadlines.

PR surface

Source +162, Tests +161. Total +323 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 4 165 3 +162
Tests 2 161 0 +161
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 326 3 +323

Review metrics

Metric Value Why it matters
Inbound network boundary 1 new untrusted attachment download per accepted photo message The new pre-dispatch fetch needs explicit latency and log-redaction safeguards because it runs on the durable inbound delivery path.

Merge-risk options

Maintainer options:

  1. Bound and redact the inbound fetch (recommended)
    Pass finite response-header, read-idle, and total deadlines to the shared downloader, and log only a redacted URL representation before merging.
  2. Pause the capability change
    If the event-shape contract or operational deadline values cannot be confirmed, pause this PR until a Zalo owner supplies that dependency and runtime evidence.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Repair the Zalouser inbound-media helper only: keep the shared guarded downloader, add bounded total/header/idle deadlines and URL-safe failure logging, add focused regression tests, and do not add config or alter plugin SDK APIs.

Technical review

Best possible solution:

Keep photo support in the Zalouser plugin, but bound the shared guarded download at this inbound boundary and redact attachment URLs before logging failures; add focused coverage for both behaviors before merge.

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

Yes for the code-level regression: current main has no Zalouser inbound-media path, while the PR's screenshots show an after-fix photo-to-response flow. A local live Zalo reproduction was not possible, and the vendor dependency source was unavailable for event-shape verification.

Is this the best way to solve the issue?

No, not as submitted. The plugin-local use of the shared channel-media seam is the right solution, but it must apply that seam's bounded-fetch and safe-diagnostic controls rather than rely on a 15-minute default and raw URL logging.

Full review comments:

  • [P1] Bound the new attachment download — extensions/zalouser/src/monitor.ts:1007-1011
    Pass finite response-header, read-idle, and total deadlines here. saveRemoteMedia defaults its header deadline to 15 minutes and has no body-idle or whole-operation limit unless a caller supplies them; this awaited call runs inside ordered durable ingress delivery, so a stalled CDN can hold the affected lane instead of falling through to the intended text-only context.
    Confidence: 0.97
  • [P1] Redact attachment URLs before logging failures — extensions/zalouser/src/monitor.ts:1030-1031
    Do not interpolate params.media.url into the failure log. Attachment URLs can contain signed query data or identifying paths, and this new error path writes the complete value even though the shared fetch layer redacts its own diagnostic URL; log a redacted representation or origin instead.
    Confidence: 0.97

Overall correctness: patch is incorrect
Overall confidence: 0.94

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against fdcb321bfaaa.

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.

Label justifications:

  • P2: This is a useful channel capability with concrete customer-support value, but the current blockers have a bounded plugin-level blast radius.
  • merge-risk: 🚨 security-boundary: The PR fetches a URL derived from a received event and writes that full URL into failure logs.
  • merge-risk: 🚨 availability: The PR adds a blocking network operation to ordered durable inbound delivery without passing the downloader's available deadlines.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (screenshot): Prepared Android and Desktop screenshots visibly show the inbound device-label photo and an after-fix bot response extracting its serial and model; redact any further proof artifacts of personal or private details.
  • proof: sufficient: Contributor real behavior proof is sufficient. Prepared Android and Desktop screenshots visibly show the inbound device-label photo and an after-fix bot response extracting its serial and model; redact any further proof artifacts of personal or private details.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. Prepared Android and Desktop screenshots visibly show the inbound device-label photo and an after-fix bot response extracting its serial and model; redact any further proof artifacts of personal or private details.

Evidence

Security concerns:

  • [medium] Full attachment URL leaks through verbose failure log — extensions/zalouser/src/monitor.ts:1031
    The failure handler logs the unredacted event-provided URL, which can disclose signed query parameters or private media identifiers to operator logs.
    Confidence: 0.97
  • [medium] Inbound fetch lacks caller-level deadlines — extensions/zalouser/src/monitor.ts:1007
    The plugin calls the guarded downloader without total, header, or idle deadline options despite the request sitting in a durable inbound-delivery path.
    Confidence: 0.97

Acceptance criteria:

  • [P1] node scripts/run-vitest.mjs extensions/zalouser/src/monitor.media.test.ts extensions/zalouser/src/zalo-js.media.test.ts.
  • [P1] node scripts/run-vitest.mjs src/media/fetch.test.ts.
  • [P1] git diff --check.

What I checked:

  • Current-main behavior: Current main returns immediately for an empty inbound body and provides no media field or inbound-media facts in the Zalouser agent context, so a photo-only message cannot reach the model as native image input. (extensions/zalouser/src/monitor.ts:228, fdcb321bfaaa)
  • PR delivery change: The PR allows a photo-only event through, resolves a local saved attachment, and passes normalized media facts into the inbound context. (extensions/zalouser/src/monitor.ts:572, 2d10b3c07ab0)
  • Availability contract: The shared downloader supports total, response-header, and read-idle timeouts, but its default header deadline is 15 minutes; the PR passes only URL, filename hint, and size cap. (src/media/fetch.ts:29, fdcb321bfaaa)
  • Durable ingress ordering: Zalouser's durable ingress delivery awaits dispatch and drains received rows in order, so an unbounded attachment fetch delays subsequent delivery in that lane. (extensions/zalouser/src/ingress.ts:173, fdcb321bfaaa)
  • Real after-fix proof: Prepared Android and Desktop screenshots show the submitted device-label photo and the bot replying with the visible serial number 3PRO175459 and model Tingee 3PRO. (2d10b3c07ab0)
  • Recent adjacent ownership: The merged native-typing cleanup establishes recent ownership of the Zalouser dependency/runtime surface by steipete. (extensions/zalouser/src/zalo-js.ts:1, 61df1dbe7b0c)

Likely related people:

  • steipete: Merged the July 2026 Zalouser native dependency-contract cleanup and was explicitly brought into this PR's channel review context. (role: recent adjacent contributor; confidence: medium; commits: 61df1dbe7b0c; files: extensions/zalouser/src/zalo-js.ts, extensions/zalouser/src/monitor.ts)
  • zw-xysk: The local current-main history and blame attribute the surrounding Zalouser monitor and inbound normalization paths to this contributor; the shallow history makes older ownership ambiguous. (role: recent area contributor; confidence: low; commits: 124a68bd264a; files: extensions/zalouser/src/monitor.ts, extensions/zalouser/src/zalo-js.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Pass bounded total, header, and idle timeout options to the shared downloader and add regression coverage.
  • Redact the failing attachment URL and test that no raw query-bearing URL reaches plugin logs.
  • Confirm the [email protected] attachment event shape from the pinned dependency source when network or dependency artifacts are available.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • 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.

History

Review history (3 earlier review cycles)
  • reviewed 2026-07-01T01:58:02.184Z sha a12839fa4dc3468f3d6dee4cb79cf9485da2b3bd :: needs maintainer review before merge. :: none
  • reviewed 2026-07-17T10:52:09.296Z sha ffc2cd01645e73555c067d05c2d0cc6c081c5d05 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-29T13:05:08.505Z sha 2d10b3c :: needs maintainer review before merge. :: none

@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. labels May 21, 2026
@clawsweeper

clawsweeper Bot commented May 21, 2026 •

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg

🔥 Warming up: real-behavior proof passed; findings, security review, or rank-up moves are still in progress.

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.
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.

@JOY

JOY commented May 21, 2026

Copy link
Copy Markdown
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:

@JOY
JOY marked this pull request as draft May 21, 2026 12:32
@JOY

JOY commented May 21, 2026

Copy link
Copy Markdown
Author

Converted to draft. Reverting earlier misleading claim of live native-vision verification; the production path I observe today is still the image-tool round-trip, not buildContext({media:...}). Will undraft after I instrument the vendor port + validate promptImages=1 actually fires on a real Zalo CDN photo. Sorry for the noise.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels May 21, 2026
@JOY
JOY marked this pull request as ready for review May 21, 2026 13:19
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels May 21, 2026
@JOY

JOY commented May 21, 2026

Copy link
Copy Markdown
Author

Real Zalo client proof attached

Visual proof of the inbound photo extraction working end-to-end on a real Zalo conversation. Em Huyen agent (Tingee customer-support bot, Vietnamese) running this PR's media-array changes against the Zalo CDN photo URLs.

Zalo Android (Capypara.AI group):

Em Huyen extracts SN from inbound photo on Zalo Android

Zalo Desktop (same conversation):

Em Huyen extracts SN from inbound photo on Zalo Desktop

What to look at:

The user sent a photo of a Tingee soundbox label, asking the bot to reset it. The bot's reply opens with:

Dạ anh Le, em đã nhìn rõ ảnh rồi. Mã thiết bị của anh là: SN: 3PRO175459 (Model: Tingee 3PRO).

("Yes Mr. Le, I have seen the photo clearly. Your device ID is SN: 3PRO175459 (Model: Tingee 3PRO).")

That SN string is printed on the physical label in the photo - the agent extracted it directly from the inbound vision block, not from any prior context. Confirms the media array on ZaloInboundMessage is correctly populated from the Zalo CDN URL, the kernel's vision pipeline accepts the content-type, and the agent receives the image as a native vision block.

Screenshots live on a separate proof/zalouser-em-huyen-screenshots branch on the fork (not on the feature branch) so the upstream merge does not pull binaries into openclaw history.

@openclaw-barnacle openclaw-barnacle Bot added triage: blank-template Candidate: PR template appears mostly untouched. proof: supplied External PR includes structured after-fix real behavior proof. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 21, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. labels May 21, 2026
@JOY

JOY commented May 30, 2026

Copy link
Copy Markdown
Author

Thanks for the review. Addressed all three blockers in f6b9607e:

  1. Narrowed photo detection — dropped the thumb-presence fallback and now reject type === "link". Since zca-js link previews carry both href + thumb, a photo now only matches on an explicit type === "photo" or a recognisable image file extension on the href. Added a test for a link-preview-with-thumb → null.
  2. Bounded the media download — pass readIdleTimeoutMs (10s) and a hard total-timeout (30s) that aborts the underlying fetch via an AbortController requestInit.signal, mirroring the discord fetchDiscordMedia pattern, so a slow/unreachable Zalo CDN can't stall the inbound turn.
  3. Redacted media URLs in failure logs — log only the URL origin and scrub any raw-URL occurrence out of the underlying error message.

@clawsweeper re-review

@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 30, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels May 30, 2026
@JOY
JOY force-pushed the feat/zalouser-inbound-images branch from f6b9607 to a12839f Compare June 5, 2026 16:15
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Jun 5, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Jun 5, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Jul 15, 2026
@JOY

JOY commented Jul 15, 2026

Copy link
Copy Markdown
Author

Not stale - this is CI-green and just waiting on review. Worth a look now that 2026.7.x tightened inbound-media handling: this PR surfaces Zalo personal-account photos as native kernel vision blocks via extractInboundMedia, which is the sanctioned media path rather than side-loading files into a scratch dir. We run this in production for Zalo CS agents (device photo -> QR decode -> device reset), and the native-media approach here is what keeps that flow working under the newer media-directory restrictions. Happy to rebase onto latest main. Could a maintainer (cc @steipete, who's been in zalouser recently via #107716) take a look before it auto-closes?

@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label Jul 16, 2026
@JOY
JOY force-pushed the feat/zalouser-inbound-images branch from a12839f to ffc2cd0 Compare July 17, 2026 10:46
@JOY

JOY commented Jul 17, 2026

Copy link
Copy Markdown
Author

Rebased onto current main — this was conflicting and is now mergeable.

Two conflicts, both in extensions/zalouser/src/monitor.ts, resolved by keeping both sides:

  • the import line (resolveZalouserDmSessionScope landed upstream meanwhile; kept it and re-added the ZaloInboundMedia type import);
  • the file tail (kept the testing export and left the oxlint-disable max-lines directive last, where main has it).

I checked the processMessage signature rather than assuming the rebase was clean just because git said so — it still takes the same 7 parameters in the same order, so the testing wrapper is unchanged.

Verification on the rebased branch:

node scripts/run-vitest.mjs extensions/zalouser/src/monitor.media.test.ts extensions/zalouser/src/zalo-js.media.test.ts
  Test Files  2 passed (2)
       Tests  17 passed (17)

The wider extensions/zalouser/src run shows 17 failures in zalo-js.credentials.test.ts and zalo-quote-metadata.test.ts. Those are not from this PR — I ran the same two files on a clean main worktree with none of my changes and got the identical 2 failed / 17 failed result, so they are pre-existing on main.

Also confirmed this still fills a real gap rather than duplicating something that landed since: ZaloInboundMessage on main has no media field today, and there is no ZaloInboundMedia / inbound-media handling anywhere under extensions/zalouser. The PR uses the standard toInboundMediaFacts from plugin-sdk/channel-inbound, the same path discord/matrix/feishu/imessage already use, so zalouser ends up consistent with the other channels rather than inventing its own shape.

Commit emails changed to the GitHub noreply address (push was rejected under email-privacy otherwise). Content is byte-identical — the tree hash is unchanged across that rewrite.

Happy to rebase again if it drifts, or to split anything out if you'd prefer a smaller first cut.

@JOY
JOY force-pushed the feat/zalouser-inbound-images branch from ffc2cd0 to 06c5e42 Compare July 29, 2026 10:09
JOY added 3 commits July 29, 2026 17:45
zca-js already delivers photo content via `TAttachmentContent.href` (see
src/models/Message.ts in RFS-ADRENO/zca-js), but the zalouser plugin layer
discards it: `normalizeMessageContent` flattens the object to a JSON string
fallback so the agent only sees the photo URL embedded as text. Models
that try to act on it call the dynamic `image` tool unreliably (~50% of
the time on Qwen3.6 in our production deployment), and when they do call
it the image-tool round-trip adds 5+ seconds latency just to get back
what's already in the message.

This change wires inbound photos into the existing channel media pipeline
that Telegram + Discord extensions use:

- Add `ZaloInboundMedia` type (kind: "image", url, thumbUrl?).
- New `extractInboundMedia` helper in zalo-js.ts detects photo content via
  `content.type === "photo"` OR image file extension in href OR presence
  of a thumb URL (zca-js only ships thumb on photos). Returns null for
  text, links, files, stickers - those flow through the existing
  `normalizeMessageContent` text path unchanged.
- `toInboundMessage` attaches the resolved media to the returned
  `ZaloInboundMessage`.
- `monitor.ts processMessage` downloads the photo via `saveRemoteMedia`
  (same path Discord uses), then passes the saved file as a top-level
  `media: [...]` array to `buildContext` via `toInboundMediaFacts` - the
  kernel then derives MediaPath/MediaUrl/MediaType automatically and the
  agent runner attaches the photo as a native vision content block.
- Early-return guard relaxed: photo-only messages (no text caption) are
  now processed; previous code returned early when `rawBody` was empty,
  silently dropping photo-only inbound messages.

Net effect for the LLM: a photo arrives as a real vision attachment in
the user turn, identical to how Telegram or Discord photo messages
present. No tool call required. Verified live in production via DOS's
Em Huyen Vietnamese customer-support bot reading device serial numbers
from user-submitted photos of Loa Tingee bottom plates with 100% tool-call
elimination + ~5s latency reduction per turn.

Test coverage: 9 unit tests for `extractInboundMedia` covering photo
detection paths (explicit type, extension fallback, thumb fallback),
non-photo content shapes (text, links, sticker, audio, PDF), whitespace
trimming, and case-insensitive extension matching with query strings.

Refs: openclaw/openclaw image tool design (extensions/discord/src/monitor/
message-handler.context.ts pattern), zca-js TAttachmentContent shape.
Verified live 2026-05-21: Zalo CDN serves user-uploaded photos with
`Content-Type: application/octet-stream`, not `image/jpeg`. The kernel's
`resolveCurrentTurnImages` requires `MediaType` to start with `image/` to
attach the photo as a vision content block, so without this override the
downloaded photo lands on disk + appears in MediaPath/MediaUrl/MediaType
but with type "application/octet-stream" - and the agent never sees the
vision block. Bot then either hallucinates or asks the user to retype the
serial number as text.

New `resolveInboundImageContentType` helper: trusts a real image/* MIME
from saveRemoteMedia when present; otherwise picks from URL extension
(.jpg/.jpeg/.png/.gif/.webp/.bmp, case-insensitive, query-string-tolerant);
falls back to image/jpeg as the most common Zalo photo format.

extractInboundMedia has already gated us so we KNOW the bytes represent
an image, making the override safe.

Tests: 6 unit tests covering the trust path, the octet-stream override,
URL extension parsing with query strings, case-insensitivity, missing
content-type, and unknown-extension fallback.

End-to-end live verification (DOS Em Huyen bot servicing Vietnamese Zalo
customer support):

  [zalouser] [default] inbound message
  [DOS DEBUG v2] dosFetchInboundMedia called media={url, kind:"image", thumbUrl}
  [DOS DEBUG v2] fetch status=200 ok=true ctype=application/octet-stream
  [DOS DEBUG v2] overrode contentType to image/jpeg from url ext
  [DOS DEBUG v2] wrote file=/tmp/openclaw/zalouser-inbound-...jpeg size=105814
  [DOS DEBUG v3] MediaPath=/tmp/openclaw/zalouser-inbound-...jpeg MediaType=image/jpeg
  [context-diag] pre-prompt: ... promptImages=1

Bot reply quoted the serial number "3PRO175459" and model "Tingee 3PRO"
directly from the native vision block in the user turn, no `image` tool
round-trip required. Tested with 5 different photos against the live
photo-stal-*.zdn.vn CDN.
knip --production flags exports that only tests import. Move the pure
helpers extractInboundMedia and resolveInboundImageContentType into
inbound-media.ts so production code imports them across modules, and
drop the unused testing/__testing re-export.
@JOY
JOY force-pushed the feat/zalouser-inbound-images branch from 2ef397c to 2d10b3c Compare July 29, 2026 10:45
@clawsweeper clawsweeper Bot added status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Jul 29, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Aug 16, 2026
@openclaw-barnacle

Copy link
Copy Markdown

Closing due to inactivity.
If you believe this PR should be revived, post in #clawtributors on Discord to talk to a maintainer.
That channel is the escape hatch for high-quality PRs that get auto-closed.

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

Labels

channel: zalouser Channel integration: zalouser merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. 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: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M stale Marked as stale due to inactivity status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. triage: blank-template Candidate: PR template appears mostly untouched.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant