Skip to content

docs(rfc): add RFC-0059 image attachment normalization - #375

Merged
Million-mo merged 3 commits into
mainfrom
docs/rfc-0059-image-attachment-normalization
Aug 17, 2026
Merged

docs(rfc): add RFC-0059 image attachment normalization#375
Million-mo merged 3 commits into
mainfrom
docs/rfc-0059-image-attachment-normalization

Conversation

@Million-mo

Copy link
Copy Markdown
Collaborator

Summary

Adds RFC-0059: Image Attachment Normalization (DRAFT), which proposes inserting the existing resize_image_if_needed() normalization into the protocol user-upload path.

Context

AgentPool already normalizes images on the tool-read path: resize_image_if_needed() in src/wolfharness_toolsets/fsspec_toolset/image_utils.py (Pillow-based, default 2000px / 4.5MB) is wired into read tool and the fsspec toolset.

However, the protocol user-upload paths bypass it entirely:

  • Python API run_agent(image_url=...)ImageUrl
  • ACP server ImageContentBlock/BlobResourceContentsBinaryImage
  • OpenCode server FilePartInputBinaryContent.from_data_uri()

Oversized field photos (4000×3000px, 10–20MB) get forwarded to the model unchanged, risking context overflow and opaque provider errors.

What the RFC proposes

  1. Reuse the existing resize_image_if_needed() rather than building a new resizer
  2. Insert it at the FilePart → pydantic-ai content conversion points across all three protocol entries
  3. Distinct over-limit failure semantics: user input errors cleanly, tool-result images keep omission behavior
  4. Config-supported limits (attachment.image.{auto_resize, max_width, max_height, max_base64_bytes})

Files

  • docs/rfcs/draft/RFC-0059-image-attachment-normalization.md (new, 477 lines)

Note

Following repo convention, STATUS.md is maintained separately from individual RFC commits (per RFC-0058 precedent) — not touched in this PR.

Reviewers

@yuchen.liu (pending)

Proposes inserting the existing resize_image_if_needed() normalization
(the read tool / fsspec toolset path, Pillow-based, default 2000px / 4.5MB)
into the protocol user-upload conversion points: Python API run_agent,
ACP attachments, and OpenCode server FilePartInput. Distinct failure
semantics for user input vs tool-result over-limit; model failure
behavior based on opencode's image.ts reference.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Million-mo and others added 2 commits August 17, 2026 15:40
… points

Implement RFC-0059 Option 1: insert the existing resize_image_if_needed()
normalization into the protocol user-upload path so Python API, ACP, and
OpenCode server all constrain image attachments within the same limits as
the tool-read path.

- Add AttachmentImageConfig (auto_resize/max_width/max_height/
  max_base64_bytes, defaults mirroring opencode: 2000x2000px, 5MB base64)
- Add ImageNormalizer reusing resize_image_if_needed from the fsspec
  toolset; only data: URIs are processed (no SSRF); failures degrade to
  pass-through so sessions are never interrupted
- Wire into OpenCode extract_user_prompt_from_parts, ACP
  from_acp_content, and functional run_agent(image_url=...)
- auto_resize: false raises ImageSizeError for over-limit user input

Co-authored-by: Sisyphus <sisyphus@ohmyopen.com>
…zation

Cover the three RFC-0059 user-upload entry points with integration-style
unit tests: OpenCode extract_user_prompt_from_parts, ACP
from_acp_content, and functional run_agent image-url helpers. Each verifies
oversized images are resized, small images pass through, non-image parts
are untouched, and the no-normalizer path stays backward compatible.
@Million-mo
Million-mo merged commit 8f4ee58 into main Aug 17, 2026
12 checks passed
@Million-mo
Million-mo deleted the docs/rfc-0059-image-attachment-normalization branch August 17, 2026 09:21
coderlihong pushed a commit to coderlihong/wolfharness that referenced this pull request Aug 18, 2026
…l-worker-tools

Integrate upstream wolf1069b#364/wolf1069b#356/wolf1069b#368/wolf1069b#372/wolf1069b#374/wolf1069b#375/wolf1069b#367 changes. Resolved:
- pyproject/uv.lock: openviking-sdk 0.1.8 (keep local; image download_bytes comment)
- mcp_server_cap.py: keep fork's self._tool_prefix logic
- viking/tools.py: combine imports (PurePosixPath + json/Path/shutil/tempfile)
- test_viking*.py: accept upload_tree (local wiki feature), 4→5 / 12→13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant