scratch_read returns whole files to a consumer that holds a fraction of one #1113

Closed
opened 2026-08-22 22:36:41 +00:00 by coilyco-ops · 0 comments
Member

Split out of #940, whose first defect is broader than the half this repository owns.

scratch_read bounds at maxScratchFileBytes (256 KB, the write limit) rather than at the tool-result budget the consumer actually holds. Measured on sirens-deep-owl-glass, 2026-08-18: scratch_read returned 53,696 bytes with 37,312 dropped against limit_bytes: 16384. The whole round trip was spent to throw 70% of it away, and the model then spent a further round on the spill file for content it should have had first time.

scratch_search was already fixed by 3f3d528 on the day #940 was filed, which is why only the read half remains.

What it should do

Return what fits and say where it stopped, with an offset that continues from there. Refusing the read outright is the smaller change and the wrong one: the agent writes files larger than one tool result and has to be able to read them back.

Acceptance

  • A file larger than the result budget comes back bounded, on a line boundary and never mid-rune.
  • The piece says how long the file is and what offset continues it.
  • Reading from the reported offsets reassembles the file exactly.
  • A short file is returned untouched, with no boundary note that would read as a truncation that did not happen.

Not this issue

The rest of #940 stays there: the MCP-side results (list_channel-message, the forgejo list_* family) are their servers' to bound, and the fetch_url half is separate.

Refs #940

Split out of #940, whose first defect is broader than the half this repository owns. `scratch_read` bounds at `maxScratchFileBytes` (256 KB, the write limit) rather than at the tool-result budget the consumer actually holds. Measured on `sirens-deep-owl-glass`, 2026-08-18: `scratch_read` returned **53,696 bytes with 37,312 dropped** against `limit_bytes: 16384`. The whole round trip was spent to throw 70% of it away, and the model then spent a further round on the spill file for content it should have had first time. `scratch_search` was already fixed by `3f3d528` on the day #940 was filed, which is why only the read half remains. ## What it should do Return what fits and say where it stopped, with an offset that continues from there. **Refusing the read outright is the smaller change and the wrong one**: the agent writes files larger than one tool result and has to be able to read them back. ## Acceptance * A file larger than the result budget comes back bounded, on a line boundary and never mid-rune. * The piece says how long the file is and what offset continues it. * Reading from the reported offsets reassembles the file exactly. * A short file is returned untouched, with no boundary note that would read as a truncation that did not happen. ## Not this issue The rest of #940 stays there: the MCP-side results (`list_channel-message`, the forgejo `list_*` family) are their servers' to bound, and the `fetch_url` half is separate. Refs #940
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
coilyco-gaming/sirens-echo#1113
No description provided.