From daf11f5b96a2ca5a5f36e62250e0aa8cc65641d7 Mon Sep 17 00:00:00 2001 From: Douwe Osinga Date: Sun, 17 May 2026 19:47:51 -0400 Subject: [PATCH] fix: zero out cost for local providers (ollama, local) (#9219) Signed-off-by: Douwe Osinga Co-authored-by: Douwe Osinga --- crates/goose/src/providers/canonical/mod.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/crates/goose/src/providers/canonical/mod.rs b/crates/goose/src/providers/canonical/mod.rs index 7f2fd75be1..ab7bc81a4a 100644 --- a/crates/goose/src/providers/canonical/mod.rs +++ b/crates/goose/src/providers/canonical/mod.rs @@ -64,6 +64,12 @@ pub fn recommended_models_from_registry(provider: &str) -> Vec { .collect() } +/// Providers that run models locally — their cost is always zero regardless +/// of what the canonical registry says for the underlying model architecture. +fn is_local_provider(provider: &str) -> bool { + matches!(provider, "ollama" | "local") +} + pub fn maybe_get_canonical_model(provider: &str, model: &str) -> Option { let registry = CanonicalModelRegistry::bundled().ok()?; @@ -74,8 +80,9 @@ pub fn maybe_get_canonical_model(provider: &str, model: &str) -> Option 0); + assert!( + canonical.limit.context > 0, + "context limit should be preserved" + ); } #[test]