fix(opencode): recover from ContextOverflowError via auto-compaction#14826
Open
PrakharMNNIT wants to merge 3 commits intoanomalyco:devfrom
Open
fix(opencode): recover from ContextOverflowError via auto-compaction#14826PrakharMNNIT wants to merge 3 commits intoanomalyco:devfrom
PrakharMNNIT wants to merge 3 commits intoanomalyco:devfrom
Conversation
When the LLM API returns a context overflow error, trigger compaction instead of killing the session. Previously the catch block had a TODO comment and fell through to a fatal error (return 'stop'). Now: sets needsCompaction = true and breaks to post-catch cleanup, which returns 'compact'. The prompt loop then creates a compaction task, generating a summary and allowing the session to continue.
Contributor
|
The following comment was made by an LLM, it may be inaccurate: Based on my search, I found one potentially related PR: Related PR:
Why it's related: Both PRs implement the same recovery mechanism (triggering auto-compaction when errors occur) to allow sessions to continue instead of failing. They follow the same pattern of setting a flag and initiating compaction. However, PR #14826 (the current PR) is not a duplicate — it addresses a different error type (ContextOverflowError from LLM directly) with its own distinct implementation. The related PR #14707 handles HTTP 413 errors. |
6 tasks
6 tasks
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 #14824
Type of change
What does this PR do?
When the LLM returns ContextOverflowError, the processor now sets
needsCompaction = trueand breaks to post-catch cleanup, which returns "compact". The prompt loop then creates a compaction task (prune + summarize), allowing the session to continue with reduced context.Previously the catch block had
// TODO: Handle context overflow errorwhich did nothing — the error fell through to kill the session.How did you verify your code works?
Screenshots / recordings
Backend-only change, no UI changes.
Checklist