Repository navigation
fix(media-understanding): downscale configured image descriptions - #102002
harjothkhara wants to merge 7 commits into
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 27, 2026, 6:29 PM ET / 22:29 UTC. ClawSweeper reviewWhat this changesThe PR reuses the image tool’s model-aware compression policy so configured attachment descriptions, explicit image descriptions, and CLI image-description fallbacks can downscale oversized images before provider execution. Merge readiness⛔ Blocked until real behavior proof is added - 4 items remain This PR remains necessary: current Priority: P1 Review scores
Verification
How this fits togetherMedia-understanding receives image attachments from channel workflows and file/CLI calls, obtains their bytes, normalizes formats, then sends them to the selected vision provider. This change inserts model-aware compression before that provider request while retaining the final provider byte limit and skipped-attachment behavior. flowchart LR
A[Channel attachment or file input] --> B[Media-understanding entry]
B --> C[Selected provider and model]
C --> D[Shared image compression policy]
D --> E[Bounded source read and normalization]
E --> F[Final provider byte-limit check]
F --> G[Vision provider request or skipped attachment]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +311, Tests +439. Total +750 across 15 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Rebase onto current Do we have a high-confidence way to reproduce the issue? Yes from source: current main has a clear path where media-understanding reads images at the final cap and normalizes them without the image tool’s model-aware policy. A live current-main provider run was not performed in this read-only review. Is this the best way to solve the issue? Yes in principle: reusing the established shared compression resolver is preferable to maintaining a separate media-understanding policy, provided the rebased branch preserves the final-cap skip contract and supplies real-provider proof. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 0073862e232b. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (7 earlier review cycles)
|
59b061c to
da6f13c
Compare
|
@clawsweeper re-review Updated this PR at Evidence is now in the PR body: |
|
🦞🧹 I asked ClawSweeper to review this item again. |
da6f13c to
bf8cbbe
Compare
…x test lint Extract ImageCompressionModelCandidate into a leaf .types module so media-understanding/runtime-types no longer imports the agents model runtime through agents/image-compression-policy. On current main that back-edge closed a madge import cycle (check:architecture). Also hoist the getBuffer mock in the image-cap test to satisfy typescript(unbound-method). Co-Authored-By: Claude Opus 4.8 <[email protected]>
After rebasing onto current main, apply.test.ts failed: its synthetic image buffers now flow through the PR's new model-aware compression path, and the real optimizer rejects non-image bytes, dropping the attachment. These integration tests cover apply/HEIC/workspace routing, not the compression resolver (unit-tested in image-compression-policy and image-input-normalize tests), so mock the resolver to the pre-compression passthrough. No runtime change. Co-Authored-By: Claude Opus 4.8 <[email protected]>
11cf71a to
8a09f8e
Compare
|
@harjothkhara thanks for the PR. ClawSweeper is still waiting on real behavior proof before this can move forward. Useful proof can be a screenshot, short video, terminal output, copied live output, linked artifact, or redacted logs that show the changed behavior after the fix. Please redact private tokens, phone numbers, private endpoints, customer data, and anything else sensitive. Once proof is added to the PR body or a comment, ClawSweeper or a maintainer can re-check it. |
|
Closing this branch as stale. #101923 stays open — I am not claiming the underlying behavior is fixed. What changed underneath it: So this is a re-implementation against a restructured area, not a rebase, and a fresh 2-3 file PR would be smaller and easier to review than salvaging this one. Leaving #101923 open for that. |
Closes #101923
What Problem This Solves
Fixes media-understanding image-description paths that could still reject or send oversized images even when an image resize policy was available from configured defaults or selected provider/model metadata.
Why This Change Was Made
Media-understanding now reuses the shared model-aware image compression resolver used by the image tool instead of maintaining a config-only policy path. Explicit image descriptions, CLI image describe fallback candidates, and configured provider-entry runs resolve compression before reading/fetching bytes, use a bounded pre-compression source cap, then enforce the final provider
maxBytesafter optimization.This also keeps HEIC conversion and GIF preservation on the shared normalization path, and maps post-compression byte-cap failures back to the existing media-understanding
maxBytesskip contract instead of reporting them as provider failures.User Impact
Oversized photos sent through media-understanding image-description flows can be resized consistently with provider/model image limits and user image-quality defaults. Large inputs that still cannot be reduced to the provider cap remain non-fatal skipped attachments rather than failed provider attempts.
AI-assisted: yes. I reviewed the shared compression resolver, media-understanding explicit/provider-entry paths, CLI fallback candidate handoff, cap-ordering behavior, and focused test coverage in this PR. A sanitized local agent transcript was not included because this automation run did not have interactive approval to attach one.
Evidence
git diff --checkpassed.node scripts/run-vitest.mjs src/media-understanding/image-input-normalize.test.ts src/media-understanding/runner.entries.image-cap.test.ts src/media-understanding/runtime.test.ts src/media-understanding/runner.vision-skip.test.ts src/cli/capability-cli.test.ts src/media/web-media.test.ts src/agents/tools/image-tool.test.tspassed: 4 Vitest shards, 321 tests total..agents/skills/autoreview/scripts/autoreview --mode branch --base origin/mainpassed clean after the repair commits: no accepted/actionable findings; overall patch correct.origin/mainatb81666ca6a; current pushed head isda6f13cf83.Not run: live Anthropic/OpenClaw image-description repro with a real oversized phone photo. Crabbox/Testbox proof was unavailable in this worktree because the Crabbox wrapper failed its basic binary sanity check, so this update proves the source/runtime/CLI fallback behavior and local review gate but does not yet provide live provider proof.