@@ -481,6 +481,93 @@ def test_model_spec_str(self):
481481 assert str (spec ) == "anthropic:claude-sonnet-4-20250514"
482482
483483
484+ class TestModelPropagation :
485+ """Tests that model configuration is correctly passed through the system."""
486+
487+ def test_runner_config_model_name (self ):
488+ """Test that BenchmarkRunner correctly sets model_name in backend_kwargs."""
489+ from benchmarks .runner import BenchmarkRunner
490+
491+ runner = BenchmarkRunner (
492+ backend = "openai" ,
493+ model = "my-test-model" ,
494+ progress = "none" ,
495+ )
496+
497+ # Verify the config has the correct model_name in backend_kwargs
498+ assert runner .config .backend == "openai"
499+ assert runner .config .model == "my-test-model"
500+ assert runner .config .backend_kwargs .get ("model_name" ) == "my-test-model"
501+
502+ def test_runner_config_preserves_extra_kwargs (self ):
503+ """Test that extra backend_kwargs are preserved."""
504+ from benchmarks .runner import BenchmarkRunner
505+
506+ runner = BenchmarkRunner (
507+ backend = "openai" ,
508+ model = "my-model" ,
509+ progress = "none" ,
510+ backend_kwargs = {"extra_param" : "extra_value" , "api_key" : "test-key" },
511+ )
512+
513+ # model_name from model param should be present
514+ assert runner .config .backend_kwargs .get ("model_name" ) == "my-model"
515+ # Extra kwargs should be preserved
516+ assert runner .config .backend_kwargs .get ("extra_param" ) == "extra_value"
517+ assert runner .config .backend_kwargs .get ("api_key" ) == "test-key"
518+
519+ def test_model_spec_to_runner (self ):
520+ """Test end-to-end from model spec parsing to runner config."""
521+ from benchmarks .cli import parse_model_spec
522+ from benchmarks .runner import BenchmarkRunner
523+
524+ spec = parse_model_spec ("anthropic:claude-3-opus" )
525+ runner = BenchmarkRunner (
526+ backend = spec .backend ,
527+ model = spec .model ,
528+ progress = "none" ,
529+ )
530+
531+ assert runner .config .backend == "anthropic"
532+ assert runner .config .model == "claude-3-opus"
533+ assert runner .config .backend_kwargs .get ("model_name" ) == "claude-3-opus"
534+
535+ def test_rlm_receives_correct_config (self ):
536+ """Test that RLM is initialized with correct backend_kwargs."""
537+ from unittest .mock import MagicMock , patch
538+
539+ from benchmarks .runner import BenchmarkRunner
540+ from benchmarks .tasks .niah import NIAHBenchmark
541+
542+ runner = BenchmarkRunner (
543+ backend = "openai" ,
544+ model = "gpt-4o-test" ,
545+ progress = "none" ,
546+ )
547+
548+ # Mock RLM to capture the initialization arguments
549+ captured_kwargs = {}
550+
551+ class MockRLM :
552+ def __init__ (self , ** kwargs ):
553+ captured_kwargs .update (kwargs )
554+ # Raise to exit early without actually running RLM
555+ raise RuntimeError ("Mock exit - RLM init captured" )
556+
557+ # RLM is imported inside _inference_rlm, so patch at rlm module level
558+ with patch ("rlm.RLM" , MockRLM ):
559+ benchmark = NIAHBenchmark (context_length = 1000 )
560+ try :
561+ runner .run (benchmark , method = "rlm" , num_samples = 1 , seed = 42 )
562+ except RuntimeError as e :
563+ if "Mock exit" not in str (e ):
564+ raise
565+
566+ # Verify the backend_kwargs passed to RLM
567+ assert captured_kwargs .get ("backend" ) == "openai"
568+ assert captured_kwargs .get ("backend_kwargs" ) == {"model_name" : "gpt-4o-test" }
569+
570+
484571class TestBenchmarkIntegration :
485572 """Integration tests for benchmark framework."""
486573
0 commit comments