Skip to content

fix(core): avoid duplicate image bytes in tool events#36524

Open
dexhunter wants to merge 1 commit into
anomalyco:v2from
dexhunter:durable-media-v2
Open

fix(core): avoid duplicate image bytes in tool events#36524
dexhunter wants to merge 1 commit into
anomalyco:v2from
dexhunter:durable-media-v2

Conversation

@dexhunter

@dexhunter dexhunter commented Jul 12, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #36343

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Production-shaped image tool output can store the same base64 bytes in both structured.content and a model-visible content[].uri. This change omits structured.content only when the value is non-empty canonical base64, both MIME types match a supported image type, and a file item contains the exact matching data URI.

Mismatched, unsupported, empty, invalid, non-media, and provider-executed compatibility data remain intact.

On the incident-shaped PNG fixture, the durable event fell from 2,007,411 to 1,003,986 bytes (49.986%), base64 occurrences fell from two to one, and chunked SSE remained parseable. This addresses local duplicate media bytes; the broader bounded-projection design remains tracked in #36444.

Supplementary autoresearch: public trajectory

How did you verify your code works?

  • 48 focused session-runner tests passed
  • full core suite: 1,288 passed, 6 skipped
  • repository pre-push typecheck: 31/31 package tasks passed
  • touched-file oxlint: 0 errors
  • strict evaluator preserved replay, provider behavior, unsupported output shapes, multiple files, input immutability, output bounding, and chunked SSE parsing
  • git diff --check passed

Screenshots / recordings

Not applicable; this changes a durable event projection with no UI changes.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Jul 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Jul 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@dexhunter

Copy link
Copy Markdown
Author

The required issue is #36343, and it is cross-linked from the issue timeline. The needs:issue label remains because this PR targets v2, while GitHub only creates closing-issue links from keywords when a PR targets the repository default branch. A maintainer with write access may need to link it manually or remove the label.

@dexhunter

Copy link
Copy Markdown
Author

Rebased this patch onto the current v2 branch. The rebuilt head is 50c74cef0; the patch applied without overlap with upstream changes. Fresh validation on this head: 19 focused tests passed, the 38-package workspace typecheck passed, touched-file oxlint reported 0 errors, and git diff --check passed.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant