fix(hooks): settle idle prompt continuations
This commit is contained in:
@@ -63,6 +63,41 @@ describe("unstable-agent-babysitter hook", () => {
|
||||
_resetForTesting()
|
||||
})
|
||||
|
||||
test("settles idle before injecting a reminder", async () => {
|
||||
// #given
|
||||
setMainSession("main-1")
|
||||
const promptCalls: Array<{ input: unknown }> = []
|
||||
const ctx = createMockPluginInput({
|
||||
messagesBySession: {
|
||||
"main-1": [
|
||||
{ info: { agent: "sisyphus", model: { providerID: "openai", modelID: "gpt-4" } } },
|
||||
],
|
||||
"bg-1": [
|
||||
{ info: { role: "assistant" }, parts: [{ type: "thinking", thinking: "deep thought" }] },
|
||||
],
|
||||
},
|
||||
promptCalls,
|
||||
})
|
||||
const backgroundManager = createBackgroundManager([createTask()])
|
||||
const hook = createUnstableAgentBabysitterHook(ctx, {
|
||||
backgroundManager,
|
||||
config: { timeout_ms: 120000 },
|
||||
idleSettleMs: 50,
|
||||
})
|
||||
|
||||
// #when
|
||||
const startedAt = Date.now()
|
||||
const eventPromise = hook.event({ event: { type: "session.idle", properties: { sessionID: "main-1" } } })
|
||||
await Promise.resolve()
|
||||
|
||||
// #then
|
||||
expect(promptCalls.length).toBe(0)
|
||||
|
||||
await eventPromise
|
||||
expect(Date.now() - startedAt).toBeGreaterThanOrEqual(45)
|
||||
expect(promptCalls.length).toBe(1)
|
||||
})
|
||||
|
||||
test("fires reminder for hung gemini task", async () => {
|
||||
// #given
|
||||
setMainSession("main-1")
|
||||
|
||||
Reference in New Issue
Block a user