@@ -11,7 +11,11 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
1111import type { CodexServerNotification } from "./protocol.js" ;
1212import { runCodexAppServerAttempt , __testing } from "./run-attempt.js" ;
1313import { writeCodexAppServerBinding } from "./session-binding.js" ;
14- import { buildThreadResumeParams , buildTurnStartParams } from "./thread-lifecycle.js" ;
14+ import {
15+ buildThreadResumeParams ,
16+ buildTurnStartParams ,
17+ startOrResumeThread ,
18+ } from "./thread-lifecycle.js" ;
1519
1620let tempDir : string ;
1721
@@ -512,4 +516,46 @@ describe("runCodexAppServerAttempt", () => {
512516 } ) ,
513517 ) ;
514518 } ) ;
519+
520+ it ( "preserves the bound auth profile when resume params omit authProfileId" , async ( ) => {
521+ const sessionFile = path . join ( tempDir , "session.jsonl" ) ;
522+ const workspaceDir = path . join ( tempDir , "workspace" ) ;
523+ await writeCodexAppServerBinding ( sessionFile , {
524+ threadId : "thread-existing" ,
525+ cwd : workspaceDir ,
526+ authProfileId : "openai-codex:bound" ,
527+ model : "gpt-5.4-codex" ,
528+ modelProvider : "openai" ,
529+ } ) ;
530+ const params = createParams ( sessionFile , workspaceDir ) ;
531+ delete params . authProfileId ;
532+
533+ const binding = await startOrResumeThread ( {
534+ client : {
535+ request : async ( method ) => {
536+ if ( method === "thread/resume" ) {
537+ return { thread : { id : "thread-existing" } , modelProvider : "openai" } ;
538+ }
539+ throw new Error ( `unexpected method: ${ method } ` ) ;
540+ } ,
541+ } as never ,
542+ params,
543+ cwd : workspaceDir ,
544+ dynamicTools : [ ] ,
545+ appServer : {
546+ start : {
547+ transport : "stdio" ,
548+ command : "codex" ,
549+ args : [ "app-server" ] ,
550+ headers : { } ,
551+ } ,
552+ requestTimeoutMs : 60_000 ,
553+ approvalPolicy : "never" ,
554+ approvalsReviewer : "user" ,
555+ sandbox : "workspace-write" ,
556+ } ,
557+ } ) ;
558+
559+ expect ( binding . authProfileId ) . toBe ( "openai-codex:bound" ) ;
560+ } ) ;
515561} ) ;
0 commit comments