Skip to content

perf(headless-runner): don't download files the model can't read - #7418

Merged
reachjalil merged 1 commit into
devfrom
perf/unreadable-files-skip-download
Nov 14, 2026
Merged

reachjalil merged 1 commit into
devfrom
perf/unreadable-files-skip-download

Conversation

@reachjalil

Copy link
Copy Markdown
Member

What is this about?

Workbot's runner no longer downloads a kept file when its type or size already says the model can't read it.

What problem does it solve?

Attaching a large video, or opening one again with open_file, made the runner hold the whole file in memory twice just to tell the model it can't be opened. A 100 MB video cost about 230 MB of memory in a cell that serves all of a person's chats.

What was the situation before?

The runner fetched the file from the files bucket, base64-encoded it, and only then looked at its type and size. That happened for audio, video, archives, old Office formats and unknown types, and for an image over about 3.7 MB, a PDF over 10 MB or an Office file over 12 MB.

How is this implemented?

  • tool-files.ts: the rules for "this can't be read at all" move into one check on name, type and size, exported as unreadableNote. readToolFile calls the same check, so every note keeps its exact wording.
  • saved-files.ts: SavedFiles.reading asks unreadableNote from the saved-file row and fetches the bytes only when the file can be read. Attachments and open_file both go through it.
  • One difference: a row whose object is missing from the bucket now gets the "Can't open" note instead of "no longer available" when its type or size rules it out, because the bucket is not asked.

What else changed?

  • package.json: a test:saved-files script for the new test.

Release note

none

Evidence

ee/apps/headless-runner/scripts/saved-file-reading.test.ts — before: opening a 100 MB video fetched it from the bucket; after: the same note comes back with no fetch, and a readable file is still fetched and read. No E2E.

A kept file was downloaded from the files bucket and base64-encoded before
its type and size were checked, so a 100 MB video cost about 230 MB of
memory to produce a one-line note. The same happened for an image over
about 3.7 MB, a PDF over 10 MB and an Office file over 12 MB, for both
attachments and open_file.

The saved-file row already has the name, type and size. SavedFiles.reading
now asks unreadableNote first and fetches the bytes only for a file that can
be read. readToolFile uses the same check, so the notes are worded exactly
as before.

Signed-off-by: Jalil <reachjalil@gmail.com>
@vercel

vercel Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

3 Skipped Deployments
Project Deployment Actions Updated
openwork-app Skipped Skipped Nov 14, 2026 1:12am UTC
openwork-den Skipped Skipped Nov 14, 2026 1:12am UTC
openwork-landing Skipped Skipped v0 Nov 14, 2026 1:12am UTC

Request Review

@vercel
vercel Bot temporarily deployed to Preview – openwork-app November 14, 2026 01:12 Inactive
@vercel
vercel Bot temporarily deployed to Preview – openwork-landing November 14, 2026 01:12 Inactive
@vercel
vercel Bot temporarily deployed to Preview – openwork-den November 14, 2026 01:12 Inactive
@reachjalil
reachjalil merged commit f0f9475 into dev Nov 14, 2026
19 checks passed

This branch was previously deployed

3 inactive deployments
Preview – openwork-app — 47bde014 Deployed Nov 14, 2026 by vercel[bot]
Preview – openwork-landing — 47bde014 Deployed Nov 14, 2026 by vercel[bot]
Preview – openwork-den — 47bde014 Deployed Nov 14, 2026 by vercel[bot]
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