Агенты: новая сессия вместо resume (память в промте), живой агент по простою 4 мин сводит память; экономия лимита (deviations п.69)
Some checks failed
ci / test (push) Failing after 29s
ci / deploy (push) Has been skipped

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-30 14:19:11 +03:00
parent 333106e518
commit 53df5a9e7f
13 changed files with 106 additions and 9 deletions

View File

@@ -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");