Агенты: новая сессия вместо resume (память в промте), живой агент по простою 4 мин сводит память; экономия лимита (deviations п.69)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -66,6 +66,25 @@ describe("долгоживущий агент (фейковый claude)", () =>
|
||||
expect(b.usage?.inputTokens).toBe(10);
|
||||
});
|
||||
|
||||
it("по простою вызывается onIdle (ход «сведи память»), после него процесс закрывается; сбой onIdle не мешает закрытию", async () => {
|
||||
for (const fail of [false, true]) {
|
||||
const events: string[] = [];
|
||||
const idled: string[] = [];
|
||||
const r = createLiveRunner({
|
||||
bin: process.execPath, prefixArgs: [script], idleMs: 150, warmupMs: 0, timeoutMs: 5_000, onEvent: (e) => events.push(e.kind),
|
||||
onIdle: async (cwd) => { idled.push(cwd); await sleep(50); if (fail) throw new Error("boom"); },
|
||||
});
|
||||
runners.push(r);
|
||||
const cwd = join(dir, fail ? "m-idle-fail" : "m-idle");
|
||||
await r.run(call(cwd, "раз"));
|
||||
expect(r.isActive(cwd)).toBe(true);
|
||||
await sleep(600);
|
||||
expect(idled).toEqual([cwd]);
|
||||
expect(r.isActive(cwd)).toBe(false);
|
||||
expect(events).toContain("idle_close");
|
||||
}
|
||||
});
|
||||
|
||||
it("новый ход сбрасывает таймер простоя", async () => {
|
||||
const { r } = mk({ idleMs: 300 });
|
||||
const cwd = join(dir, "m3");
|
||||
|
||||
Reference in New Issue
Block a user