File tree Expand file tree Collapse file tree 3 files changed +24
-6
lines changed
Expand file tree Collapse file tree 3 files changed +24
-6
lines changed Original file line number Diff line number Diff line change @@ -447,12 +447,13 @@ public async Task Should_Set_Model_On_Existing_Session()
447447 {
448448 var session = await CreateSessionAsync ( ) ;
449449
450- // SetModel should not throw
450+ // Subscribe for the model change event before calling SetModelAsync
451+ var modelChangedTask = TestHelper . GetNextEventOfTypeAsync < SessionModelChangeEvent > ( session ) ;
452+
451453 await session . SetModelAsync ( "gpt-4.1" ) ;
452454
453- // Session should still be usable after model change
454- await session . SendAsync ( new MessageOptions { Prompt = "What is 1+1?" } ) ;
455- var assistantMessage = await TestHelper . GetFinalAssistantMessageAsync ( session ) ;
456- Assert . NotNull ( assistantMessage ) ;
455+ // Verify a model_change event was emitted with the new model
456+ var modelChanged = await modelChangedTask ;
457+ Assert . Equal ( "gpt-4.1" , modelChanged . Data . NewModel ) ;
457458 }
458459}
Original file line number Diff line number Diff line change @@ -189,6 +189,23 @@ func TestSessionRpc(t *testing.T) {
189189 }
190190 })
191191
192+ // session.model.switchTo is defined in schema but not yet implemented in CLI
193+ t .Run ("should call session.SetModel" , func (t * testing.T ) {
194+ t .Skip ("session.model.switchTo not yet implemented in CLI" )
195+
196+ session , err := client .CreateSession (t .Context (), & copilot.SessionConfig {
197+ OnPermissionRequest : copilot .PermissionHandler .ApproveAll ,
198+ Model : "claude-sonnet-4.5" ,
199+ })
200+ if err != nil {
201+ t .Fatalf ("Failed to create session: %v" , err )
202+ }
203+
204+ if err := session .SetModel (t .Context (), "gpt-4.1" ); err != nil {
205+ t .Fatalf ("SetModel returned error: %v" , err )
206+ }
207+ })
208+
192209 t .Run ("should get and set session mode" , func (t * testing.T ) {
193210 session , err := client .CreateSession (t .Context (), & copilot.SessionConfig {OnPermissionRequest : copilot .PermissionHandler .ApproveAll })
194211 if err != nil {
Original file line number Diff line number Diff line change @@ -89,7 +89,7 @@ describe("CopilotClient", () => {
8989
9090 // Mock sendRequest to capture the call without hitting the runtime
9191 const spy = vi . spyOn ( ( client as any ) . connection ! , "sendRequest" )
92- . mockImplementation ( async ( method : string , params : any ) => {
92+ . mockImplementation ( async ( method : string , _params : any ) => {
9393 if ( method === "session.model.switchTo" ) return { } ;
9494 // Fall through for other methods (shouldn't be called)
9595 throw new Error ( `Unexpected method: ${ method } ` ) ;
You can’t perform that action at this time.
0 commit comments