From 09879ed67c98e50de214149b5d323ab40d64a8fb Mon Sep 17 00:00:00 2001 From: Extra Small Date: Wed, 25 Mar 2026 06:26:33 -0700 Subject: [PATCH] fix: prioritize predefined model context_limit over canonical registry (#7888) Signed-off-by: Extra Small Signed-off-by: Douwe Osinga Co-authored-by: Douwe Osinga --- crates/goose/src/model.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/crates/goose/src/model.rs b/crates/goose/src/model.rs index 480891fbf2..68f7f304d1 100644 --- a/crates/goose/src/model.rs +++ b/crates/goose/src/model.rs @@ -111,6 +111,12 @@ impl ModelConfig { } pub fn with_canonical_limits(mut self, provider_name: &str) -> Self { + if let Some(pm) = find_predefined_model(&self.model_name) { + if self.context_limit.is_none() { + self.context_limit = pm.context_limit; + } + } + if let Some(canonical) = crate::providers::canonical::maybe_get_canonical_model(provider_name, &self.model_name) { @@ -125,13 +131,6 @@ impl ModelConfig { } } - // Try filling remaining gaps from predefined models - if self.context_limit.is_none() { - if let Some(pm) = find_predefined_model(&self.model_name) { - self.context_limit = pm.context_limit; - } - } - self }