fix: detect token-limit errors in todo-continuation to prevent infinite loop (#2462)

handler.ts now catches ContextLengthError/prompt-too-long errors and
stops continuation instead of retrying with an even larger context.

91 tests pass, tsc clean.

Closes #2462
This commit is contained in:
YeonGyu-Kim
2026-04-07 15:24:20 +09:00
parent be562905d6
commit a9c73986d7
7 changed files with 232 additions and 1 deletions
@@ -55,6 +55,11 @@ export async function handleSessionIdle(args: {
return
}
if (state.tokenLimitDetected) {
log(`[${HOOK_NAME}] Skipped: token limit error detected, retry would worsen context overflow`, { sessionID })
return
}
if (state.abortDetectedAt) {
const timeSinceAbort = Date.now() - state.abortDetectedAt
if (timeSinceAbort < ABORT_WINDOW_MS) {