Skip to content

fix(client): let clients drop tool-result image payloads from the store - #59101

Merged
Hona merged 1 commit into
devfrom
backport-client-images
Oct 25, 2026
Merged

Hona merged 1 commit into
devfrom
backport-client-images

Conversation

@Hona

@Hona Hona commented Oct 25, 2026 •

Copy link
Copy Markdown
Member

Backport of #58427 and #58560 from beta.

Problem

Tool results can carry screenshots as inline data: files. The store kept every one as base64, so a long session with browser or computer-use tools held hundreds of MB, even in a client that never shows those images.

Change

  • omitToolFileData option on createData: off by default. When set, inline data: files in tool results become an empty data:<mime>;base64, URI, so the item still says what it was. file: and other URIs are untouched.
  • Where it applies: live session.tool.success and session.tool.failed events, and fetched message pages.
  • Memory detail (fix(app): stop omitted tool images from keeping their payload alive #58560): the empty URI is built from mime, not sliced from the original, because a V8 sliced string keeps the whole payload alive.

No client turns it on yet. The desktop sets it with the beta desktop merge; the TUI is unchanged.

Testing

  • typecheck:tsc passes in client, tui and app.
  • New client/test/solid-data.test.ts case: fetched and live tool results drop inline data: payloads and keep other files. It passes with client/test/solid-refresh.test.ts.

Added by the opencode bot (AI-generated).

Public API: adds the optional omitToolFileData option to createData in the client package (off by default, backwards compatible)

Backport of #58427 and #58560 from beta. A new opt-in omitToolFileData option
stores inline data: files in tool results as an empty data:<mime>;base64, URI,
for clients that never render them. A session full of screenshots otherwise
keeps hundreds of MB of base64 alive.
Copilot AI balanced review requested due to automatic review settings October 25, 2026 23:38
@Hona
Hona enabled auto-merge (squash) October 25, 2026 23:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. When omitToolFileData is set, inline data: payloads are dropped in every path that puts tool results into the store: the live session.tool.success/session.tool.failed events and both message fetch paths (first page and older pages). The only other fetched message, the model-switched reload, has no tool content. file: URIs are left alone. I ran the new test in solid-data.test.ts together with solid-refresh.test.ts (both pass), checked that the new test fails on the base, and ran typecheck:tsc in client and tui (both pass).

Public API: adds an optional omitToolFileData option to createData in @opencode/client. It is off by default, so it is backwards compatible.

@Hona
Hona merged commit e943bb6 into dev Oct 25, 2026
22 checks passed
@Hona
Hona deleted the backport-client-images branch October 25, 2026 23:48
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.

2 participants