@@ -906,8 +906,6 @@ async function findAdoptedSessionEntry(params: {
906906 return ( await listAdoptedSessionEntries ( params ) ) . get ( params . threadId ) ;
907907}
908908
909- class CodexAdoptionBindingCleanupError extends AggregateError { }
910-
911909async function clearCreatedAdoptionBinding ( params : {
912910 bindingStore : CodexAppServerBindingStore ;
913911 identity : ReturnType < typeof sessionBindingIdentity > ;
@@ -934,19 +932,22 @@ async function clearCreatedAdoptionBinding(params: {
934932 try {
935933 current = await params . bindingStore . read ( params . identity ) ;
936934 } catch ( readError ) {
937- throw new CodexAdoptionBindingCleanupError (
935+ const cleanupFailure = new AggregateError (
938936 [ params . cause , ...( clearError ? [ clearError ] : [ ] ) , readError ] ,
939937 `OpenClaw session creation failed and the Codex binding could not be verified for ${ params . sourceThreadId } ` ,
938+ { cause : readError } ,
940939 ) ;
940+ throw cleanupFailure ;
941941 }
942942 // Pending state is the cleanup CAS token. Once lifecycle work changes it,
943943 // that successor owns every tracked native artifact and must survive here.
944944 if ( ! matchesPendingSupervisionOwner ( current , params . expectedPending ) ) {
945945 return ;
946946 }
947- throw new CodexAdoptionBindingCleanupError (
947+ throw new AggregateError (
948948 [ params . cause , ...( clearError ? [ clearError ] : [ ] ) ] ,
949949 `OpenClaw session creation failed and the Codex binding could not be cleared for ${ params . sourceThreadId } ` ,
950+ { cause : params . cause } ,
950951 ) ;
951952}
952953
0 commit comments