fix(todo-continuation-enforcer): add stagnation guard helper
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
33
src/hooks/todo-continuation-enforcer/stagnation-detection.ts
Normal file
33
src/hooks/todo-continuation-enforcer/stagnation-detection.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { log } from "../../shared/logger"
|
||||
|
||||
import { HOOK_NAME, MAX_STAGNATION_COUNT } from "./constants"
|
||||
import type { ContinuationProgressUpdate } from "./session-state"
|
||||
|
||||
export function shouldStopForStagnation(args: {
|
||||
sessionID: string
|
||||
incompleteCount: number
|
||||
progressUpdate: ContinuationProgressUpdate
|
||||
}): boolean {
|
||||
const { sessionID, incompleteCount, progressUpdate } = args
|
||||
|
||||
if (progressUpdate.hasProgressed) {
|
||||
log(`[${HOOK_NAME}] Progress detected: reset stagnation count`, {
|
||||
sessionID,
|
||||
previousIncompleteCount: progressUpdate.previousIncompleteCount,
|
||||
incompleteCount,
|
||||
})
|
||||
}
|
||||
|
||||
if (progressUpdate.stagnationCount < MAX_STAGNATION_COUNT) {
|
||||
return false
|
||||
}
|
||||
|
||||
log(`[${HOOK_NAME}] Skipped: todo continuation stagnated`, {
|
||||
sessionID,
|
||||
incompleteCount,
|
||||
previousIncompleteCount: progressUpdate.previousIncompleteCount,
|
||||
stagnationCount: progressUpdate.stagnationCount,
|
||||
maxStagnationCount: MAX_STAGNATION_COUNT,
|
||||
})
|
||||
return true
|
||||
}
|
||||
Reference in New Issue
Block a user