Repository navigation
fix(core): keep image trimming stable across turns - #51986
Open
carson2222 wants to merge 2 commits into
Open
carson2222 wants to merge 2 commits into
carson2222 wants to merge 2 commits into
Conversation
Contributor
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
Contributor
|
The following comment was made by an LLM, it may be inaccurate: |
3 of 6 tasks
1 task done
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #51985
Type of change
What does this PR do?
boundImagestrims old images once a request carries more than 25 MiB of them, down to 15 MiB. It recomputes the cutoff from the full history on every request, so each new image changes which old images get replaced. The start of the history changes every turn and the Anthropic prompt cache misses every turn.This removes images in whole 10 MiB steps, the gap between the trigger and the target. The replaced set now stays the same from one request to the next until the image total crosses the next step. Retained images never go over 25 MiB. Between steps they sit anywhere from 15 to 25 MiB instead of always being cut back to 15 MiB.
How did you verify your code works?
Added a test that grows a history one image at a time. Before the change, 26, 30 and 35 images replaced 11, 15 and 20 of them. Now all three replace 10, and the 36th image moves the cutoff to 20.
Ran
bun run testandbun typecheckinpackages/core, plus the pre-pushbun run check. The core suite has 16 failures on my Mac (shell, plugin reload, MCP, watcher). The same 16 fail on unmodifiedv2.Screenshots / recordings
Not a UI change.
Checklist