Add configurable per-profile context window setting#9352
Conversation
|
I'm starting a first review of this pull request. You can follow along in the session on Warp. I completed the review and posted feedback on this pull request. Comment I completed the review and posted feedback on this pull request. Comment Powered by Oz |
There was a problem hiding this comment.
Overview
This PR adds a feature-flagged per-profile context-window override, including UI controls in AI settings and the profile editor, GraphQL model metadata plumbing, request propagation, telemetry, and slider snapping support.
Concerns
- The new
contextWindowGraphQL field is selected unconditionally, so clients can fail against servers that have not deployed the new API even when the client feature flag is disabled. - Invalid model metadata with
min > maxcan still reach UI/action paths that callu32::clamp, which panics on inverted bounds. - The outbound request copies the raw persisted context-window override without revalidating it against current model metadata, allowing stale out-of-range or non-configurable limits to be sent.
- The AI settings slider does not use the snap-value path added for the profile editor, so the two entry points behave inconsistently.
Verdict
Found: 0 critical, 3 important, 1 suggestions
Request changes
Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).
Powered by Oz
| .ui_builder() | ||
| .slider(view.context_window_slider_state.clone()) | ||
| .with_range(min as f32..max as f32) | ||
| .with_default_value(current_value as f32) |
There was a problem hiding this comment.
💡 [SUGGESTION] The settings-page slider never installs the snap values, so drag/click here emits arbitrary token counts while the profile editor snaps to rounded stops; wire the same context_window_snap_values(min, max) path into this slider for consistent behavior.
There was a problem hiding this comment.
Overview
This PR adds a feature-flagged per-profile context window limit, including GraphQL model metadata plumbing, profile persistence, request serialization, and slider/input UI in both AI settings and the profile editor.
Concerns
- The new GraphQL
contextWindowfield is requested unconditionally, so the feature flag does not protect production/stable clients from servers that have not deployed the schema yet. - Server-provided context-window bounds are not fully validated before UI code reaches
u32::clamp, which can panic on invalidmin > maxdata. - Persisted context-window overrides are read straight into request params without revalidating against the current model range/configurability.
- The AI settings slider omits the snap values used by the profile editor, so the two entry points can persist different classes of values.
Verdict
Found: 0 critical, 4 important, 0 suggestions
Request changes
Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).
Powered by Oz
| pub provider: LlmProvider, | ||
| pub host_configs: Vec<RoutingHostConfig>, | ||
| pub pricing: LlmPricing, | ||
| pub context_window: LlmContextWindow, |
There was a problem hiding this comment.
LlmInfo.contextWindow will fail before the flag can help. Make the server field available on all target servers first, or avoid adding it to production-bound queries until it is safe.
| .and_then(|id| prefs.get_llm_info(id)) | ||
| .map(|info| info.context_window.clone()) | ||
| .unwrap_or_else(|| prefs.get_default_base_model().context_window.clone()); | ||
| if cw.is_configurable && cw.max > 0 { |
There was a problem hiding this comment.
context_window is server-provided; if min > max, this still returns Some and the UI/action paths later call u32::clamp(min, max), which panics. Treat invalid ranges as non-configurable here.
| if cw.is_configurable && cw.max > 0 { | |
| if cw.is_configurable && cw.max > 0 && cw.min <= cw.max { |
| .as_ref() | ||
| .is_none_or(|t| matches!(t, crate::terminal::model::session::SessionType::Local)); | ||
|
|
||
| let context_window_limit = AIExecutionProfilesModel::as_ref(app) |
There was a problem hiding this comment.
RequestParams without validating it against the active base model's advertised range/configurability. A stale or corrupted cloud profile can still send an out-of-range limit even though the UI clamps user input; derive this through the context-window helper and clamp or clear before sending.
| .ui_builder() | ||
| .slider(view.context_window_slider_state.clone()) | ||
| .with_range(min as f32..max as f32) | ||
| .with_default_value(current_value as f32) |
There was a problem hiding this comment.
with_snap_values, unlike the profile editor, so dragging or clicking here persists arbitrary token counts instead of the nicely-rounded values generated and tested by context_window_snap_values. Share that helper and apply the same snap list here.
szgupta
left a comment
There was a problem hiding this comment.
Already reviewed these changes in a separate PR
| pub computer_use_model: LLMId, | ||
| pub is_memory_enabled: bool, | ||
| pub warp_drive_context_enabled: bool, | ||
| pub context_window_limit: Option<u32>, |
There was a problem hiding this comment.
u32 makes sense. this is coming from the server so we need it to explicitly be 32-bit rather than machine-dependent (usize).
Lets users override the agent base model's context window from settings and from the profile editor. The slider/input clamp to the model's advertised range, persist via AIExecutionProfilesModel, reset when the base model changes, and hide when global AI is disabled or the model isn't configurable.
9d46a75 to
aad157c
Compare
Adds a per-profile context window control for the agent's base model. Users can override the model's default context window from the AI settings page. Co-Authored-By: Oz <oz-agent@warp.dev>
Adds a per-profile context window control for the agent's base model. Users can override the model's default context window from the AI settings page. Co-Authored-By: Oz <oz-agent@warp.dev>
Description
Adds a per-profile context window control for the agent's base model, gated behind the new
configurable_context_windowfeature flag. Users can override the model's default context window from both the AI settings page and the profile editor.Context windowrow beneath the base model dropdown:[min — slider — max] [numeric input]. The control hides if the active base model isn't configurable, if global AI is disabled, or if the feature flag is off.[min, max]range, snap to nicely-rounded values, and stay in sync with each other on drag, commit, profile refresh, model change, and AISettings updates.AIExecutionProfilesModel::set_context_window_limit, plumbed throughRequestParams.context_window_limitso the agent request reflects the user's choice.Uint32newtype mapped to schema'sUintscalar (orphan-rule workaround for cynic), and wiresLlmContextWindow { is_configurable, min, max, default }throughLlmInfofor bothget_feature_model_choicesandworkspacequeries.warpui_coreslider gains snap-value support, used to render reasonable tick stops across very wide ranges.Testing
app/src/ai/execution_profiles/editor/mod_test.rscovering snap-value generation across small, large, offset, equal-min/max, and min>max ranges.cargo nextest run -p warp --features configurable_context_window snap_values context_windowpasses locally.cargo check -p warp --features configurable_context_windowpasses with no warnings.Server API dependencies
FeatureFlag::ConfigurableContextWindow.Agent Mode
Changelog Entries for Stable
CHANGELOG-OZ: Configurable max context window per profile.
Conversation link
Co-Authored-By: Oz oz-agent@warp.dev