context_window_limit is silently ignored and then deleted from settings.toml for custom-endpoint models
Describe the bug
For a model served by a custom endpoint (the model chip shows <model> (Custom · <endpoint>)), the context_window_limit field of an agent execution profile has no effect, and the value is then silently deleted from settings.toml without any warning in the UI or in ~/Library/Logs/warp.log.
Steps to reproduce
- Configure a custom endpoint with at least one model (Settings → search "API keys" → custom endpoint; OpenAI Chat Completions schema).
- Select that model so the agent footer chip shows
<model> (Custom · <endpoint>). - Add
context_window_limit = 1000000under[agents.execution_profiles.default]in~/.warp/settings.toml(Warp hot-reloads this file, so no restart is needed). - Observe that:
- the
N% context remainingindicator in the footer is unchanged; - the key is removed from
settings.tomlon the next reconcile (server model-list refresh, or any BYOK key change), with no user-visible explanation.
- the
Expected behavior
Either the configured limit is applied, or Warp tells the user that it cannot be applied to the selected model. Silently deleting a user-authored setting is the bug: the JSON settings schema documents context_window_limit as an ordinary optional field ("Optional context window limit in tokens. The valid range is model-dependent and determined server-side; the value is automatically clamped to the selected model's supported context window"), which reads as "always settable, clamped as needed" — not "ignored and erased for custom models". The profile editor also just hides the control for these models, so there is no feedback on any surface.
Root cause (traced in the open-source client)
- Custom-endpoint models are synthesized client-side with a default, non-configurable context window.
app/src/ai/llms.rs,custom_llm_info_from()doescontext_window: LLMContextWindow::default().LLMContextWindowderivesDefault, sois_configurable = false, min = 0, max = 0, default_max = 0. (Server-catalog models get real values mapped inapp/src/server/server_api/ai.rs, whereis_configurable/min/max/defaultcome from the server.) app/src/ai/execution_profiles/mod.rs:has_configurable_context_window()requiresllm.context_window.is_configurable && llm.context_window.max > 0, socontext_window_limit_for_request()returnsNonefor these models.app/src/ai/agent/api/impl.rs: the outbound request therefore carriesbase_model_context_window_limit: params.context_window_limit.unwrap_or(0)— i.e.0.app/src/ai/llms.rs:reconcile_disabled_model_preferences()explicitly clears the persisted value when the effective base model is not configurable (profiles.set_context_window_limit(&profile_id, None, ctx)).update_active_profile_base_model()clears it on every base-model change as well.- The displayed percentage is server-provided, not client-computed:
app/src/ai/blocklist/agent_view/agent_input_footer/mod.rsrendersremaining_pct = ((1.0 - usage) * 100.0), whereusage = conversation.context_window_usage()comes from the conversation usage metadata populated by the server.
There is additionally no way to declare a window for a custom model: CustomEndpointModel (crates/ai/src/api_keys.rs) has only name, alias, config_key, and CustomEndpoint has only name, url, api_key, models, schema. The whole custom-endpoint configuration surface is GUI-only and absent from settings.toml.
Suggested fixes
- Support declaring a context window (and other model metadata) per custom-endpoint model, so
is_configurablecan be true for them — this is the capability tracked by #11963 and #11947. - At minimum, stop silently deleting
context_window_limit. If the limit cannot apply to the effective base model, keep the stored value, log it, and either surface a warning in the profile editor or show why the control is unavailable. - Consider documenting the custom-model restriction in the settings schema description, since the current wording implies the field always works.
Additional context
Filed from source-level analysis of warpdotdev/warp plus direct observation on a local install (the context_window_limit line was added to settings.toml and disappeared again after Warp re-wrote the file). Not a regression — the behavior follows from the code paths above, which are not model-specific.
Environment
- OS: macOS (26.6.2)
- Shell: bash 3.2.57 (arm64-apple-darwin25)
- Warp version: v0.2026.08.12.21.54.stable_00
- Model: custom OpenAI Chat Completions endpoint (BYOK), selected as the execution profile's base model
- Is this an issue only in Warp: yes (no other client exposes this setting)
Source: warpdotdev/warp