-
Notifications
You must be signed in to change notification settings - Fork 47
🤖 feat: warn when switching to model that can't fit current context #1667
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 70d776494f
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0928d0e264
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@codex review |
d7c727e to
cdc6fbb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d7c727ebd8
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
e12a4e8 to
4b56412
Compare
|
@codex review |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
0417ca9 to
3b88432
Compare
Add a soft warning banner when users switch from a high-context model (e.g., Sonnet with 1M) to a lower-context model (e.g., GPT-4o 128K) while current context exceeds 90% of the target model's limit. Features: - Warning banner appears above chat input on model switch - One-click "Compact with <model>" action using preferred/previous model - Dismissible (session-only, re-shows on next model switch) - Recomputes when 1M toggle changes (both directions) - Only one compaction warning shows at a time (context-switch takes priority) Implementation: - New useContextSwitchWarning hook encapsulates all warning logic - checkContextSwitch utility determines if warning is needed - ContextSwitchWarning component renders the banner - Storybook story demonstrates the feature
- Move onModelChange call before early returns so warning works even offline or with custom agents active - Track previous pending model via ref instead of using last assistant message's model, so compaction fallback works even when user switches without sending a message first
- Extract shared getEffectiveContextLimit helper for 1M toggle logic - Fix ContextSwitchWarning story to use data-tutorial selector (avoids 'multiple elements' error) - Fix handleCompact to pass model at top-level of executeCompaction (prevents global preference override)
WorkspaceModeAISync can update pendingModel via localStorage when mode/agent changes. Add effect to detect these external changes and recompute warning.
Initialize prevPendingModelRef to null so the effect triggers on first render, detecting model 'change' from null to current model and showing the warning when context exceeds limit.
When the basic compaction model resolution (preferred → previous) fails, fall back to searching all known models for one with larger context that the user can access (has provider credentials or gateway routing). Also changed warning text from 'is near' to 'may exceed' since the warning can trigger when context actually exceeds the target limit.
b230f49 to
d769b96
Compare
|
@codex review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d769b9655f
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
- Replace raw emoji icon with AlertTriangle SVG (AGENTS.md compliance) - Validate higher-context compaction suggestions against current tokens using getEffectiveContextLimit before offering 'Compact with ...' action
|
@codex review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6990a4a5fc
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Gate the 'tokens became available' re-check to only fire on 0 -> >0 transition. This prevents the warning from immediately reappearing after user dismissal while still allowing it to trigger on initial usage data load.
|
@codex review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bead5a6705
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
- Add shared parseModelString() and isModelAllowedByPolicy() to policyUi.ts - Remove duplicate helpers from useModelsFromSettings and ModelsSection - Thread policy into getExplicitCompactionSuggestion and getHigherContextCompactionSuggestion - Add ContextSwitchOptions to checkContextSwitch for provider config + policy validation - Update useContextSwitchWarning and useCompactAndRetry to pass effective policy This prevents the context switch warning from suggesting compaction models that are blocked by policy or have unconfigured providers. Previously, the warning derived compaction models from persisted preference or previous assistant model, which could become invalid after provider keys are removed or policy changes.
|
@codex review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 43c447a66f
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 138f0b5df6
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0d7c2ec526
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9831364688
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0a7b30af28
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Summary
Add a soft warning banner when users switch from a high-context model (e.g., Sonnet with 1M) to a lower-context model (e.g., GPT-4o 128K) while current context exceeds 90% of the target model's limit.
Features
Implementation
useContextSwitchWarninghook encapsulates all warning logiccheckContextSwitchutility determines if warning is neededgetHigherContextCompactionSuggestionfinds usable models with larger context when basic resolution failsContextSwitchWarningcomponent renders the bannerLimitations
The warning uses token counts from the previous model's tokenizer as an approximation. Different models have different tokenizers, so the actual token count for the target model may vary. We can't compute the exact count without making a request to the target model's tokenizer. The 90% threshold provides some buffer for this variance.
Generated with
mux• Model:anthropic:claude-opus-4-5• Thinking:high• Cost:$45.19