@@ -73,10 +73,14 @@ const authorize = Effect.fn(function* () {
7373 return new URL ( attempt . url )
7474} )
7575
76- const request = Effect . fn ( function * ( providerID : Provider . ID , baseURL : string ) {
76+ const request = Effect . fn ( function * (
77+ providerID : Provider . ID ,
78+ baseURL : string ,
79+ sessionID = Session . ID . make ( "ses_test" ) ,
80+ ) {
7781 const hooks = yield * PluginHooks . Service
7882 const event = yield * hooks . trigger ( "session" , "model.request" , {
79- sessionID : Session . ID . make ( "ses_test" ) ,
83+ sessionID,
8084 agent : Agent . ID . make ( "build" ) ,
8185 model : Model . Ref . make ( { providerID, id : Model . ID . make ( "gpt-5.5" ) } ) ,
8286 kind : "primary" ,
@@ -767,8 +771,21 @@ describe("ChatGPTPlugin", () => {
767771 expect ( provider . settings ?. baseURL ) . toBe ( "https://api.openai.com/v1" )
768772 expect ( provider . headers ) . not . toHaveProperty ( "x-openai-chatpass-test" )
769773 expect ( direct . baseURL ) . toBe ( "https://api.openai.com/v1" )
770- expect ( direct . headers ) . toEqual ( { } )
774+ expect ( direct . headers ) . toEqual ( {
775+ "session-id" : "ses_test" ,
776+ "thread-id" : "ses_test" ,
777+ "x-client-request-id" : "ses_test" ,
778+ } )
771779 expect ( direct . hasHttpHooks ) . toBe ( false )
780+ const sessions = yield * Session . Service
781+ const location = yield * Location . Service
782+ const parent = yield * sessions . create ( { location : { directory : location . directory } } )
783+ const child = yield * sessions . create ( { parentID : parent . id } )
784+ expect ( ( yield * request ( Provider . ID . openai , "https://api.openai.com/v1" , child . id ) ) . headers ) . toEqual ( {
785+ "session-id" : parent . id ,
786+ "thread-id" : child . id ,
787+ "x-client-request-id" : child . id ,
788+ } )
772789 const eligible = required ( yield * models . get ( Provider . ID . openai , Model . ID . make ( "gpt-5.5" ) ) )
773790 expect ( eligible . package ) . toBe ( "@opencode/ai/providers/openai" )
774791 expect ( eligible . headers ) . not . toHaveProperty ( "x-openai-chatpass-test" )
@@ -845,6 +862,7 @@ describe("ChatGPTPlugin", () => {
845862 expect ( provider . settings ?. transport ) . toBe ( "websocket" )
846863 expect ( model . settings ?. transport ) . toBeUndefined ( )
847864 expect ( direct . baseURL ) . toBe ( "https://api.openai.com/v1" )
865+ expect ( direct . headers ) . toEqual ( { } )
848866 expect ( direct . hasHttpHooks ) . toBe ( false )
849867 expect ( provider . headers ) . not . toHaveProperty ( "x-openai-chatpass-test" )
850868 expect ( required ( yield * models . get ( Provider . ID . openai , Model . ID . make ( "gpt-4.1" ) ) ) . enabled ) . toBe ( true )
0 commit comments