@@ -2630,6 +2630,41 @@ func TestGatewayRuntimePortBridgeListModelsUsesSessionProvider(t *testing.T) {
26302630 }
26312631}
26322632
2633+ func TestGatewayRuntimePortBridgeListModelsSessionNotFoundFallsBackToGlobal (t * testing.T ) {
2634+ store := & bridgeSessionStoreWithLoader {
2635+ bridgeSessionStoreStub : bridgeSessionStoreStub {},
2636+ loadErr : agentsession .ErrSessionNotFound ,
2637+ }
2638+ cfgMgr := & configManagerStub {
2639+ cfg : config.Config {
2640+ SelectedProvider : "gemini" ,
2641+ CurrentModel : "gemini-2.5-pro" ,
2642+ },
2643+ }
2644+ ps := & providerSelectionStub {
2645+ listOptions : []configstate.ProviderOption {
2646+ {ID : "openai" , Models : []providertypes.ModelDescriptor {{ID : "gpt-4.1" , Name : "GPT-4.1" }}},
2647+ {ID : "gemini" , Models : []providertypes.ModelDescriptor {{ID : "gemini-2.5-pro" , Name : "Gemini 2.5 Pro" }}},
2648+ },
2649+ }
2650+ bridge , _ := newGatewayRuntimePortBridge (context .Background (), & runtimeStub {eventsCh : make (chan agentruntime.RuntimeEvent , 1 )}, store , cfgMgr , ps )
2651+ defer bridge .Close ()
2652+
2653+ models , err := bridge .ListModels (context .Background (), gateway.ListModelsInput {
2654+ SubjectID : testBridgeSubjectID ,
2655+ SessionID : "session-startup-probe-1" ,
2656+ })
2657+ if err != nil {
2658+ t .Fatalf ("ListModels() error = %v" , err )
2659+ }
2660+ if len (models ) != 1 {
2661+ t .Fatalf ("models len = %d, want 1" , len (models ))
2662+ }
2663+ if models [0 ].Provider != "gemini" || models [0 ].ID != "gemini-2.5-pro" {
2664+ t .Fatalf ("models = %+v, want gemini/gemini-2.5-pro only" , models )
2665+ }
2666+ }
2667+
26332668func TestGatewayRuntimePortBridgeGetSessionModelFallsBackToEffectiveSelection (t * testing.T ) {
26342669 store := & bridgeSessionStoreWithLoader {
26352670 bridgeSessionStoreStub : bridgeSessionStoreStub {},
0 commit comments