@@ -129,8 +129,16 @@ class FakeNativeBackend implements NativeSessionBackend {
129129
130130 return {
131131 models : {
132- currentModelId : "gpt-5.2" ,
133- availableModels : [ { modelId : "gpt-5.2" , name : "GPT-5.2" , description : "GPT-5.2" } ] ,
132+ currentModelId : "gpt-5.4-medium" ,
133+ availableModels : [
134+ { modelId : "gpt-5.4-medium" , name : "GPT-5.4" , description : "GPT-5.4" } ,
135+ {
136+ modelId : "gpt-5.4-medium-fast" ,
137+ name : "GPT-5.4 Fast" ,
138+ description : "GPT-5.4 Fast" ,
139+ } ,
140+ { modelId : "gpt-5.2" , name : "GPT-5.2" , description : "GPT-5.2" } ,
141+ ] ,
134142 } ,
135143 modes : {
136144 currentModeId : "agent" ,
@@ -215,7 +223,10 @@ function createAgentTestHarness() {
215223 async listModels ( ) {
216224 return [
217225 { modelId : "auto" , name : "Auto" , current : true } ,
226+ { modelId : "gpt-5.4-medium" , name : "GPT-5.4" } ,
227+ { modelId : "gpt-5.4-medium-fast" , name : "GPT-5.4 Fast" } ,
218228 { modelId : "gpt-5.2" , name : "GPT-5.2" } ,
229+ { modelId : "claude-4.5-opus-high" , name : "Opus 4.5" } ,
219230 ] ;
220231 } ,
221232 } as any ,
@@ -432,6 +443,29 @@ describe("CursorAcpAgent", () => {
432443 expect ( backends ) . toHaveLength ( 0 ) ;
433444 } ) ;
434445
446+ it ( "exposes listed models in newSession model listing" , async ( ) => {
447+ const { agent } = createAgentTestHarness ( ) ;
448+
449+ await agent . initialize ( {
450+ protocolVersion : 1 ,
451+ clientCapabilities : { } ,
452+ } as any ) ;
453+
454+ const session = await agent . newSession ( {
455+ cwd : "/tmp" ,
456+ mcpServers : [ ] ,
457+ } as any ) ;
458+
459+ expect ( session . models ?. currentModelId ) . toBe ( "auto" ) ;
460+ expect ( session . models ?. availableModels . map ( ( model ) => model . modelId ) ) . toEqual ( [
461+ "auto" ,
462+ "gpt-5.4-medium" ,
463+ "gpt-5.4-medium-fast" ,
464+ "gpt-5.2" ,
465+ "claude-4.5-opus-high" ,
466+ ] ) ;
467+ } ) ;
468+
435469 it ( "uses default mode by default" , async ( ) => {
436470 const { agent } = createAgentTestHarness ( ) ;
437471
@@ -500,7 +534,7 @@ describe("CursorAcpAgent", () => {
500534
501535 const response = await agent . prompt ( {
502536 sessionId : session . sessionId ,
503- prompt : [ { type : "text" , text : "/model gpt-5.2 " } ] ,
537+ prompt : [ { type : "text" , text : "/model gpt-5.4-medium " } ] ,
504538 } as any ) ;
505539
506540 expect ( response . stopReason ) . toBe ( "end_turn" ) ;
@@ -510,6 +544,33 @@ describe("CursorAcpAgent", () => {
510544 recordSpy . mockRestore ( ) ;
511545 } ) ;
512546
547+ it ( "accepts /model fast variants before first prompt without backend restart" , async ( ) => {
548+ const { agent, backends } = createAgentTestHarness ( ) ;
549+
550+ await agent . initialize ( {
551+ protocolVersion : 1 ,
552+ clientCapabilities : { } ,
553+ } as any ) ;
554+ const session = await agent . newSession ( {
555+ cwd : "/tmp" ,
556+ mcpServers : [ ] ,
557+ } as any ) ;
558+
559+ const restartSpy = vi . spyOn ( agent as any , "restartBackend" ) ;
560+
561+ const response = await agent . prompt ( {
562+ sessionId : session . sessionId ,
563+ prompt : [ { type : "text" , text : "/model gpt-5.4-medium-fast" } ] ,
564+ } as any ) ;
565+
566+ expect ( response . stopReason ) . toBe ( "end_turn" ) ;
567+ expect ( backends ) . toHaveLength ( 0 ) ;
568+ expect ( restartSpy ) . not . toHaveBeenCalled ( ) ;
569+ expect ( ( agent as any ) . sessions [ session . sessionId ] ?. modelId ) . toBe ( "gpt-5.4-medium-fast" ) ;
570+
571+ restartSpy . mockRestore ( ) ;
572+ } ) ;
573+
513574 it ( "forwards permission requests in default mode" , async ( ) => {
514575 const { agent, backends, client } = createAgentTestHarness ( ) ;
515576
@@ -644,12 +705,35 @@ describe("CursorAcpAgent", () => {
644705
645706 await agent . unstable_setSessionModel ( {
646707 sessionId : session . sessionId ,
647- modelId : "gpt-5.2" ,
708+ modelId : "gpt-5.4-medium" ,
709+ } as any ) ;
710+
711+ expect ( backends ) . toHaveLength ( 2 ) ;
712+ expect ( backends [ 0 ] ! . closeCalls ) . toBe ( 1 ) ;
713+ expect ( backends [ 1 ] ! . options . modelId ) . toBe ( "gpt-5.4-medium" ) ;
714+ } ) ;
715+
716+ it ( "passes fast model ids through to native backend restart" , async ( ) => {
717+ const { agent, backends } = createAgentTestHarness ( ) ;
718+
719+ await agent . initialize ( {
720+ protocolVersion : 1 ,
721+ clientCapabilities : { } ,
722+ } as any ) ;
723+ const session = await agent . newSession ( {
724+ cwd : "/tmp" ,
725+ mcpServers : [ ] ,
726+ } as any ) ;
727+ await startNativeBackend ( agent , session . sessionId ) ;
728+
729+ await agent . unstable_setSessionModel ( {
730+ sessionId : session . sessionId ,
731+ modelId : "gpt-5.4-medium-fast" ,
648732 } as any ) ;
649733
650734 expect ( backends ) . toHaveLength ( 2 ) ;
651735 expect ( backends [ 0 ] ! . closeCalls ) . toBe ( 1 ) ;
652- expect ( backends [ 1 ] ! . options . modelId ) . toBe ( "gpt-5.2 " ) ;
736+ expect ( backends [ 1 ] ! . options . modelId ) . toBe ( "gpt-5.4-medium-fast " ) ;
653737 } ) ;
654738
655739 it ( "rejects a second prompt while one is in progress" , async ( ) => {
@@ -720,7 +804,7 @@ describe("CursorAcpAgent", () => {
720804 await expect (
721805 agent . unstable_setSessionModel ( {
722806 sessionId : session . sessionId ,
723- modelId : "gpt-5.2 " ,
807+ modelId : "gpt-5.4-medium " ,
724808 } as any ) ,
725809 ) . rejects . toThrow ( "Invalid params" ) ;
726810
@@ -823,7 +907,14 @@ describe("CursorAcpAgent", () => {
823907
824908 expect ( backends ) . toHaveLength ( 1 ) ;
825909 expect ( backends [ 0 ] ! . loadCalls ) . toEqual ( [ "be-native-1" ] ) ;
826- expect ( response . models ?. currentModelId ) . toBe ( "gpt-5.2" ) ;
910+ expect ( response . models ?. currentModelId ) . toBe ( "gpt-5.4-medium" ) ;
911+ expect ( response . models ?. availableModels . map ( ( model ) => model . modelId ) ) . toEqual ( [
912+ "gpt-5.4-medium" ,
913+ "gpt-5.4-medium-fast" ,
914+ "gpt-5.2" ,
915+ "auto" ,
916+ "claude-4.5-opus-high" ,
917+ ] ) ;
827918 expect (
828919 client . updates . filter ( ( u ) => u . update ?. sessionUpdate === "user_message_chunk" ) ,
829920 ) . toHaveLength ( 1 ) ;
0 commit comments