Skip to content

fix(agents): honor imageMaxDimensionPx at the provider and CLI image handoffs - #205663

Merged
obviyus merged 3 commits into
mainfrom
bugloop-205642
Nov 26, 2026
Merged

obviyus merged 3 commits into
mainfrom
bugloop-205642

Conversation

@obviyus

@obviyus obviyus commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

Root cause: src/agents/embedded-agent-runner/run/attempt-stream-settle.ts:504 calls materializeProviderContext without the configured agents.defaults.imageMaxDimensionPx, and src/agents/cli-runner/helpers.ts:338 (loadCliPromptImages) hydrates CLI images without it, so both re-sanitize at the 1200 px default while the canonical hydration already uses the configured value.

Fixes #205642

Thanks @solarwinds95 for the detailed report, the config timeline and the bundle trace that pointed straight at both handoffs.

What changed

  • Provider handoff: passes resolveImageSanitizationLimits(attempt.config).maxDimensionPx, the same resolution attempt-setup.ts, prompt-image-preparation.ts and the worker/harness callers use. materializeProviderContext now accepts maxDimensionPx (it still omits maxBytes).
  • CLI: loadCliPromptImages takes the run config and resolves the dimension itself, so the prehook loader, the initial payload and steered input all get it from one place.
  • Nothing else: no change to compression policy, quality steps, the 5 MB provider / 6 MB CLI byte caps, or defaults. With imageMaxDimensionPx unset the resolver returns nothing and both paths keep 1200 px.

What users see

With imageMaxDimensionPx: 2400 on main, the provider path re-sanitized every image at 1200 px. Those bytes no longer matched the image hashes pinned by the canonical hydration (which used 2400), so the provider request dropped the images and sent "3 image attachments could not be loaded" instead. After the fix the provider gets the canonical images: images up to 2400 px are sent unchanged, larger ones are resized to 2400, and the follow-up turn replays the same bytes. The CLI path now honors the setting too.

Re-encode note: the reporter's two JPEGs (854x1280, 1000x1280) grew because they were re-encoded at 1200 px. With a configured limit at or above 1280 they are now sent byte-identical, so that case goes away for this configuration. The same re-encode at the default 1200 px (the "larger than source" sanitizer behavior) is unchanged and out of scope here.

Evidence

Built Gateway in a secretless node:24.22.1 container, a local OpenAI-compatible stand-in that records the decoded size and hash of every image it receives, and a CLI-backend stand-in plugin that records the image files it is handed. One chat turn with JPEGs 854x1280, 1000x1280 and 3000x2000, then a text follow-up. Proof comment: #205663 (comment)

run config provider/CLI receives (turn 1 and replay) resize log on handoff
main x2 2400 0 images + "3 image attachments could not be loaded" maxDimensionPx=1200 maxBytes=5242880
fix x2 2400 854x1280 and 1000x1280 source bytes, 3000 px -> 2400x1600; replay identical only 3000x2000 -> 2400 (canonical)
main / fix unset identical bytes on both (801x1200, 938x1200, 1200x800, same sha256) 1200
CLI main 2400 801x1200, 938x1200, 1200x800 maxDimensionPx=1200 maxBytes=6291456
CLI fix 2400 854x1280, 1000x1280 source bytes, 2400x1600 2400

There is no imageMaxBytes setting (config validate rejects agents.defaults.imageMaxBytes), so the byte caps stay the existing constants.

Tests: attempt-stream-settle.image-limits.test.ts (provider handoff, image dropped on main) and a case in cli-runner.helpers.test.ts (CLI file re-encoded at 1200 px on main). Both fail on main and pass here.

Deltas against main: production +10 / -1, tests +104 / -0.

…handoffs

- The provider streaming handoff and the shared CLI image loader now pass the configured agents.defaults.imageMaxDimensionPx, resolved like the other prompt-image callers.
- Unset config still resolves to the 1200 px default, so default requests are unchanged.

Fixes #205642
…ndoffs

- Provider handoff: a 1600 px image under imageMaxDimensionPx 2400 reaches the provider unchanged (dropped on base).
- CLI loader: the same image reaches the CLI file unchanged (re-encoded at 1200 px on base).
- Use a typed provider runtime handle and literal model input/role types instead of a cast.
@clawsweeper

clawsweeper Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label Nov 26, 2026
@obviyus

obviyus commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator Author
#205642 proof: built Gateway (secretless node:24.22.1 Docker), local OpenAI-compatible stand-in recording every image it receives (decoded size, bytes, sha256), CLI-backend stand-in plugin recording the image files it is handed.
Base: main e9fd1f1e1236 (2026.11.10). Candidate: e13a83b5e989 (fix commit; PR head 4c15620e7fd5 = same production diff rebased on b8992c005468, tests only on top; main did not touch these files in between).
Inputs (frozen, inputs.sha256): photo-854x1280.jpg 577541B c9b77dd0, photo-1000x1280.jpg 674193B 78d3200a, photo-3000x2000.jpg 3143266B 3a4547c6.
Turn 1: chat.send with the three JPEGs. Turn 2: text-only follow-up (history replay).

== base1 (base1-20261126-061805) runtime=openclaw imageMaxDimensionPx=2400 extra=none
  provider req 3 msgs:  + note "3 image attachments could not be loaded"
  provider req 6 msgs:  + note "3 image attachments could not be loaded"
  resize log: 3000x2000 maxDimensionPx=2400 maxBytes=6291456 -> side 2400
  resize log: 854x1280 maxDimensionPx=1200 maxBytes=5242880 -> side 1200
  resize log: 1000x1280 maxDimensionPx=1200 maxBytes=5242880 -> side 1200
  resize log: 2400x1600 maxDimensionPx=1200 maxBytes=5242880 -> side 1200
== base2 (base2-20261126-061825) runtime=openclaw imageMaxDimensionPx=2400 extra=none
  provider req 3 msgs:  + note "3 image attachments could not be loaded"
  provider req 6 msgs:  + note "3 image attachments could not be loaded"
  resize log: 3000x2000 maxDimensionPx=2400 maxBytes=6291456 -> side 2400
  resize log: 854x1280 maxDimensionPx=1200 maxBytes=5242880 -> side 1200
  resize log: 1000x1280 maxDimensionPx=1200 maxBytes=5242880 -> side 1200
  resize log: 2400x1600 maxDimensionPx=1200 maxBytes=5242880 -> side 1200
== cand1 (cand1-20261126-061923) runtime=openclaw imageMaxDimensionPx=2400 extra=none
  provider req 3 msgs: 854x1280 577541B c9b77dd0, 1000x1280 674193B 78d3200a, 2400x1600 1087609B 7d2621d8
  provider req 6 msgs: 854x1280 577541B c9b77dd0, 1000x1280 674193B 78d3200a, 2400x1600 1087609B 7d2621d8
  resize log: 3000x2000 maxDimensionPx=2400 maxBytes=6291456 -> side 2400
== cand2 (cand2-20261126-061939) runtime=openclaw imageMaxDimensionPx=2400 extra=none
  provider req 3 msgs: 854x1280 577541B c9b77dd0, 1000x1280 674193B 78d3200a, 2400x1600 1087609B 7d2621d8
  provider req 6 msgs: 854x1280 577541B c9b77dd0, 1000x1280 674193B 78d3200a, 2400x1600 1087609B 7d2621d8
  resize log: 3000x2000 maxDimensionPx=2400 maxBytes=6291456 -> side 2400
== base-default (base-default-20261126-061840) runtime=openclaw imageMaxDimensionPx=unset
  provider req 3 msgs: 801x1200 302629B 52fd7d05, 938x1200 353245B c6c496b8, 1200x800 187185B fd2d5e32
  provider req 6 msgs: 801x1200 302629B 52fd7d05, 938x1200 353245B c6c496b8, 1200x800 187185B fd2d5e32
  resize log: 854x1280 maxDimensionPx=1200 maxBytes=6291456 -> side 1200
  resize log: 1000x1280 maxDimensionPx=1200 maxBytes=6291456 -> side 1200
  resize log: 3000x2000 maxDimensionPx=1200 maxBytes=6291456 -> side 1200
== cand-default (cand-default-20261126-061955) runtime=openclaw imageMaxDimensionPx=unset
  provider req 3 msgs: 801x1200 302629B 52fd7d05, 938x1200 353245B c6c496b8, 1200x800 187185B fd2d5e32
  provider req 6 msgs: 801x1200 302629B 52fd7d05, 938x1200 353245B c6c496b8, 1200x800 187185B fd2d5e32
  resize log: 854x1280 maxDimensionPx=1200 maxBytes=6291456 -> side 1200
  resize log: 1000x1280 maxDimensionPx=1200 maxBytes=6291456 -> side 1200
  resize log: 3000x2000 maxDimensionPx=1200 maxBytes=6291456 -> side 1200
== base-cli (base-cli-20261126-061900) runtime=cli imageMaxDimensionPx=2400 extra=none
  CLI files: 1200x800 187185B fd2d5e32, 801x1200 302629B 52fd7d05, 938x1200 353245B c6c496b8
  resize log: 1000x1280 maxDimensionPx=1200 maxBytes=6291456 -> side 1200
  resize log: 3000x2000 maxDimensionPx=1200 maxBytes=6291456 -> side 1200
  resize log: 854x1280 maxDimensionPx=1200 maxBytes=6291456 -> side 1200
== cand-cli (cand-cli-20261126-062010) runtime=cli imageMaxDimensionPx=2400 extra=none
  CLI files: 1000x1280 674193B 78d3200a, 2400x1600 1087609B 7d2621d8, 854x1280 577541B c9b77dd0
  resize log: 3000x2000 maxDimensionPx=2400 maxBytes=6291456 -> side 2400

Control imageMaxBytes: - openclaw.json:1 — agents.defaults: Unrecognized key: "imageMaxBytes" (no such setting; byte caps are unchanged constants).

Regression tests red on base (fix production diff reverted), green on candidate:
   × |agents-core| src/agents/cli-runner.helpers.test.ts > prepareCliPromptImagePayload prompt references > keeps images within the configured imageMaxDimensionPx 30ms
   × |agents-embedded-agent-run| src/agents/embedded-agent-runner/run/attempt-stream-settle.image-limits.test.ts > embedded provider image handoff > keeps images within the configured imageMaxDimensionPx 330ms
Pre-push: ocx test on 68 touched/importer files: 9 shards passed. tsgo test graph agents-other clean.

@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. impact:message-loss Channel message delivery can be lost, duplicated, or misrouted. impact:ux-friction User-facing flow adds avoidable confusion or support burden without fully blocking progress. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 26, 2026
@clawsweeper

clawsweeper Bot commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

The PR passes the existing configured image dimension limit through provider materialization and initial, prehook, and steered CLI image hydration.

Example: Send an 854×1280 JPEG with agents.defaults.imageMaxDimensionPx set to 2400.

  • Before: The handoff applies 1200 px again, reducing detail and potentially dropping the provider image when its hash changes.
  • After: Both handoffs preserve the original image bytes within the configured limit.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, worthwhile repair with production-boundary captures and distinct regression coverage; overall rating is capped because it delivers only part of the linked issue's requested behavior.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The supplied terminal capture exercises the built Gateway through chat.send and records actual provider-bound images and CLI files at 2400 px, stable provider replay, and unchanged unset-default bytes; its external stand-ins prove the changed handoffs rather than model recognition quality.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Partial
User problem: Images can lose configured detail or disappear from model input because a later handoff sanitizes them at 1200 px despite a higher configured limit.
Reason: The direction is approved by maintainer authorship and restores a documented existing setting with minimal code; the broader linked issue also requests compression behavior outside this patch.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR makes a focused repair to a current-main image configuration bug; no introduced correctness or security defects were found.

Reviewed head: 4c15620e7fd5ef779ba058f94639ab4b838520fb

Before merge

None.

Findings

None.

Agent review details

How this fits together

Agent image preparation turns attachment facts and inline images into provider request blocks or CLI image files, using shared sanitization and replay decisions.

flowchart TD
  A[Attachments and image facts] --> B[Canonical image preparation]
  C[Run configuration] --> B
  C --> D[Provider materialization]
  C --> E[Shared CLI image loader]
  B --> D
  B --> E
  D --> F[Provider request]
  E --> G[Initial or steered CLI input]
Loading

Technical review

Best possible solution:

Land the narrow dimension-propagation repair while leaving compression-policy changes for separate consideration.

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

Current-main source shows both missing limits and the resulting default sanitization; the contributor also supplies before/after Gateway and CLI captures, but this read-only review executed no target code.

Is this the best way to solve the issue?

Using the existing resolver and shared CLI loader is the smallest complete repair for dimension propagation; because the linked issue also requests a separate compression change, use Related rather than an automatic closing reference.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against c7824fb4d2b0.

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Vyctor H. Brzezowski: Raw commit ae8a103 adds src/agents/cli-runner/execute-plugin.steered-transcript.ts:57 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: ae8a103649e2; files: src/agents/cli-runner/execute-plugin.steered-transcript.ts)

PR surface

Source +9, Tests +109. Total +118 across 8 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 6 10 1 +9
Tests 2 109 0 +109
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 119 1 +118

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Production versus test LOC Production +10/-1; tests +109/-0 The small propagation repair has separate regressions checking actual provider image blocks and CLI file bytes.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 25, 2026, 8:28 PM ET / November 26, 2026, 01:28 UTC.

@obviyus
obviyus merged commit ef21b58 into main Nov 26, 2026
156 checks passed
@obviyus
obviyus deleted the bugloop-205642 branch November 26, 2026 01:32
@obviyus

obviyus commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator Author

Merged in ef21b58. Thanks @solarwinds95 for the precise report and log analysis in #205642. The provider handoff and the CLI runtime now use the configured agents.defaults.imageMaxDimensionPx, the same way the other image paths do, so images are no longer resized to 1200 px (or dropped from the request) when you set a larger limit, and images already within your limit are sent unchanged. The default 1200 px behavior and its re-encoding are unchanged; picking the smallest re-encode candidate and a configurable byte cap would be separate changes, so please open a new issue if you'd like those.

vincentkoc added a commit that referenced this pull request Nov 26, 2026
…irement-rule

* origin/main: (172 commits)
  test(gateway): expect a revoked person's Goal retry to be hidden as not found (#205698)
  fix: keep browser disabled when only hardening relay authentication (#203137)
  fix: recover Linux stream automations after command-anchor crashes (#203149)
  fix(whatsapp): identify voice-note captions as text in delivery receipts (#205381)
  fix(test): unblock restart-auth plugin and worker publication qualification (#205679)
  chore(ui): refresh control ui locales (#205691)
  fix: reduce memory during SQLite usage refresh (#201064)
  fix(plugins): readmit native captures with a dangling host link
  chore(i18n): refresh native locales (#205680)
  fix(update): hash SQLite lock bytes as zeros so Windows exclusion cannot fail verification (#205668)
  fix(skill-workshop): skip the skill diet for skills with Markdown outside support directories (#204881)
  fix(plugins): clarify dated SDK migration notices (#200932)
  fix: keep the resident launcher when reinstalling Gateway (#205655)
  fix: show the whole reply when you reopen a TUI session (#200455)
  test(ui): wait for restored speech player authorization (#199502)
  feat: let agents post approved GitHub comments (#204301)
  fix(agents): honor imageMaxDimensionPx at the provider and CLI image handoffs (#205663)
  chore(ui): refresh control ui locales (#205664)
  fix(google): preserve playback when Google Live splits audio into parts (#205364)
  fix: show named characters in exported session messages (#205362)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 26, 2026
…handoffs (openclaw#205663)

Root cause: src/agents/embedded-agent-runner/run/attempt-stream-settle.ts:504 calls `materializeProviderContext` without the configured `agents.defaults.imageMaxDimensionPx`, and src/agents/cli-runner/helpers.ts:338 (`loadCliPromptImages`) hydrates CLI images without it, so both re-sanitize at the 1200 px default while the canonical hydration already uses the configured value.

Fixes openclaw#205642

Thanks @solarwinds95 for the detailed report, the config timeline and the bundle trace that pointed straight at both handoffs.

## What changed

- Provider handoff: passes `resolveImageSanitizationLimits(attempt.config).maxDimensionPx`, the same resolution `attempt-setup.ts`, `prompt-image-preparation.ts` and the worker/harness callers use. `materializeProviderContext` now accepts `maxDimensionPx` (it still omits `maxBytes`).
- CLI: `loadCliPromptImages` takes the run config and resolves the dimension itself, so the prehook loader, the initial payload and steered input all get it from one place.
- Nothing else: no change to compression policy, quality steps, the 5 MB provider / 6 MB CLI byte caps, or defaults. With `imageMaxDimensionPx` unset the resolver returns nothing and both paths keep 1200 px.

## What users see

With `imageMaxDimensionPx: 2400` on main, the provider path re-sanitized every image at 1200 px. Those bytes no longer matched the image hashes pinned by the canonical hydration (which used 2400), so the provider request dropped the images and sent "3 image attachments could not be loaded" instead. After the fix the provider gets the canonical images: images up to 2400 px are sent unchanged, larger ones are resized to 2400, and the follow-up turn replays the same bytes. The CLI path now honors the setting too.

Re-encode note: the reporter's two JPEGs (854x1280, 1000x1280) grew because they were re-encoded at 1200 px. With a configured limit at or above 1280 they are now sent byte-identical, so that case goes away for this configuration. The same re-encode at the default 1200 px (the "larger than source" sanitizer behavior) is unchanged and out of scope here.

## Evidence

Built Gateway in a secretless node:24.22.1 container, a local OpenAI-compatible stand-in that records the decoded size and hash of every image it receives, and a CLI-backend stand-in plugin that records the image files it is handed. One chat turn with JPEGs 854x1280, 1000x1280 and 3000x2000, then a text follow-up. Proof comment: openclaw#205663 (comment)

| run | config | provider/CLI receives (turn 1 and replay) | resize log on handoff |
|---|---|---|---|
| main x2 | 2400 | 0 images + "3 image attachments could not be loaded" | maxDimensionPx=1200 maxBytes=5242880 |
| fix x2 | 2400 | 854x1280 and 1000x1280 source bytes, 3000 px -> 2400x1600; replay identical | only 3000x2000 -> 2400 (canonical) |
| main / fix | unset | identical bytes on both (801x1200, 938x1200, 1200x800, same sha256) | 1200 |
| CLI main | 2400 | 801x1200, 938x1200, 1200x800 | maxDimensionPx=1200 maxBytes=6291456 |
| CLI fix | 2400 | 854x1280, 1000x1280 source bytes, 2400x1600 | 2400 |

There is no `imageMaxBytes` setting (`config validate` rejects `agents.defaults.imageMaxBytes`), so the byte caps stay the existing constants.

Tests: `attempt-stream-settle.image-limits.test.ts` (provider handoff, image dropped on main) and a case in `cli-runner.helpers.test.ts` (CLI file re-encoded at 1200 px on main). Both fail on main and pass here.

Deltas against main: production +10 / -1, tests +104 / -0.

Co-authored-by: Ayaan Zaidi <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 28, 2026
…handoffs (#205663)

Root cause: src/agents/embedded-agent-runner/run/attempt-stream-settle.ts:504 calls `materializeProviderContext` without the configured `agents.defaults.imageMaxDimensionPx`, and src/agents/cli-runner/helpers.ts:338 (`loadCliPromptImages`) hydrates CLI images without it, so both re-sanitize at the 1200 px default while the canonical hydration already uses the configured value.

Fixes #205642

Thanks @solarwinds95 for the detailed report, the config timeline and the bundle trace that pointed straight at both handoffs.

## What changed

- Provider handoff: passes `resolveImageSanitizationLimits(attempt.config).maxDimensionPx`, the same resolution `attempt-setup.ts`, `prompt-image-preparation.ts` and the worker/harness callers use. `materializeProviderContext` now accepts `maxDimensionPx` (it still omits `maxBytes`).
- CLI: `loadCliPromptImages` takes the run config and resolves the dimension itself, so the prehook loader, the initial payload and steered input all get it from one place.
- Nothing else: no change to compression policy, quality steps, the 5 MB provider / 6 MB CLI byte caps, or defaults. With `imageMaxDimensionPx` unset the resolver returns nothing and both paths keep 1200 px.

## What users see

With `imageMaxDimensionPx: 2400` on main, the provider path re-sanitized every image at 1200 px. Those bytes no longer matched the image hashes pinned by the canonical hydration (which used 2400), so the provider request dropped the images and sent "3 image attachments could not be loaded" instead. After the fix the provider gets the canonical images: images up to 2400 px are sent unchanged, larger ones are resized to 2400, and the follow-up turn replays the same bytes. The CLI path now honors the setting too.

Re-encode note: the reporter's two JPEGs (854x1280, 1000x1280) grew because they were re-encoded at 1200 px. With a configured limit at or above 1280 they are now sent byte-identical, so that case goes away for this configuration. The same re-encode at the default 1200 px (the "larger than source" sanitizer behavior) is unchanged and out of scope here.

## Evidence

Built Gateway in a secretless node:24.22.1 container, a local OpenAI-compatible stand-in that records the decoded size and hash of every image it receives, and a CLI-backend stand-in plugin that records the image files it is handed. One chat turn with JPEGs 854x1280, 1000x1280 and 3000x2000, then a text follow-up. Proof comment: #205663 (comment)

| run | config | provider/CLI receives (turn 1 and replay) | resize log on handoff |
|---|---|---|---|
| main x2 | 2400 | 0 images + "3 image attachments could not be loaded" | maxDimensionPx=1200 maxBytes=5242880 |
| fix x2 | 2400 | 854x1280 and 1000x1280 source bytes, 3000 px -> 2400x1600; replay identical | only 3000x2000 -> 2400 (canonical) |
| main / fix | unset | identical bytes on both (801x1200, 938x1200, 1200x800, same sha256) | 1200 |
| CLI main | 2400 | 801x1200, 938x1200, 1200x800 | maxDimensionPx=1200 maxBytes=6291456 |
| CLI fix | 2400 | 854x1280, 1000x1280 source bytes, 2400x1600 | 2400 |

There is no `imageMaxBytes` setting (`config validate` rejects `agents.defaults.imageMaxBytes`), so the byte caps stay the existing constants.

Tests: `attempt-stream-settle.image-limits.test.ts` (provider handoff, image dropped on main) and a case in `cli-runner.helpers.test.ts` (CLI file re-encoded at 1200 px on main). Both fail on main and pass here.

Deltas against main: production +10 / -1, tests +104 / -0.

Co-authored-by: Ayaan Zaidi <[email protected]>

(cherry picked from commit ef21b58)

Backport adaptation: Kept the release steered-transcript code unchanged because steered-image hydration from ae8a103 is not shipped here. Applied configured limits to the existing ordinary CLI and embedded provider handoffs.

Co-authored-by: RomneyDa <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 28, 2026
…handoffs (#205663)

Root cause: src/agents/embedded-agent-runner/run/attempt-stream-settle.ts:504 calls `materializeProviderContext` without the configured `agents.defaults.imageMaxDimensionPx`, and src/agents/cli-runner/helpers.ts:338 (`loadCliPromptImages`) hydrates CLI images without it, so both re-sanitize at the 1200 px default while the canonical hydration already uses the configured value.

Fixes #205642

Thanks @solarwinds95 for the detailed report, the config timeline and the bundle trace that pointed straight at both handoffs.

- Provider handoff: passes `resolveImageSanitizationLimits(attempt.config).maxDimensionPx`, the same resolution `attempt-setup.ts`, `prompt-image-preparation.ts` and the worker/harness callers use. `materializeProviderContext` now accepts `maxDimensionPx` (it still omits `maxBytes`).
- CLI: `loadCliPromptImages` takes the run config and resolves the dimension itself, so the prehook loader, the initial payload and steered input all get it from one place.
- Nothing else: no change to compression policy, quality steps, the 5 MB provider / 6 MB CLI byte caps, or defaults. With `imageMaxDimensionPx` unset the resolver returns nothing and both paths keep 1200 px.

With `imageMaxDimensionPx: 2400` on main, the provider path re-sanitized every image at 1200 px. Those bytes no longer matched the image hashes pinned by the canonical hydration (which used 2400), so the provider request dropped the images and sent "3 image attachments could not be loaded" instead. After the fix the provider gets the canonical images: images up to 2400 px are sent unchanged, larger ones are resized to 2400, and the follow-up turn replays the same bytes. The CLI path now honors the setting too.

Re-encode note: the reporter's two JPEGs (854x1280, 1000x1280) grew because they were re-encoded at 1200 px. With a configured limit at or above 1280 they are now sent byte-identical, so that case goes away for this configuration. The same re-encode at the default 1200 px (the "larger than source" sanitizer behavior) is unchanged and out of scope here.

Built Gateway in a secretless node:24.22.1 container, a local OpenAI-compatible stand-in that records the decoded size and hash of every image it receives, and a CLI-backend stand-in plugin that records the image files it is handed. One chat turn with JPEGs 854x1280, 1000x1280 and 3000x2000, then a text follow-up. Proof comment: #205663 (comment)

| run | config | provider/CLI receives (turn 1 and replay) | resize log on handoff |
|---|---|---|---|
| main x2 | 2400 | 0 images + "3 image attachments could not be loaded" | maxDimensionPx=1200 maxBytes=5242880 |
| fix x2 | 2400 | 854x1280 and 1000x1280 source bytes, 3000 px -> 2400x1600; replay identical | only 3000x2000 -> 2400 (canonical) |
| main / fix | unset | identical bytes on both (801x1200, 938x1200, 1200x800, same sha256) | 1200 |
| CLI main | 2400 | 801x1200, 938x1200, 1200x800 | maxDimensionPx=1200 maxBytes=6291456 |
| CLI fix | 2400 | 854x1280, 1000x1280 source bytes, 2400x1600 | 2400 |

There is no `imageMaxBytes` setting (`config validate` rejects `agents.defaults.imageMaxBytes`), so the byte caps stay the existing constants.

Tests: `attempt-stream-settle.image-limits.test.ts` (provider handoff, image dropped on main) and a case in `cli-runner.helpers.test.ts` (CLI file re-encoded at 1200 px on main). Both fail on main and pass here.

Deltas against main: production +10 / -1, tests +104 / -0.

Co-authored-by: Ayaan Zaidi <[email protected]>

Release adaptation: Thread the existing image dimension setting through the stable initial CLI loader, CLI payload fallback, and provider materializer without changing byte caps. Leave CLI steering unchanged because stable has no image hydration call there.

Follow-ups: #207052 changes cached prompts for end-of-turn recovery; #206699 changes Claude cron login guidance. Neither fixes or is required by these image handoffs.

(cherry picked from commit ef21b58)
Co-authored-by: RomneyDa <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
* fix: show Claude CLI document uploads only once in chat

* fix: show Claude CLI document uploads only once in chat

OpenClaw-Publication: 4555cb04-bff2-43b3-aff8-ec271d6567b2

* fix: keep Claude document uploads on the message that sent them

* fix: preserve the released message queue result contract

Release adaptation: Use an optional accepted-input observer instead of widening
queueMessage's released Promise<void> contract. Reuse the stable steering and
transcript-rewrite handlers; leave source admission, native image steering,
config, and all SQLite schemas unchanged. The existing history index columns
also carry exact document correlation. Keep the released model-hook test layout.

Companion audit through be407a4: no later #203866 reference. PRs #208535
(Claude compacted fork summaries), #206158 (native subagent status), and
#205663 (image dimensions) are separate. PRs #208252 (Codex source), #207022
(embedded prompt dispatch), #206969 (fallback), #205963 (Copilot question
policy), and 50a7368 (snooze) do not own this path. SHA mentions in
#204700 and #204685 are update/qualification records, not follow-ups.

(cherry picked from commit 269f884)

Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling impact:message-loss Channel message delivery can be lost, duplicated, or misrouted. impact:ux-friction User-facing flow adds avoidable confusion or support burden without fully blocking progress. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

1 participant