Add max context window model metadata (#18382)

Adds max_context_window to model metadata and routes core context-window
reads through resolved model info. Config model_context_window overrides
are clamped to max_context_window when present; without an override, the
model context_window is used.
This commit is contained in:
Ahmed Ibrahim
2026-04-17 21:48:14 -07:00
committed by GitHub
parent e9c70fff3f
commit 5bb193aa88
17 changed files with 330 additions and 6 deletions
+5 -3
View File
@@ -75,9 +75,11 @@ pub(crate) struct TurnContext {
impl TurnContext {
pub(crate) fn model_context_window(&self) -> Option<i64> {
let effective_context_window_percent = self.model_info.effective_context_window_percent;
self.model_info.context_window.map(|context_window| {
context_window.saturating_mul(effective_context_window_percent) / 100
})
self.model_info
.resolved_context_window()
.map(|context_window| {
context_window.saturating_mul(effective_context_window_percent) / 100
})
}
pub(crate) fn apps_enabled(&self) -> bool {