You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ContextWindowExceededError during compaction (litellm & claude-opus-4.5) #11450
Context compaction fails with litellm.ContextWindowExceededError when the conversation history exceeds the model's context window, even when compaction is triggered manually.
This happens because the compaction process attempts to send the entire message history to the model for summarization, causing the input itself to exceed the context limit.
To reproduce
Start a session with a model having a limited context window (e.g., claude-opus-4.5).
Have a long conversation until the token usage exceeds the context window.
Wait for auto-compaction trigger or run /compact.
Expected behavior
Compaction should summarize and shorten the history, allowing the session to continue.
Environment
Model: claude-opus-4.5
Error:
litellm.ContextWindowExceededError: litellm.BadRequestError: BedrockException: Context Window Error - {"message":"The model returned the following errors: Input is too long for requested model."}
model=claude-opus-4.5. context_window_fallbacks=None. fallbacks=None.
Set 'context_window_fallback' - https://docs.litellm.ai/docs/routing#fallbacks. Received Model Group=claude-opus-4.5
Available Model Group Fallbacks=None
Additional context
The issue is located in packages/opencode/src/session/compaction.ts. The process function passes input.messages directly to MessageV2.toModelMessages without any truncation, leading to the overflow during the compaction request itself.
Plugins
Context7
OpenCode version
v1.1.47
Steps to reproduce
Steps to reproduce:
Configure model: Set active model to claude-opus-4.5 (or any model with strict context limits) connected via LiteLLM.
Fill context window: Engage in a long conversation or paste large files until the token usage exceeds the model's context limit (generating >200k tokens).
Trigger compaction: Either wait for auto-compaction to trigger, or manually run the /compact command.
Observe error: The process crashes with litellm.ContextWindowExceededError instead of summarizing the history.
These issues relate to compaction failures with context window errors, particularly affecting Anthropic models like Claude Opus 4.5. The core problem appears to be that compaction itself fails when attempting to process oversized history, which is exactly what you're experiencing.
Feel free to ignore if none of these address your specific case.
Activity
github-actions commentedon Jan 31, 2026
This issue might be a duplicate of existing issues. Please check:
These issues relate to compaction failures with context window errors, particularly affecting Anthropic models like Claude Opus 4.5. The core problem appears to be that compaction itself fails when attempting to process oversized history, which is exactly what you're experiencing.
Feel free to ignore if none of these address your specific case.
github-actions commentedon Apr 2, 2026
To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.