Repository navigation
fix(session): port upstream bounded history images (anomalyco/opencode#62270) - #1714
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
|
Important Review skippedBot user detected. To trigger a single review, invoke the
|
25 of 71 tasks
|
👋 This PR was automatically closed by our quality checks. Common reasons:
If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you. |
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 #1712
Type of change
What does this PR do?
User-visible failure: every image a user pastes (or a tool like
readreturns) stays in history and is re-sent inline on every request. Images cost almost no tokens, so compaction never drops them. After enough screenshots the request body exceeds the provider's limit and every following turn fails withRequest body too large/multimodal data size is too large. Those messages weren't classified as overflow, so auto-compaction never ran and the session stayed broken.Port of upstream anomalyco/opencode#62270 (fixes upstream #39929 / #59794), adapted to the fork's v1
MessageV2.toModelMessagesEffect:MessageV2.boundImagesruns afterconvertToModelMessages. Once inline image bytes (userfile/imageparts and images insidetool-resultcontent) pass 25 MiB, the oldest are replaced with a text placeholder telling the model the image is gone, until the rest fit 15 MiB. The gap between the two values means the cut only moves every ~10 MiB of new images, so the replaced prefix and the provider prompt cache stay the same between cuts. Messages that don't change keep their object identity.http(s)URLs count as 0 bytes and are never replaced. Upstream's first version could still use up its cut on remote images (upstream issue core: boundImages spends its image-budget cut on remote images that carry no payload anomalyco/opencode#61391), so this port only replaces images that have an inline payload.request body too largeandmultimodal data size is too largeare added to the overflow patterns in bothprovider/error.tsandpackages/llm/src/provider-error.ts, so these errors trigger compaction instead of a hard failure.All changes are wrapped in
altimate_change start — upstream_fix:markers. Stored history is untouched; only the outgoing request is trimmed.How did you verify your code works?
session.message-v2.boundImagestests: below-trigger no-op, oldest-first replacement down to target, stable prefix as images arrive, remote URLs ignored and kept inside the cut, nested tool-result media, and end-to-end throughtoModelMessages(tool-result images and synthetic user images for OpenAI-compatible providers). New overflow cases for the two messages. Without the source change, 8 of the new tests fail.bun test test/session/message-v2.test.ts test/providerinpackages/opencode: 936 pass, 0 fail.packages/llmtests: 0 fail.bun typecheck(turbo, all 13 packages) passes.bun run script/upstream/analyze.ts --markers --base origin/main --strictpasses. Caveat: withupstream/devnow on the v2 layout, the audit sees no shared files and passes without checking anything. I also ran it with theupstreamremote temporarily pointed at a local mirror whosedevis v1.17.9: 3 upstream-shared files checked, all marked.Cost side effects
None. No new model calls, queries or resources. This reduces request payload size.
Screenshots / recordings
N/A, no UI change.
Checklist
Tracked in #1478.
Written by Devin
Summary by cubic
Ports the upstream fix that bounds images re-sent from session history, so sessions no longer break when pasted screenshots accumulate and push the request body over the provider's limit. Closes #1712.
request body too largeandmultimodal data size is too largenow count as context overflow, so these failures trigger auto-compaction instead of a hard error.Stored history is unchanged; only the outgoing request is trimmed.
Written for commit b299802. Summary will update on new commits.