MCPcopy Create free account
hub / github.com/tiann/hapi / beginCompactRecovery

Method beginCompactRecovery

cli/src/codex/codexRemoteLauncher.ts:1858–1887  ·  view source on GitHub ↗
(threadId: string, messageToRetry: QueuedMessage, error: string | null)

Source from the content-addressed store, hash-verified

1856 };
1857
1858 const beginCompactRecovery = (threadId: string, messageToRetry: QueuedMessage, error: string | null) => {
1859 sameThreadCompactAttempt += 1;
1860 recoveryInFlight = true;
1861 const recovery = {
1862 threadId,
1863 message: messageToRetry,
1864 timeout: null as ReturnType<typeof setTimeout> | null
1865 };
1866 compactRecovery = recovery;
1867 recovery.timeout = setTimeout(() => {
1868 failCompactRecovery(
1869 recovery,
1870 'Task failed: context window overflow and same-conversation compact timed out'
1871 );
1872 }, SAME_THREAD_COMPACT_TIMEOUT_MS);
1873 recovery.timeout.unref?.();
1874
1875 logger.debug(
1876 `[Codex] Compacting retryable context failure on same thread ` +
1877 `(attempt ${sameThreadCompactAttempt}/${SAME_THREAD_MAX_COMPACT_RETRIES}): ${error ?? 'unknown error'}`
1878 );
1879 void appServerClient.compactThread({ threadId }, { signal: this.abortController.signal })
1880 .catch((compactError) => {
1881 logger.warn('[Codex] Failed to start app-server thread compact before retry:', compactError);
1882 failCompactRecovery(
1883 recovery,
1884 'Task failed: context window overflow and same-conversation compact failed'
1885 );
1886 });
1887 };
1888
1889 const forwardedGoalSignaturesByThreadId = new Map<string, string>();
1890 const forwardedGoalClearsByThreadId = new Set<string>();

Callers

nothing calls this directly

Calls 3

debugMethod · 0.80
warnMethod · 0.80
compactThreadMethod · 0.45

Tested by

no test coverage detected