diff --git a/crates/goose/src/model.rs b/crates/goose/src/model.rs index be123c469e..250d914332 100644 --- a/crates/goose/src/model.rs +++ b/crates/goose/src/model.rs @@ -249,19 +249,28 @@ mod tests { #[test] #[serial] fn test_model_config_context_limits() { - let config = ModelConfig::new("claude-3-opus") - .unwrap() - .with_context_limit(Some(150_000)); - assert_eq!(config.context_limit(), 150_000); + // Clear all GOOSE environment variables to ensure clean test environment + with_var("GOOSE_TEMPERATURE", None::<&str>, || { + with_var("GOOSE_CONTEXT_LIMIT", None::<&str>, || { + with_var("GOOSE_TOOLSHIM", None::<&str>, || { + with_var("GOOSE_TOOLSHIM_OLLAMA_MODEL", None::<&str>, || { + let config = ModelConfig::new("claude-3-opus") + .unwrap() + .with_context_limit(Some(150_000)); + assert_eq!(config.context_limit(), 150_000); - let config = ModelConfig::new("claude-3-opus").unwrap(); - assert_eq!(config.context_limit(), 200_000); + let config = ModelConfig::new("claude-3-opus").unwrap(); + assert_eq!(config.context_limit(), 200_000); - let config = ModelConfig::new("gpt-4-turbo").unwrap(); - assert_eq!(config.context_limit(), 128_000); + let config = ModelConfig::new("gpt-4-turbo").unwrap(); + assert_eq!(config.context_limit(), 128_000); - let config = ModelConfig::new("unknown-model").unwrap(); - assert_eq!(config.context_limit(), DEFAULT_CONTEXT_LIMIT); + let config = ModelConfig::new("unknown-model").unwrap(); + assert_eq!(config.context_limit(), DEFAULT_CONTEXT_LIMIT); + }); + }); + }); + }); } #[test]