Skip to content

Commit 6febffb

Browse files
committed
test: harden active memory timeout specs
1 parent b23232d commit 6febffb

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

extensions/active-memory/index.test.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2392,16 +2392,17 @@ describe("active-memory plugin", () => {
23922392
});
23932393

23942394
it("ignores late subagent payloads once the active-memory timeout signal has fired", async () => {
2395+
const CONFIGURED_TIMEOUT_MS = 25;
23952396
__testing.setMinimumTimeoutMsForTests(1);
23962397
__testing.setSetupGraceTimeoutMsForTests(0);
23972398
api.pluginConfig = {
23982399
agents: ["main"],
2399-
timeoutMs: 1,
2400+
timeoutMs: CONFIGURED_TIMEOUT_MS,
24002401
logging: true,
24012402
};
24022403
plugin.register(api as unknown as OpenClawPluginApi);
24032404
runEmbeddedPiAgent.mockImplementationOnce(async (params: { timeoutMs?: number }) => {
2404-
await new Promise((resolve) => setTimeout(resolve, (params.timeoutMs ?? 0) + 1));
2405+
await new Promise((resolve) => setTimeout(resolve, (params.timeoutMs ?? 0) + 25));
24052406
return {
24062407
payloads: [{ text: "late timeout payload that should never become memory context" }],
24072408
meta: { aborted: true },
@@ -2433,12 +2434,13 @@ describe("active-memory plugin", () => {
24332434
});
24342435

24352436
it("does not spend the model timeout budget on active-memory subagent setup", async () => {
2436-
const CONFIGURED_TIMEOUT_MS = 10;
2437+
const CONFIGURED_TIMEOUT_MS = 50;
2438+
const SETUP_GRACE_TIMEOUT_MS = 500;
24372439
__testing.setMinimumTimeoutMsForTests(1);
24382440
api.pluginConfig = {
24392441
agents: ["main"],
24402442
timeoutMs: CONFIGURED_TIMEOUT_MS,
2441-
setupGraceTimeoutMs: 100,
2443+
setupGraceTimeoutMs: SETUP_GRACE_TIMEOUT_MS,
24422444
logging: true,
24432445
};
24442446
plugin.register(api as unknown as OpenClawPluginApi);
@@ -2458,7 +2460,9 @@ describe("active-memory plugin", () => {
24582460
);
24592461

24602462
expect(result?.prependContext).toContain("remember the ramen place");
2461-
expect(runEmbeddedPiAgent.mock.calls.at(-1)?.[0]?.timeoutMs).toBe(CONFIGURED_TIMEOUT_MS + 100);
2463+
expect(runEmbeddedPiAgent.mock.calls.at(-1)?.[0]?.timeoutMs).toBe(
2464+
CONFIGURED_TIMEOUT_MS + SETUP_GRACE_TIMEOUT_MS,
2465+
);
24622466
const infoLines = vi
24632467
.mocked(api.logger.info)
24642468
.mock.calls.map((call: unknown[]) => String(call[0]));
@@ -3607,11 +3611,12 @@ describe("active-memory plugin", () => {
36073611
});
36083612

36093613
it("skips recall after consecutive timeouts when circuit breaker trips (#74054)", async () => {
3614+
const CONFIGURED_TIMEOUT_MS = 25;
36103615
__testing.setMinimumTimeoutMsForTests(1);
36113616
__testing.setSetupGraceTimeoutMsForTests(0);
36123617
api.pluginConfig = {
36133618
agents: ["main"],
3614-
timeoutMs: 1,
3619+
timeoutMs: CONFIGURED_TIMEOUT_MS,
36153620
logging: true,
36163621
circuitBreakerMaxTimeouts: 2,
36173622
circuitBreakerCooldownMs: 60_000,
@@ -3662,11 +3667,12 @@ describe("active-memory plugin", () => {
36623667
});
36633668

36643669
it("resets circuit breaker after a successful recall", async () => {
3670+
const CONFIGURED_TIMEOUT_MS = 25;
36653671
__testing.setMinimumTimeoutMsForTests(1);
36663672
__testing.setSetupGraceTimeoutMsForTests(0);
36673673
api.pluginConfig = {
36683674
agents: ["main"],
3669-
timeoutMs: 50,
3675+
timeoutMs: CONFIGURED_TIMEOUT_MS,
36703676
logging: true,
36713677
circuitBreakerMaxTimeouts: 1,
36723678
circuitBreakerCooldownMs: 60_000,

0 commit comments

Comments
 (0)