fix(council): fix nudge retry cap bypass and add memory cleanup

This commit is contained in:
ismeth
2026-03-02 00:52:19 +01:00
committed by YeonGyu-Kim
parent e15ce7b279
commit 9e196a21d7
2 changed files with 47 additions and 1 deletions
@@ -358,6 +358,28 @@ describe("sendCouncilContinuationNudge", () => {
resetCouncilNudgeCount(task.id)
})
})
describe("#given promptAsync persistently fails", () => {
it("#when called MAX_NUDGE_ATTEMPTS times #then counter still reaches max and next call returns false", () => {
//#given
const client = {
session: { promptAsync: mock(() => Promise.reject(new Error("persistent network error"))) },
}
const task = createRunningTask({ id: "task-nudge-persistent-fail" })
resetCouncilNudgeCount(task.id)
//#when - exhaust all 5 attempts despite every promptAsync failing
for (let i = 0; i < 5; i++) {
const result = sendCouncilContinuationNudge(client as never, task, task.sessionID!)
expect(result).toBe(true)
}
const resultAfterMax = sendCouncilContinuationNudge(client as never, task, task.sessionID!)
//#then - counter was not rolled back, so max was reached
expect(resultAfterMax).toBe(false)
expect(client.session.promptAsync).toHaveBeenCalledTimes(5)
})
})
})
describe("resetCouncilNudgeCount", () => {
@@ -392,4 +414,29 @@ describe("resetCouncilNudgeCount", () => {
resetCouncilNudgeCount(task.id)
})
})
describe("#given nudge count exists for a task", () => {
it("#when resetCouncilNudgeCount is called #then memory is cleaned up and nudging restarts from zero", () => {
//#given
const client = createMockClient()
const task = createRunningTask({ id: "task-cleanup-test" })
sendCouncilContinuationNudge(client as never, task, task.sessionID!)
sendCouncilContinuationNudge(client as never, task, task.sessionID!)
sendCouncilContinuationNudge(client as never, task, task.sessionID!)
//#when
resetCouncilNudgeCount(task.id)
//#then - counter is cleared, all 5 nudge attempts available again
const freshClient = createMockClient()
for (let i = 0; i < 5; i++) {
expect(sendCouncilContinuationNudge(freshClient as never, task, task.sessionID!)).toBe(true)
}
expect(sendCouncilContinuationNudge(freshClient as never, task, task.sessionID!)).toBe(false)
expect(freshClient.session.promptAsync).toHaveBeenCalledTimes(5)
// cleanup
resetCouncilNudgeCount(task.id)
})
})
})
@@ -74,7 +74,6 @@ export function sendCouncilContinuationNudge(
parts: [createInternalAgentTextPart(CONTINUATION_PROMPT)],
},
}).catch((error) => {
nudgeCountByTask.set(task.id, count)
log("[council-continuation] Nudge prompt error:", {
taskId: task.id,
error: String(error),