Skip to content

fix(runtime): pruned read_file stubs keep their window and name the re-read (AP2) - #233

Merged
lg2m merged 2 commits into
docs/eng-978-ac-progress-firstfrom
fix/eng-988-ap2-pruned-read-stub
Oct 2, 2026
Merged

lg2m merged 2 commits into
docs/eng-978-ac-progress-firstfrom
fix/eng-988-ap2-pruned-read-stub

Conversation

@lg2m

@lg2m lg2m commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

Slice AP2 of autonomous-core.md (ADR-0054 § Context) · Linear ENG-988 · Base: #232 (the plan revision).

What changes for users

When a long session prunes an old read_file result, the model used to see:

[pruned: read_file {"path":"src/lib.rs"} returned 9120 bytes; call it again if needed]

That stub has no line window, so the model re-read the whole file. If it passed a hash it still remembered through if_changed_since, the re-read came back unchanged with no body, even though the text was no longer in context. In the session store, one child read the same file 47 times. The stub now reads:

read src/lib.rs L1-60/240 clipped=2
[pruned: read_file {"path":"src/lib.rs","limit":60} returned 9120 bytes; the text is no longer in context: read_file the lines you need again, without if_changed_since]

Design

  • header_line matches a header by tool name, but read_file's header starts with read. The pruning code now looks up read for read_file and splices out the trailing h: token (h:- too, for unhashed files). The window, line count and other fields are kept.
  • Other tools' stubs are unchanged, including search and tree, which already kept their headers.
  • Live pruning (on overflow) and assembly pruning both call prune_stale_tool_results, so they produce the same stub text. The replay invariant is unaffected.
  • docs/design/tools.md § Headers is amended to match.

Verification

  • Regression pruned_read_file_stubs_keep_the_window_drop_the_hash_and_name_the_reread failed on the base: it got the bare stub with no header. It passes now. It covers a windowed read, an unhashed (h:-) read, and a path that contains a hash-shaped segment. Only the trailing hash is spliced out.

  • a_run_that_outgrows_the_window_stubs_its_stale_reads_instead_of_failing now asserts that live pruning produces the same stub shape as assembly.

  • Independent read-only review approved, with should-fixes that are all taken in 0329a8c.

  • Four existing tests asserted that the stub starts with [pruned or ends with the old hint. They now assert the new shape, including that the hash is absent.

  • cargo test --workspace: 2008 passed (2012 with AP1 stacked), 0 failed. cargo clippy --workspace --all-targets --all-features -D warnings and cargo fmt --check are clean.

  • context_assembly bench: 500 iterations, 4 runs each, A/B on the same host. Assemble medians:

    archived runs before after
    10 50.3 µs 50.0 µs
    1 000 50.9 µs 53.1 µs
    10 000 54.1 µs 55.3 µs

    The before and after ranges overlap, and IO pressure was 20–37 % during the runs, so the differences are within noise. The bench's fixture prunes read_file results, so it exercises the new path. Raw output is in target/qq-perf/ap2-2026-10-01/.

Compatibility

No protocol, descriptor or store change. Old sessions replay with the new stub text, since stubs are computed at assembly and stored rows are untouched. A pruned stub is a few bytes longer, but still shorter than the result it replaces; otherwise it is not used.

…e-read

A pruned read_file result lost its header, because the header names the
operation (`read`) while the stub looked for the tool name. The stub then
said "call it again if needed", and a re-read that passed a remembered hash
through if_changed_since came back `unchanged` with no body, for text that
was no longer in context.

The stub now keeps `read <path> L…/… [fields]`, drops the `h:` token, and
says to re-read the needed lines without if_changed_since. Other tools'
stubs are unchanged. Live and assembly pruning share one function, so both
produce the same text.

AP2 of docs/plans/autonomous-core.md (ADR-0054).

Linear: ENG-988
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@lg2m
lg2m added this pull request to stack #234 October 1, 2026 16:52
A path segment shaped like h:<hex> is kept. The live-pruning test now
asserts the same stub shape as assembly (review follow-up).

Linear: ENG-988
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