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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user