Skip to content

Commit 12cd338

Browse files
committed
fix(anthropic-auto-compact): improve session recovery with Continue prompt
- Replace recursive retry mechanism with explicit session.prompt_async('Continue') - Clear all compaction state after successful revert to prevent state corruption - Prevents infinite retry loops and improves session reliability 🤖 Generated with assistance of oh-my-opencode
1 parent b9e373a commit 12cd338

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/hooks/anthropic-auto-compact/executor.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -492,14 +492,19 @@ export async function executeCompact(
492492
fallbackState.revertAttempt++
493493
fallbackState.lastRevertedMessageID = pair.userMessageID
494494

495-
retryState.attempt = 0
496-
truncateState.truncateAttempt = 0
495+
// Clear all state after successful revert - don't recurse
496+
clearSessionState(autoCompactState, sessionID)
497497

498-
autoCompactState.compactionInProgress.delete(sessionID)
499-
500-
setTimeout(() => {
501-
executeCompact(sessionID, msg, autoCompactState, client, directory, experimental)
502-
}, 1000)
498+
// Send "Continue" prompt to resume session
499+
setTimeout(async () => {
500+
try {
501+
await (client as Client).session.prompt_async({
502+
path: { sessionID },
503+
body: { parts: [{ type: "text", text: "Continue" }] },
504+
query: { directory },
505+
})
506+
} catch {}
507+
}, 500)
503508
return
504509
} catch {}
505510
} else {

0 commit comments

Comments
 (0)