@@ -122,6 +122,10 @@ fn apply_ollama_options(payload: &mut Value, model_config: &ModelConfig) {
122122 }
123123}
124124
125+ fn ollama_host_configured ( config : & crate :: config:: Config ) -> bool {
126+ config. get_param :: < String > ( "OLLAMA_HOST" ) . is_ok ( )
127+ }
128+
125129impl OllamaProvider {
126130 pub async fn from_env ( model : ModelConfig ) -> Result < Self > {
127131 let config = crate :: config:: Config :: global ( ) ;
@@ -262,6 +266,10 @@ impl ProviderDef for OllamaProvider {
262266 true
263267 }
264268
269+ fn inventory_configured ( ) -> bool {
270+ ollama_host_configured ( crate :: config:: Config :: global ( ) )
271+ }
272+
265273 fn inventory_identity ( ) -> Result < InventoryIdentityInput > {
266274 let config = crate :: config:: Config :: global ( ) ;
267275 Ok (
@@ -465,6 +473,51 @@ fn stream_ollama(response: Response, mut log: RequestLog) -> Result<MessageStrea
465473mod tests {
466474 use super :: * ;
467475
476+ #[ test]
477+ fn test_ollama_host_default_does_not_mark_inventory_configured ( ) {
478+ let _guard = env_lock:: lock_env ( [ ( "OLLAMA_HOST" , None :: < & str > ) ] ) ;
479+ let config_file = tempfile:: NamedTempFile :: new ( ) . unwrap ( ) ;
480+ let secrets_file = tempfile:: NamedTempFile :: new ( ) . unwrap ( ) ;
481+ let config = crate :: config:: Config :: new_with_config_paths (
482+ vec ! [ config_file. path( ) . to_path_buf( ) ] ,
483+ secrets_file. path ( ) ,
484+ )
485+ . unwrap ( ) ;
486+
487+ assert ! ( !ollama_host_configured( & config) ) ;
488+ }
489+
490+ #[ test]
491+ fn test_ollama_host_env_marks_inventory_configured ( ) {
492+ let _guard = env_lock:: lock_env ( [ ( "OLLAMA_HOST" , Some ( "http://127.0.0.1:11435" ) ) ] ) ;
493+ let config_file = tempfile:: NamedTempFile :: new ( ) . unwrap ( ) ;
494+ let secrets_file = tempfile:: NamedTempFile :: new ( ) . unwrap ( ) ;
495+ let config = crate :: config:: Config :: new_with_config_paths (
496+ vec ! [ config_file. path( ) . to_path_buf( ) ] ,
497+ secrets_file. path ( ) ,
498+ )
499+ . unwrap ( ) ;
500+
501+ assert ! ( ollama_host_configured( & config) ) ;
502+ }
503+
504+ #[ test]
505+ fn test_ollama_host_config_marks_inventory_configured ( ) {
506+ let _guard = env_lock:: lock_env ( [ ( "OLLAMA_HOST" , None :: < & str > ) ] ) ;
507+ let config_file = tempfile:: NamedTempFile :: new ( ) . unwrap ( ) ;
508+ let secrets_file = tempfile:: NamedTempFile :: new ( ) . unwrap ( ) ;
509+ let config = crate :: config:: Config :: new_with_config_paths (
510+ vec ! [ config_file. path( ) . to_path_buf( ) ] ,
511+ secrets_file. path ( ) ,
512+ )
513+ . unwrap ( ) ;
514+ config
515+ . set_param ( "OLLAMA_HOST" , "http://127.0.0.1:11435" )
516+ . unwrap ( ) ;
517+
518+ assert ! ( ollama_host_configured( & config) ) ;
519+ }
520+
468521 #[ test]
469522 fn test_apply_ollama_options_uses_input_limit ( ) {
470523 let _guard = env_lock:: lock_env ( [ ( "GOOSE_INPUT_LIMIT" , Some ( "8192" ) ) ] ) ;
0 commit comments