@@ -791,6 +791,69 @@ describe("buildStatusReply subagent summary", () => {
791791 ) ;
792792 } ) ;
793793
794+ it ( "uses the Codex app-server account before OpenAI env labels on Codex harness status" , async ( ) => {
795+ registerStatusCodexHarness ( ) ;
796+
797+ await withTempHome (
798+ async ( dir ) => {
799+ const agentDir = path . join ( dir , ".openclaw" , "agents" , "main" , "agent" ) ;
800+ const codexHome = path . join ( agentDir , "codex-home" ) ;
801+ fs . mkdirSync ( codexHome , { recursive : true } ) ;
802+ fs . writeFileSync (
803+ path . join ( codexHome , "auth.json" ) ,
804+ JSON . stringify ( {
805+ auth_mode : "chatgpt" ,
806+ tokens : {
807+ access_token : "codex-access-token" ,
808+ refresh_token : "codex-refresh-token" ,
809+ } ,
810+ } ) ,
811+ "utf-8" ,
812+ ) ;
813+
814+ const text = await buildStatusText ( {
815+ cfg : {
816+ ...baseCfg ,
817+ agents : {
818+ defaults : {
819+ agentRuntime : { id : "codex" } ,
820+ } ,
821+ } ,
822+ } ,
823+ sessionEntry : {
824+ sessionId : "sess-status-codex-home-oauth" ,
825+ updatedAt : 0 ,
826+ } ,
827+ sessionKey : "agent:main:main" ,
828+ parentSessionKey : "agent:main:main" ,
829+ sessionScope : "per-sender" ,
830+ statusChannel : "mobilechat" ,
831+ provider : "openai" ,
832+ model : "gpt-5.5" ,
833+ contextTokens : 32_000 ,
834+ resolvedFastMode : false ,
835+ resolvedVerboseLevel : "off" ,
836+ resolvedReasoningLevel : "off" ,
837+ resolveDefaultThinkingLevel : async ( ) => undefined ,
838+ isGroup : false ,
839+ defaultGroupActivation : ( ) => "mention" ,
840+ } ) ;
841+
842+ const normalized = normalizeTestText ( text ) ;
843+ expect ( normalized ) . toContain ( "Model: openai/gpt-5.5" ) ;
844+ expect ( normalized ) . toContain ( "Runtime: OpenAI Codex" ) ;
845+ expect ( normalized ) . toContain ( "oauth (codex-cli)" ) ;
846+ expect ( normalized ) . not . toContain ( "api-key (env: OPENAI_API_KEY)" ) ;
847+ } ,
848+ {
849+ env : {
850+ OPENAI_API_KEY : "status-env-key-placeholder" ,
851+ OPENAI_OAUTH_TOKEN : undefined ,
852+ } ,
853+ } ,
854+ ) ;
855+ } ) ;
856+
794857 it ( "uses Codex usage for bare codex models running on the Codex harness" , async ( ) => {
795858 registerStatusCodexHarness ( ) ;
796859
0 commit comments