notesoup 0.51.1 → 0.51.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/plugins/pi/entries.d.ts +2 -0
  2. package/dist/plugins/pi/entries.js +2 -0
  3. package/dist/plugins/pi/reset/artifacts.d.ts +10 -2
  4. package/dist/plugins/pi/reset/artifacts.js +24 -5
  5. package/dist/plugins/pi/reset/lifecycle.d.ts +37 -21
  6. package/dist/plugins/pi/reset/lifecycle.js +132 -57
  7. package/dist/plugins/pi/runtime.js +9 -10
  8. package/dist/plugins/pi/text.d.ts +11 -14
  9. package/dist/plugins/pi/text.js +15 -16
  10. package/dist/test/agent-loop.test.js +316 -163
  11. package/dist/test/boot.integration.test.js +3 -3
  12. package/dist/test/claude-validation.test.js +4 -2
  13. package/dist/test/dsh-cli.test.js +7 -6
  14. package/dist/test/helpers/dsh-messages.js +3 -0
  15. package/dist/test/model-facing-text.test.js +10 -4
  16. package/dist/test/reset-lifecycle.test.js +272 -88
  17. package/docs/architecture.md +1 -1
  18. package/docs/reset-lifecycle.md +42 -57
  19. package/package.json +2 -2
  20. package/plugins/claude/.claude-plugin/plugin.json +1 -1
  21. package/plugins/paseo/OVERVIEW.md +7 -0
  22. package/plugins/paseo/README.md +12 -0
  23. package/plugins/paseo/client/source-row.ts +14 -0
  24. package/plugins/paseo/client/sticky-card.tsx +21 -0
  25. package/plugins/paseo/index.client.tsx +10 -0
  26. package/plugins/paseo/package.json +19 -0
  27. package/plugins/paseo/paseo-plugin.json +4 -0
  28. package/plugins/paseo/shared/last-word.ts +6 -0
  29. package/plugins/paseo/test/source-row.test.ts +19 -0
  30. package/plugins/paseo/tsconfig.json +16 -0
  31. package/plugins/pi/entries.ts +2 -0
  32. package/plugins/pi/reset/artifacts.ts +26 -5
  33. package/plugins/pi/reset/lifecycle.ts +135 -70
  34. package/plugins/pi/runtime.ts +9 -10
  35. package/plugins/pi/text.ts +17 -17
@@ -6,12 +6,15 @@ import test from "node:test";
6
6
  import { createAssistantMessageEventStream, getCurrentSystemMessage } from "@earendil-works/pi-ai";
7
7
  import { createAgentSession, createCodemodeExtension, DefaultResourceLoader, ModelRuntime, SessionManager, SettingsManager, } from "@earendil-works/pi-coding-agent";
8
8
  import notesoup, { createNotesoup } from "../plugins/pi/extension.js";
9
- import { BOOT_TYPE, CONTINUATION_TYPE, GUIDANCE_TYPE, MANUAL_WIPE_TYPE, RESET_MARKER_TYPE, WARNING_TYPE } from "../plugins/pi/entries.js";
9
+ import { BOOT_TYPE, CARRIED_INPUT_TYPE, CONTINUATION_TYPE, GUIDANCE_TYPE, MANUAL_WIPE_TYPE, NEXT_WINDOW_PROMPT_TYPE, RESET_MARKER_TYPE, WARNING_TYPE } from "../plugins/pi/entries.js";
10
10
  import { historyFromSession } from "../plugins/pi/history.js";
11
11
  import { assertBootHistory } from "./helpers/extension.js";
12
12
  import { NOTES_PROTOCOL_OPEN_TAG, WINDOW_IDENTITY_OPEN_TAG } from "../src/boot/text.js";
13
13
  import { FORCED_CONTINUATIONS, GUIDANCE_OPEN_TAG, NORMAL_CONTINUATIONS, warningPrompt } from "../src/budget/text.js";
14
- import { warningContent } from "../plugins/pi/text.js";
14
+ import { commandWarningContent, promptBlock } from "../plugins/pi/text.js";
15
+ import { registerResetLifecycle } from "../plugins/pi/reset/lifecycle.js";
16
+ import { buildResetDrafts } from "../plugins/pi/reset/artifacts.js";
17
+ import { currentWindowId } from "../plugins/pi/window.js";
15
18
  async function openFixture(options) {
16
19
  const dir = options.cwd ?? mkdtempSync(join(tmpdir(), "notesoup-agent-loop-"));
17
20
  const ownsDir = options.cwd === undefined;
@@ -76,7 +79,7 @@ async function openFixture(options) {
76
79
  noPromptTemplates: true,
77
80
  systemPromptOverride: () => options.systemPrompt ?? "Use the tools as requested.",
78
81
  agentsFilesOverride: () => ({ agentsFiles: [] }),
79
- extensionFactories: [...(options.codemode ? [createCodemodeExtension({ models: false })] : []), options.settingsManager ? createNotesoup({ settingsManager }) : notesoup, (pi) => {
82
+ extensionFactories: [...(options.codemode ? [createCodemodeExtension({ models: false })] : []), options.extensionFactory ?? (options.settingsManager ? createNotesoup({ settingsManager }) : notesoup), (pi) => {
80
83
  options.hook?.(pi, () => session, requests);
81
84
  }],
82
85
  });
@@ -127,7 +130,7 @@ async function openFixture(options) {
127
130
  await session.bindExtensions({
128
131
  uiContext: {
129
132
  notify(message, type) {
130
- if (message === "🥣 Brain emptied") {
133
+ if (message === "🥣 Fresh brain") {
131
134
  const marker = sessionManager.getBranch().filter((entry) => entry.type === "custom" && entry.customType === RESET_MARKER_TYPE).at(-1);
132
135
  const windowId = marker?.data?.windowId;
133
136
  assert.ok(sessionManager.getBranch().some((entry) => entry.type === "custom" && entry.customType === RESET_MARKER_TYPE && entry.data?.windowId === windowId), "notification follows the reset marker commit");
@@ -203,6 +206,12 @@ function continuationLinesIn(body) {
203
206
  return CONTINUATION_JSON_LINES.filter((line) => body.includes(line));
204
207
  }
205
208
  const WARNING_JSON = JSON.stringify(warningPrompt()).slice(1, -1);
209
+ const COMMAND_WARNING_JSON = JSON.stringify(commandWarningContent()).slice(1, -1);
210
+ function assertUserContent(context, content) {
211
+ assert.ok(context?.messages.some((message) => message.role === "user" && JSON.stringify(message.content) === JSON.stringify(content)), "carried input reaches the provider verbatim as user content");
212
+ }
213
+ /** The committed-reset success notice: fresh wording for the model's own wipe, forced for system resets. */
214
+ const isResetSuccessNotice = (notice) => notice.includes("🥣 Fresh brain") || notice.includes("🥣 Brain forcibly emptied");
206
215
  function resetMarkers(fixture) {
207
216
  return fixture.sessionManager.getBranch().filter((entry) => entry.type === "custom" && entry.customType === RESET_MARKER_TYPE);
208
217
  }
@@ -226,7 +235,7 @@ function assertFreshRequest(fixture, requestIndex, oldSentinel) {
226
235
  assert.ok(body.includes(WINDOW_IDENTITY_OPEN_TAG), "the new provider request includes the fresh context-window boot");
227
236
  assert.deepEqual(continuationLinesIn(body).length, 1, "the fresh window carries exactly one reset paragraph");
228
237
  }
229
- test("real Pi codemode receives typed notes/history outcomes, including expected errors", { timeout: 20000 }, async () => {
238
+ test("real Pi codemode receives typed notes/history outcomes, including expected errors", async () => {
230
239
  let fixture;
231
240
  fixture = await openFixture({
232
241
  codemode: true,
@@ -383,7 +392,7 @@ test("real AgentSession: a final warning notifies before the response, even if a
383
392
  fixture.close();
384
393
  }
385
394
  });
386
- test("real AgentSession: final warning survives its reset boundary and notifies once", { timeout: 20000 }, async () => {
395
+ test("real AgentSession: final warning survives its reset boundary and notifies once", async () => {
387
396
  let fixture;
388
397
  fixture = await openFixture({
389
398
  compactionEnabled: true,
@@ -409,12 +418,12 @@ test("real AgentSession: final warning survives its reset boundary and notifies
409
418
  assert.equal(fixture.sessionManager.getBranch().filter((entry) => entry.type === "custom_message" && entry.customType === WARNING_TYPE).length, 1);
410
419
  assert.equal(resetMarkers(fixture).length, 1, "the reset commits in the same boundary as the final warning");
411
420
  assert.equal(fixture.budgetNotices(), 1, "the old-window committed warning reaches the UI after reset");
412
- assert.equal(fixture.notices.filter((notice) => notice === "🥣 Brain emptied").length, 1, "reset notification remains intact");
421
+ assert.equal(fixture.notices.filter((notice) => notice === "🥣 Fresh brain").length, 1, "reset notification remains intact");
413
422
  assert.equal(fixture.notices.some((notice) => notice.includes("Context running low")), false, "early guidance stays silent");
414
423
  await fixture.session.prompt("Continue after reset.");
415
424
  await fixture.session.waitForIdle();
416
425
  assert.equal(fixture.budgetNotices(), 1, "later turns cannot repeat the consumed final warning");
417
- assert.equal(fixture.notices.filter((notice) => notice === "🥣 Brain emptied").length, 1, "the prior reset notification is also deduplicated");
426
+ assert.equal(fixture.notices.filter((notice) => notice === "🥣 Fresh brain").length, 1, "the prior reset notification is also deduplicated");
418
427
  }
419
428
  finally {
420
429
  fixture.close();
@@ -434,7 +443,7 @@ test("real AgentSession: explicit tiny-session wipe ignores keepRecentTokens and
434
443
  assert.equal(fixture.notices.length, 0, "startup boot is silent");
435
444
  await fixture.session.prompt("OLD_CONTEXT_SENTINEL: retain this only in durable history.");
436
445
  await fixture.session.waitForIdle();
437
- assert.deepEqual(fixture.notices.filter((message) => message.includes("Brain emptied")), ["🥣 Brain emptied · last word: “shoe”"], "the reset notifies once, carrying the last word");
446
+ assert.deepEqual(fixture.notices.filter(isResetSuccessNotice), ["🥣 Fresh brain"], "the reset notifies once, without repeating the last word");
438
447
  assert.equal(fixture.requests.length, 2, "the tool starts exactly one continuation");
439
448
  assert.ok(text(fixture.requests[0]).includes("OLD_CONTEXT_SENTINEL"));
440
449
  assertFreshRequest(fixture, 1, "OLD_CONTEXT_SENTINEL");
@@ -457,7 +466,7 @@ test("real AgentSession: explicit tiny-session wipe ignores keepRecentTokens and
457
466
  fixture.close();
458
467
  }
459
468
  });
460
- test("real AgentSession: manual command spans its tool batch and stops at settlement", { timeout: 20000 }, async () => {
469
+ test("real AgentSession: manual command spans its tool batch and stops at settlement", async () => {
461
470
  let fixture;
462
471
  fixture = await openFixture({
463
472
  compactionEnabled: false,
@@ -465,7 +474,7 @@ test("real AgentSession: manual command spans its tool batch and stops at settle
465
474
  if (request === 1)
466
475
  return assistant(fixture, [{ type: "text", text: "before manual reset" }]);
467
476
  if (request === 2) {
468
- assert.ok(text(context).includes(WARNING_JSON), "idle /empty sends the shared checkpoint prompt");
477
+ assert.ok(text(context).includes(COMMAND_WARNING_JSON), "idle /empty sends the manual close-out notice");
469
478
  return assistant(fixture, [{ type: "toolCall", id: "manual-note", name: "notes_write", arguments: { address: "manual-a.md", content: "MANUAL_NOTE_ALPHA" } }], "toolUse");
470
479
  }
471
480
  assert.equal(request, 3, "the close-out turn finishes in the old window");
@@ -480,6 +489,7 @@ test("real AgentSession: manual command spans its tool batch and stops at settle
480
489
  await fixture.session.waitForIdle();
481
490
  assert.equal(fixture.requests.length, 3, "the run stops at settlement instead of continuing in the fresh window");
482
491
  assert.equal(resetMarkers(fixture).length, 1);
492
+ assert.equal(fixture.sessionManager.getBranch().some((entry) => entry.type === "custom_message" && entry.customType === CARRIED_INPUT_TYPE), false, "a bare command with no later human input carries nothing");
483
493
  const branch = fixture.sessionManager.getBranch();
484
494
  const warningIndex = branch.findIndex((entry) => entry.type === "custom_message" && entry.customType === MANUAL_WIPE_TYPE);
485
495
  const checkpointIndex = branch.findIndex((entry) => entry.type === "compaction");
@@ -487,7 +497,7 @@ test("real AgentSession: manual command spans its tool batch and stops at settle
487
497
  assert.ok(warningIndex >= 0 && warningIndex < checkpointIndex, "the idle warning is durable before the checkpoint");
488
498
  const warning = branch[warningIndex];
489
499
  assert.ok(warning?.type === "custom_message");
490
- assert.equal(warning.content, warningContent());
500
+ assert.equal(warning.content, commandWarningContent());
491
501
  assert.equal(branch[markerIndex - 1]?.id, branch[checkpointIndex]?.id);
492
502
  assert.ok(branch.slice(0, checkpointIndex).some((entry) => entry.type === "message" && entry.message.role === "toolResult" && entry.message.toolName === "notes_write"), "note write finishes before the checkpoint");
493
503
  const marker = resetMarkers(fixture)[0];
@@ -504,50 +514,40 @@ test("real AgentSession: manual command spans its tool batch and stops at settle
504
514
  fixture.close();
505
515
  }
506
516
  });
507
- test("real AgentSession: a clear command keeps its prompt out of the fresh window and resumes once", { timeout: 25000 }, async () => {
508
- for (const mode of ["empty", "fresh-window", "hard-reserve", "overflow"]) {
509
- let fixture;
510
- const prompt = 'AFTER_CLEAR_PROMPT_SENTINEL /cm "literal text"';
511
- // `text()` serializes to JSON, so a quoted argument reaches the provider in its escaped form.
512
- const promptJson = JSON.stringify(prompt).slice(1, -1);
513
- fixture = await openFixture({
514
- compactionEnabled: mode === "hard-reserve",
515
- script: (request, context) => {
516
- if (request === 1)
517
- return assistant(fixture, [{ type: "text", text: "initial work" }]);
518
- if (request === 2) {
519
- assert.ok(text(context).includes(promptJson), "the closing window sees the human's command line verbatim");
520
- if (mode === "overflow")
521
- return assistant(fixture, [], "error", { errorMessage: "Prompt too long: context exceeds maximum context length" });
522
- return mode === "hard-reserve"
523
- ? assistant(fixture, [{ type: "toolCall", id: "prompt-note", name: "notes_write", arguments: { address: "prompt-note.md", content: "saved" } }], "toolUse", { usage: usage(80_000) })
524
- : assistant(fixture, [{ type: "text", text: "notes complete" }]);
525
- }
526
- assert.equal(request, 3, "exactly one fresh-window request");
527
- assert.equal(text(context).includes("PROMPT_RESET_OLD_SENTINEL"), false);
528
- assert.equal(text(context).includes("AFTER_CLEAR_PROMPT_SENTINEL"), false, "the fresh window is not handed the prompt");
529
- assert.equal(text(context).includes("literal text"), false, "not even the quoted argument survives the reset");
530
- assert.deepEqual(continuationLinesIn(text(context)).length, 1, "wake-up prose opens the fresh window, once");
531
- return assistant(fixture, [{ type: "text", text: "prompt handled" }]);
532
- },
533
- });
534
- try {
535
- await fixture.session.prompt("PROMPT_RESET_OLD_SENTINEL");
536
- await fixture.session.prompt(`/${mode === "empty" ? "empty" : "fresh-window"} ${prompt} `);
537
- await fixture.session.waitForIdle();
538
- assert.equal(fixture.requests.length, 3);
539
- assert.equal(resetMarkers(fixture).length, 1);
540
- const branch = fixture.sessionManager.getBranch();
541
- const continuationIndex = branch.findIndex((entry) => entry.type === "custom_message" && entry.customType === CONTINUATION_TYPE);
542
- assert.equal(branch.slice(continuationIndex + 1).filter((entry) => entry.type === "custom_message").length, 0, "nothing is injected after the continuation");
543
- assert.ok(fixture.notices.some((notice) => notice.includes("Brain emptied")));
544
- }
545
- finally {
546
- fixture.close();
547
- }
517
+ test("real AgentSession: /empty text is carried verbatim and answered after close-out", async () => {
518
+ let fixture;
519
+ const prompt = 'AFTER_CLEAR_PROMPT_SENTINEL /cm "literal text" \nsecond line';
520
+ fixture = await openFixture({
521
+ compactionEnabled: false,
522
+ script: (request, context) => {
523
+ if (request === 1)
524
+ return assistant(fixture, [{ type: "text", text: "initial work" }]);
525
+ if (request === 2) {
526
+ assert.ok(text(context).includes(JSON.stringify(promptBlock(`/empty ${prompt}`)).slice(1, -1)));
527
+ return assistant(fixture, [{ type: "toolCall", id: "prompt-wipe", name: "empty_brain", arguments: { last_word: "saved" } }], "toolUse");
528
+ }
529
+ assert.equal(request, 3);
530
+ assertFreshRequest(fixture, 2, "PROMPT_RESET_OLD_SENTINEL");
531
+ assertUserContent(context, [{ type: "text", text: prompt }]);
532
+ return assistant(fixture, [{ type: "text", text: "prompt handled" }]);
533
+ },
534
+ });
535
+ try {
536
+ await fixture.session.prompt("PROMPT_RESET_OLD_SENTINEL");
537
+ await fixture.session.prompt(`/empty ${prompt}`);
538
+ await fixture.session.waitForIdle();
539
+ assert.equal(fixture.requests.length, 3);
540
+ assert.equal(resetMarkers(fixture).length, 1);
541
+ const branch = fixture.sessionManager.getBranch();
542
+ const continuationIndex = branch.findIndex((entry) => entry.type === "custom_message" && entry.customType === CONTINUATION_TYPE);
543
+ assert.deepEqual(branch.slice(continuationIndex + 1, continuationIndex + 3).map((entry) => entry.type === "custom_message" ? entry.customType : entry.type), ["notesoup/reset-last-word", CARRIED_INPUT_TYPE]);
544
+ assert.ok(fixture.notices.some(isResetSuccessNotice));
545
+ }
546
+ finally {
547
+ fixture.close();
548
548
  }
549
549
  });
550
- test("real AgentSession: whitespace-only /fresh-window clears and stops", { timeout: 20000 }, async () => {
550
+ test("real AgentSession: whitespace-only /fresh-window clears and stops", async () => {
551
551
  let fixture;
552
552
  fixture = await openFixture({
553
553
  compactionEnabled: false,
@@ -566,7 +566,7 @@ test("real AgentSession: whitespace-only /fresh-window clears and stops", { time
566
566
  fixture.close();
567
567
  }
568
568
  });
569
- test("real AgentSession: streaming clear prompt keeps the first request", { timeout: 20000 }, async () => {
569
+ test("real AgentSession: streaming clear prompt keeps the first request", async () => {
570
570
  let fixture;
571
571
  let started;
572
572
  let release;
@@ -612,7 +612,7 @@ test("real AgentSession: streaming clear prompt keeps the first request", { time
612
612
  fixture.close();
613
613
  }
614
614
  });
615
- test("real AgentSession: manual hard-reserve reset stops clean and mixed-tool turns without fresh provider work", { timeout: 20000 }, async () => {
615
+ test("real AgentSession: manual hard-reserve reset stops clean and mixed-tool turns without fresh provider work", async () => {
616
616
  for (const mixed of [false, true]) {
617
617
  let fixture;
618
618
  let newUserAllowed = false;
@@ -636,7 +636,7 @@ test("real AgentSession: manual hard-reserve reset stops clean and mixed-tool tu
636
636
  assert.equal(fixture.requests.length, 2);
637
637
  assert.equal(resetMarkers(fixture).length, 1, "the safety wipe is not repeated at settlement");
638
638
  assert.equal(JSON.stringify(fixture.sessionManager.buildSessionProjection().messages).includes("HARD_RESERVE_OLD_SENTINEL"), false);
639
- assert.ok(fixture.notices.some((notice) => notice.includes("Brain emptied")));
639
+ assert.ok(fixture.notices.some(isResetSuccessNotice));
640
640
  if (mixed) {
641
641
  assert.ok(existsSync(join(fixture.notesRoot, "pi", "session", fixture.sessionManager.getSessionId(), "pressure.md")), "the whole tool batch completes before the cut");
642
642
  assert.equal(fixture.streamSignals.at(-1), true, "Pi's unavoidable tool follow-up is cancelled before provider work");
@@ -655,65 +655,33 @@ test("real AgentSession: manual hard-reserve reset stops clean and mixed-tool tu
655
655
  }
656
656
  }
657
657
  });
658
- test("real AgentSession: manual safety reset answers queued user input once before stopping", { timeout: 20000 }, async () => {
658
+ test("real AgentSession: overflowing /empty close-out forces a reset and retries its text only once", async () => {
659
659
  let fixture;
660
660
  fixture = await openFixture({
661
- hook: (pi, getSession) => pi.on("tool_call", async (event) => {
662
- if (event.toolName === "notes_write")
663
- await getSession().followUp("PRESSURE_QUEUED_USER_INPUT");
664
- }),
665
661
  script: (request, context) => {
666
- if (request === 1)
667
- return assistant(fixture, [{ type: "text", text: "before wipe" }]);
668
- if (request === 2)
669
- return assistant(fixture, [{ type: "toolCall", id: "queued-pressure-note", name: "notes_write", arguments: { address: "queued-pressure.md", content: "checkpoint" } }], "toolUse", { usage: usage(80_000) });
670
- assert.equal(text(context).includes("QUEUED_SAFETY_OLD_SENTINEL"), false);
671
- if (request === 3) {
672
- assert.equal(text(context).includes("PRESSURE_QUEUED_USER_INPUT"), false, "Pi's tool follow-up precedes followUp queue delivery");
673
- return assistant(fixture, [{ type: "text", text: "wipe complete; waiting for queued input" }]);
674
- }
675
- assert.equal(request, 4);
676
- assert.equal(text(context).split("PRESSURE_QUEUED_USER_INPUT").length - 1, 1);
677
- return assistant(fixture, [{ type: "text", text: "queued user input handled" }]);
678
- },
679
- });
680
- try {
681
- await fixture.session.prompt("QUEUED_SAFETY_OLD_SENTINEL");
682
- await fixture.session.prompt("/empty");
683
- await fixture.session.waitForIdle();
684
- assert.equal(fixture.requests.length, 4, "queued input is answered once after Pi's tool follow-up, then the stop lands");
685
- assert.equal(resetMarkers(fixture).length, 1);
686
- assert.equal(fixture.streamSignals.at(-1), false, "real user input must not be cancelled as an automatic follow-up");
687
- }
688
- finally {
689
- fixture.close();
690
- }
691
- });
692
- test("real AgentSession: manual overflow wipes and stops even with automatic reset disabled", { timeout: 20000 }, async () => {
693
- let fixture;
694
- fixture = await openFixture({
695
- compactionEnabled: false,
696
- script: (request) => {
697
662
  if (request === 1)
698
663
  return assistant(fixture, [{ type: "text", text: "before overflow" }]);
699
- assert.equal(request, 2, "manual overflow must not trigger a recovery request");
664
+ assert.ok(request <= 3, "an oversized carried prompt cannot loop");
665
+ if (request === 3)
666
+ assertUserContent(context, [{ type: "text", text: "OVERSIZED_MANUAL_PROMPT" }]);
700
667
  return assistant(fixture, [], "error", { errorMessage: "Prompt too long: context exceeds maximum context length" });
701
668
  },
702
669
  });
703
670
  try {
704
671
  await fixture.session.prompt("MANUAL_OVERFLOW_OLD_SENTINEL");
705
- await fixture.session.prompt("/empty");
672
+ await fixture.session.prompt("/empty OVERSIZED_MANUAL_PROMPT");
706
673
  await fixture.session.waitForIdle();
707
- assert.equal(fixture.requests.length, 2);
674
+ assert.equal(fixture.requests.length, 3);
708
675
  assert.equal(resetMarkers(fixture).length, 1);
709
- assert.equal(JSON.stringify(fixture.sessionManager.buildSessionProjection().messages).includes("MANUAL_OVERFLOW_OLD_SENTINEL"), false);
710
- assert.ok(fixture.notices.some((notice) => notice.includes("Brain emptied")));
676
+ assertFreshRequest(fixture, 2, "MANUAL_OVERFLOW_OLD_SENTINEL");
677
+ assert.equal(resetMarkers(fixture)[0].data.origin, "forced");
678
+ assert.ok(fixture.notices.some(isResetSuccessNotice));
711
679
  }
712
680
  finally {
713
681
  fixture.close();
714
682
  }
715
683
  });
716
- test("real AgentSession: streaming /empty steers a close-out and stops at settlement", { timeout: 20000 }, async () => {
684
+ test("real AgentSession: streaming /empty steers a close-out and stops at settlement", async () => {
717
685
  let fixture;
718
686
  let announceStarted;
719
687
  let releaseResponse;
@@ -728,7 +696,7 @@ test("real AgentSession: streaming /empty steers a close-out and stops at settle
728
696
  return assistant(fixture, [{ type: "text", text: "current response finished" }]);
729
697
  }
730
698
  assert.equal(request, 2, "the steered warning gets exactly one close-out turn before the run stops");
731
- assert.ok(text(context).includes(WARNING_JSON), "the busy warning is delivered to the running agent");
699
+ assert.ok(text(context).includes(COMMAND_WARNING_JSON), "the busy warning is delivered to the running agent");
732
700
  return assistant(fixture, [{ type: "text", text: "close-out complete" }]);
733
701
  },
734
702
  });
@@ -746,14 +714,14 @@ test("real AgentSession: streaming /empty steers a close-out and stops at settle
746
714
  assert.equal(fixture.requests.length, 2, "the warning closes out and the run stops — no continuation in the fresh window");
747
715
  assert.equal(fixture.sessionManager.getBranch().filter((entry) => entry.type === "custom_message" && entry.customType === MANUAL_WIPE_TYPE).length, 1, "the busy warning is persisted once");
748
716
  assert.equal(JSON.stringify(fixture.sessionManager.buildSessionProjection().messages).includes("STREAMING_WIPE_OLD_SENTINEL"), false);
749
- assert.ok(fixture.notices.some((notice) => notice.includes("Brain emptied")), "the committed boundary has a separate success notice");
717
+ assert.ok(fixture.notices.some(isResetSuccessNotice), "the committed boundary has a separate success notice");
750
718
  }
751
719
  finally {
752
720
  releaseResponse();
753
721
  fixture.close();
754
722
  }
755
723
  });
756
- test("real AgentSession: repeated manual commands share one pending window", { timeout: 20000 }, async () => {
724
+ test("real AgentSession: repeated manual commands share one pending window", async () => {
757
725
  let fixture;
758
726
  let announceStarted;
759
727
  let releaseResponse;
@@ -786,7 +754,7 @@ test("real AgentSession: repeated manual commands share one pending window", { t
786
754
  fixture.close();
787
755
  }
788
756
  });
789
- test("real AgentSession: user abort, synthetic aborted response, and generic error never fall back", { timeout: 25000 }, async () => {
757
+ test("real AgentSession: user abort, synthetic aborted response, and generic error never fall back", async () => {
790
758
  for (const mode of ["ctx-abort", "synthetic-abort", "generic-error"]) {
791
759
  let fixture;
792
760
  let didAbort = false;
@@ -811,7 +779,7 @@ test("real AgentSession: user abort, synthetic aborted response, and generic err
811
779
  await fixture.session.waitForIdle();
812
780
  assert.equal(resetMarkers(fixture).length, 0, `${mode} does not force a reset`);
813
781
  assert.equal(fixture.sessionManager.getBranch().filter((entry) => entry.type === "compaction").length, 0);
814
- assert.equal(fixture.notices.some((notice) => notice.includes("Brain emptied")), false);
782
+ assert.equal(fixture.notices.some(isResetSuccessNotice), false);
815
783
  if (mode === "ctx-abort")
816
784
  assert.equal(fixture.streamSignals.at(-1), true, "this case aborts the real Pi operation signal");
817
785
  else
@@ -832,49 +800,183 @@ test("real AgentSession: user abort, synthetic aborted response, and generic err
832
800
  }
833
801
  }
834
802
  });
835
- test("real AgentSession: steering and follow-up queued during a manual reset are answered before the stop", { timeout: 25000 }, async () => {
836
- for (const delivery of ["steer", "followUp"]) {
837
- let fixture;
838
- let announceStarted;
839
- let releaseResponse;
840
- const started = new Promise((resolve) => { announceStarted = resolve; });
841
- const gate = new Promise((resolve) => { releaseResponse = resolve; });
842
- fixture = await openFixture({
843
- compactionEnabled: false,
844
- script: async (request, context) => {
845
- if (request === 1) {
846
- assert.ok(text(context).includes(WARNING_JSON));
847
- announceStarted();
803
+ test("real AgentSession: input during bare /empty is hidden-steered, carried with images, and answered after a safety reset", async () => {
804
+ let fixture;
805
+ let started;
806
+ let release;
807
+ const ready = new Promise((resolve) => { started = resolve; });
808
+ const gate = new Promise((resolve) => { release = resolve; });
809
+ const input = "DEFERRED_HUMAN_INPUT\n verbatim";
810
+ const image = { type: "image", data: "aGVsbG8=", mimeType: "image/png" };
811
+ fixture = await openFixture({
812
+ script: async (request, context) => {
813
+ if (request === 1) {
814
+ started();
815
+ await gate;
816
+ return assistant(fixture, [{ type: "text", text: "saving notes" }]);
817
+ }
818
+ if (request === 2) {
819
+ assertUserContent(context, [{ type: "text", text: promptBlock(input) }, image]);
820
+ return assistant(fixture, [{ type: "toolCall", id: "deferred-pressure", name: "notes_write", arguments: { address: "deferred.md", content: "saved" } }], "toolUse", { usage: usage(80_000) });
821
+ }
822
+ assert.equal(request, 3, "carried input continues instead of taking the bare-command stop");
823
+ assertFreshRequest(fixture, 2, "saving notes");
824
+ assertUserContent(context, [{ type: "text", text: input }, image]);
825
+ return assistant(fixture, [{ type: "text", text: "deferred input answered" }]);
826
+ },
827
+ });
828
+ try {
829
+ const command = fixture.session.prompt("/empty");
830
+ await ready;
831
+ await fixture.session.prompt(input, { images: [image], streamingBehavior: "followUp" });
832
+ release();
833
+ await command;
834
+ await fixture.session.waitForIdle();
835
+ assert.equal(fixture.requests.length, 3);
836
+ assert.equal(resetMarkers(fixture).length, 1);
837
+ const branch = fixture.sessionManager.getBranch();
838
+ const steer = branch.find((entry) => entry.type === "custom_message" && entry.customType === NEXT_WINDOW_PROMPT_TYPE);
839
+ assert.ok(steer?.type === "custom_message");
840
+ assert.equal(steer.display, false);
841
+ assert.deepEqual(steer.content, [{ type: "text", text: promptBlock(input) }, image], "the bare block and original images reach the closing model");
842
+ assert.equal(branch.filter((entry) => entry.type === "custom_message" && entry.customType === CARRIED_INPUT_TYPE).length, 1);
843
+ assert.equal(fixture.streamSignals.at(-1), false, "the stop-pending safeguard cannot swallow carried input");
844
+ }
845
+ finally {
846
+ release();
847
+ fixture.close();
848
+ }
849
+ });
850
+ test("real AgentSession: a hidden steer queued during reset construction is not replayed beside carried input", async () => {
851
+ let fixture;
852
+ let started;
853
+ let release;
854
+ const building = new Promise((resolve) => { started = resolve; });
855
+ const gate = new Promise((resolve) => { release = resolve; });
856
+ const input = "LATE_BUILD_INPUT";
857
+ fixture = await openFixture({
858
+ tools: [],
859
+ extensionFactory: (pi) => {
860
+ const lifecycle = registerResetLifecycle(pi, {
861
+ isEnabled: () => true,
862
+ budget: { automaticResetEnabled: () => false, hardReserveDue: () => false, consumeTurnEnd: () => [], clear() { } },
863
+ async buildReset(ctx, isCurrent, lastWord, firstSeq, origin) {
864
+ started();
848
865
  await gate;
849
- }
850
- if (request === 2) {
851
- assert.ok(text(context).includes(WARNING_JSON), `${delivery} is answered in the old window before the reset commits`);
852
- assert.equal(text(context).split("QUEUED_DURING_FALLBACK").length - 1, 1, `${delivery} is delivered once`);
853
- }
854
- return assistant(fixture, [{ type: "text", text: `response ${request}` }]);
855
- },
856
- });
857
- try {
858
- const command = fixture.session.prompt("/empty");
859
- await started;
860
- if (delivery === "steer")
861
- fixture.session.steer("QUEUED_DURING_FALLBACK");
862
- else
863
- fixture.session.followUp("QUEUED_DURING_FALLBACK");
864
- releaseResponse();
865
- await command;
866
- await fixture.session.waitForIdle();
867
- assert.equal(fixture.requests.length, 2, `${delivery} is answered, then the reset commits at settlement with no continuation`);
868
- assert.equal(resetMarkers(fixture).length, 1, `${delivery} does not duplicate the reset`);
869
- assert.equal(fixture.sessionManager.getBranch().filter((entry) => entry.type === "message" && JSON.stringify(entry.message).includes("QUEUED_DURING_FALLBACK")).length, 1);
870
- }
871
- finally {
872
- releaseResponse();
873
- fixture.close();
874
- }
866
+ return buildResetDrafts(ctx, undefined, isCurrent, lastWord, firstSeq, origin);
867
+ },
868
+ });
869
+ pi.on("before_agent_start", (_event, ctx) => { lifecycle.command(currentWindowId(ctx), false); });
870
+ },
871
+ script: (request, context) => {
872
+ if (request === 1)
873
+ return assistant(fixture, [{ type: "text", text: "closing old window" }]);
874
+ assert.equal(request, 2);
875
+ assertUserContent(context, [{ type: "text", text: input }]);
876
+ assert.equal(text(context).includes("notesoup:next_window_prompt"), false, "the stale queued steer must not duplicate the carried input");
877
+ return assistant(fixture, [{ type: "text", text: "late input answered" }]);
878
+ },
879
+ });
880
+ try {
881
+ const closing = fixture.session.prompt("close out");
882
+ await building;
883
+ await fixture.session.prompt(input, { streamingBehavior: "steer" });
884
+ release();
885
+ await closing;
886
+ await fixture.session.waitForIdle();
887
+ assert.equal(fixture.requests.length, 2);
888
+ assert.equal(text(fixture.requests[1]).includes("notesoup:next_window_prompt"), false);
889
+ const branch = fixture.sessionManager.getBranch();
890
+ const markerIndex = branch.findIndex((entry) => entry.type === "custom" && entry.customType === RESET_MARKER_TYPE);
891
+ assert.ok(branch.slice(markerIndex + 1).some((entry) => entry.type === "custom_message" && entry.customType === NEXT_WINDOW_PROMPT_TYPE), "Pi really delivered the queued steer after committing the boundary");
892
+ }
893
+ finally {
894
+ release();
895
+ fixture.close();
875
896
  }
876
897
  });
877
- test("real AgentSession: a reset survives all notes-home read failures with an incomplete boot", { timeout: 15000 }, async () => {
898
+ test("real AgentSession: abort after handled input preserves originals without forcing a continuation", async () => {
899
+ let fixture;
900
+ let started;
901
+ let release;
902
+ const ready = new Promise((resolve) => { started = resolve; });
903
+ const gate = new Promise((resolve) => { release = resolve; });
904
+ const image = { type: "image", data: "aGVsbG8=", mimeType: "image/png" };
905
+ const original = [{ type: "text", text: "ABORTED_HANDLED_INPUT" }, image];
906
+ fixture = await openFixture({
907
+ compactionEnabled: false,
908
+ script: async (request, context) => {
909
+ if (request === 1) {
910
+ started();
911
+ await gate;
912
+ return assistant(fixture, [], "aborted");
913
+ }
914
+ assert.equal(request, 2);
915
+ assertUserContent(context, original);
916
+ assert.equal(text(context).includes("notesoup:next_window_prompt"), false);
917
+ return assistant(fixture, [{ type: "text", text: "resumed after abort" }]);
918
+ },
919
+ });
920
+ try {
921
+ const closing = fixture.session.prompt("/empty");
922
+ await ready;
923
+ await fixture.session.prompt("ABORTED_HANDLED_INPUT", { images: [image], streamingBehavior: "steer" });
924
+ const aborted = fixture.session.abort();
925
+ release();
926
+ await Promise.all([closing, aborted]);
927
+ assert.equal(fixture.requests.length, 1, "an explicit abort must stay stopped");
928
+ const originals = fixture.sessionManager.getBranch().filter((entry) => entry.type === "custom_message" && entry.customType === CARRIED_INPUT_TYPE);
929
+ assert.equal(originals.length, 1, "handled input is durable even though close-out was cancelled");
930
+ assert.deepEqual(originals[0].type === "custom_message" ? originals[0].content : undefined, original);
931
+ await fixture.session.prompt("Resume after cancellation.");
932
+ await fixture.session.waitForIdle();
933
+ assert.equal(fixture.requests.length, 2);
934
+ assert.equal(resetMarkers(fixture).length, 0);
935
+ }
936
+ finally {
937
+ release();
938
+ fixture.close();
939
+ }
940
+ });
941
+ test("real AgentSession: a close-out error does not discard handled input", async () => {
942
+ let fixture;
943
+ let started;
944
+ let release;
945
+ const ready = new Promise((resolve) => { started = resolve; });
946
+ const gate = new Promise((resolve) => { release = resolve; });
947
+ fixture = await openFixture({
948
+ compactionEnabled: false,
949
+ script: async (request, context) => {
950
+ if (request === 1) {
951
+ started();
952
+ await gate;
953
+ return assistant(fixture, [], "error", { errorMessage: "ordinary close-out failure" });
954
+ }
955
+ assert.equal(request, 2);
956
+ assertUserContent(context, [{ type: "text", text: "ERROR_HANDLED_INPUT" }]);
957
+ assert.equal(text(context).includes("notesoup:next_window_prompt"), false);
958
+ return assistant(fixture, [{ type: "text", text: "handled input answered without reset" }]);
959
+ },
960
+ });
961
+ try {
962
+ const closing = fixture.session.prompt("/empty");
963
+ await ready;
964
+ await fixture.session.prompt("ERROR_HANDLED_INPUT", { streamingBehavior: "steer" });
965
+ release();
966
+ await closing;
967
+ await fixture.session.waitForIdle();
968
+ const originals = fixture.sessionManager.getBranch().filter((entry) => entry.type === "custom_message" && entry.customType === CARRIED_INPUT_TYPE);
969
+ assert.equal(originals.length, 1);
970
+ assert.equal(fixture.requests.length, 2);
971
+ assertUserContent(fixture.requests[1], [{ type: "text", text: "ERROR_HANDLED_INPUT" }]);
972
+ assert.equal(resetMarkers(fixture).length, 0, "ordinary errors still do not force a reset");
973
+ }
974
+ finally {
975
+ release();
976
+ fixture.close();
977
+ }
978
+ });
979
+ test("real AgentSession: a reset survives all notes-home read failures with an incomplete boot", async () => {
878
980
  let fixture;
879
981
  fixture = await openFixture({
880
982
  compactionEnabled: false,
@@ -903,7 +1005,7 @@ test("real AgentSession: a reset survives all notes-home read failures with an i
903
1005
  fixture.close();
904
1006
  }
905
1007
  });
906
- test("real AgentSession: reset projection drops legacy message shapes but keeps raw history and equal/backwards new timestamps", { timeout: 15000 }, async () => {
1008
+ test("real AgentSession: reset projection drops legacy message shapes but keeps raw history and equal/backwards new timestamps", async () => {
907
1009
  let fixture;
908
1010
  const legacyTimestamp = Date.now();
909
1011
  const legacyTexts = [
@@ -989,7 +1091,7 @@ test("real AgentSession: successive resets and a mixed tool batch cut only after
989
1091
  }
990
1092
  }
991
1093
  });
992
- test("real AgentSession: two retain-none checkpoints survive session-file reopen", { timeout: 20000 }, async () => {
1094
+ test("real AgentSession: two retain-none checkpoints survive session-file reopen", async () => {
993
1095
  const sessionDir = mkdtempSync(join(tmpdir(), "notesoup-persisted-session-"));
994
1096
  let fixture;
995
1097
  let sessionFile = "";
@@ -1085,7 +1187,7 @@ test("real AgentSession: steering and follow-up are delivered exactly once in th
1085
1187
  }
1086
1188
  }
1087
1189
  });
1088
- test("real AgentSession: hidden or missing reset boots refuse to move the boundary", { timeout: 15000 }, async () => {
1190
+ test("real AgentSession: hidden or missing reset boots refuse to move the boundary", async () => {
1089
1191
  let fixture;
1090
1192
  fixture = await openFixture({
1091
1193
  compactionEnabled: false,
@@ -1177,14 +1279,27 @@ test("real AgentSession: the complete system message and a changed tool loadout
1177
1279
  fixture.close();
1178
1280
  }
1179
1281
  });
1180
- test("real AgentSession: overflow and recoverable length reset and retry once; repeated failure is bounded", { timeout: 15000 }, async () => {
1282
+ test("real AgentSession: overflow and recoverable length reset and retry once; repeated failure is bounded", async () => {
1181
1283
  for (const failure of ["overflow", "length"]) {
1182
1284
  let fixture;
1183
1285
  fixture = await openFixture({
1184
- script: (request) => {
1185
- if (request === 1 && failure === "overflow")
1186
- return assistant(fixture, [{ type: "text", text: "overflow response" }], "error", { errorMessage: "Prompt too long: context exceeds maximum context length" });
1187
- if (request === 1)
1286
+ hook: failure === "overflow" ? (pi, getSession) => pi.on("tool_call", async () => {
1287
+ await getSession().steer("PASSIVE_STEERED_INPUT");
1288
+ await getSession().followUp("PASSIVE_FOLLOWUP_INPUT");
1289
+ }) : undefined,
1290
+ script: (request, context) => {
1291
+ if (failure === "overflow") {
1292
+ if (request === 1)
1293
+ return assistant(fixture, [{ type: "toolCall", id: "passive-probe", name: "get_context_remaining", arguments: {} }], "toolUse");
1294
+ if (request === 2)
1295
+ return assistant(fixture, [{ type: "text", text: "tool loop checkpoint" }]);
1296
+ if (request === 3)
1297
+ return assistant(fixture, [], "error", { errorMessage: "Prompt too long: context exceeds maximum context length" });
1298
+ assert.equal(request, 4);
1299
+ assertUserContent(context, [{ type: "text", text: "PASSIVE_STEERED_INPUT" }]);
1300
+ assertUserContent(context, [{ type: "text", text: "PASSIVE_FOLLOWUP_INPUT" }]);
1301
+ }
1302
+ else if (request === 1)
1188
1303
  return assistant(fixture, [{ type: "text", text: "truncated" }], "length", { usage: usage(99_000, 1) });
1189
1304
  return assistant(fixture, [{ type: "text", text: "recovered" }]);
1190
1305
  },
@@ -1194,8 +1309,8 @@ test("real AgentSession: overflow and recoverable length reset and retry once; r
1194
1309
  await fixture.session.waitForIdle();
1195
1310
  assert.equal(resetMarkers(fixture).length, 1, `${failure} performs one reset`);
1196
1311
  assert.equal(fixture.sessionManager.getBranch().filter((entry) => entry.type === "compaction").length, 1, `${failure} commits one native reset checkpoint`);
1197
- assert.equal(fixture.requests.length, 2, `${failure} resumes once`);
1198
- assertFreshRequest(fixture, 1, `RECOVER_${failure}_SENTINEL`);
1312
+ assert.equal(fixture.requests.length, failure === "overflow" ? 4 : 2, `${failure} resumes once after queued work drains`);
1313
+ assertUserContent(fixture.requests.at(-1), [{ type: "text", text: `RECOVER_${failure}_SENTINEL` }]);
1199
1314
  }
1200
1315
  finally {
1201
1316
  fixture.close();
@@ -1203,20 +1318,58 @@ test("real AgentSession: overflow and recoverable length reset and retry once; r
1203
1318
  }
1204
1319
  let repeated;
1205
1320
  repeated = await openFixture({
1206
- script: (request) => assistant(repeated, [{ type: "text", text: `overflow-${request}` }], "error", { errorMessage: "Prompt too long: context exceeds maximum context length" }),
1321
+ script: (request) => request === 1
1322
+ ? assistant(repeated, [{ type: "toolCall", id: "automatic-start", name: "empty_brain", arguments: {} }], "toolUse")
1323
+ : assistant(repeated, [{ type: "text", text: `overflow-${request}` }], "error", { errorMessage: "Prompt too long: context exceeds maximum context length" }),
1207
1324
  });
1208
1325
  try {
1209
1326
  await repeated.session.prompt("REPEATED_OVERFLOW_SENTINEL");
1210
1327
  await repeated.session.waitForIdle();
1211
- assert.equal(resetMarkers(repeated).length, 1, "repeated overflow does not create repeated windows");
1212
- assert.equal(repeated.sessionManager.getBranch().filter((entry) => entry.type === "compaction").length, 1, "bounded overflow recovery commits one retain-none checkpoint");
1213
- assert.equal(repeated.requests.length, 2, "repeated overflow stops after one recovery request");
1328
+ assert.equal(resetMarkers(repeated).length, 2, "the tool reset is followed by exactly one overflow recovery");
1329
+ assert.equal(repeated.sessionManager.getBranch().filter((entry) => entry.type === "compaction").length, 2);
1330
+ assert.equal(repeated.requests.length, 3, "an automatic continuation still gets only one recovery request");
1331
+ assertFreshRequest(repeated, 2, "REPEATED_OVERFLOW_SENTINEL");
1332
+ assert.equal(repeated.sessionManager.getBranch().filter((entry) => entry.type === "custom_message" && entry.customType === CARRIED_INPUT_TYPE).length, 0, "our own automatic continuation has no human input to carry");
1214
1333
  }
1215
1334
  finally {
1216
1335
  repeated.close();
1217
1336
  }
1218
1337
  });
1219
- test("real AgentSession: concurrent trusted projects keep reserve and automatic policy isolated", { timeout: 20000 }, async () => {
1338
+ test("real AgentSession: a smaller-model overflow carries the failed run's human input and stays on that model", async () => {
1339
+ let fixture;
1340
+ fixture = await openFixture({
1341
+ contextWindow: 200_000,
1342
+ script: (request, context) => {
1343
+ if (request === 1)
1344
+ return assistant(fixture, [{ type: "text", text: "LARGE_MODEL_HISTORY" }], "stop", { usage: usage(150_000) });
1345
+ if (request === 2)
1346
+ return assistant(fixture, [], "error", { errorMessage: "Prompt too long: context exceeds maximum context length" });
1347
+ assert.equal(request, 3);
1348
+ assertUserContent(context, [{ type: "text", text: "CONTINUE_AFTER_MODEL_SWITCH" }]);
1349
+ return assistant(fixture, [{ type: "text", text: "continued on smaller model" }]);
1350
+ },
1351
+ });
1352
+ try {
1353
+ await fixture.session.prompt("LARGE_MODEL_TASK");
1354
+ await fixture.session.waitForIdle();
1355
+ assert.equal(resetMarkers(fixture).length, 0, "150k fits the original model's reserve");
1356
+ const smaller = { ...fixture.model, id: `${fixture.model.id}-small`, contextWindow: 100_000 };
1357
+ fixture.model = smaller;
1358
+ await fixture.session.setModel(smaller, { persist: false });
1359
+ await fixture.session.prompt("CONTINUE_AFTER_MODEL_SWITCH");
1360
+ await fixture.session.waitForIdle();
1361
+ assert.equal(resetMarkers(fixture).length, 1, "model downgrade overflow commits one reset");
1362
+ assert.equal(fixture.requests.length, 3, "one failed small-model request and one recovery request");
1363
+ assert.equal(fixture.session.model?.id, smaller.id, "recovery stays on the selected model");
1364
+ assertFreshRequest(fixture, 2, "LARGE_MODEL_HISTORY");
1365
+ assert.ok(FORCED_CONTINUATIONS.some((line) => text(fixture.requests[2]).includes(line)), "recovery uses the forced continuation");
1366
+ assert.ok(fixture.sessionManager.getBranch().some((entry) => entry.type === "message" && JSON.stringify(entry.message).includes("CONTINUE_AFTER_MODEL_SWITCH")), "the latest user request survives in raw history");
1367
+ }
1368
+ finally {
1369
+ fixture.close();
1370
+ }
1371
+ });
1372
+ test("real AgentSession: concurrent trusted projects keep reserve and automatic policy isolated", async () => {
1220
1373
  const agentDir = mkdtempSync(join(tmpdir(), "notesoup-shared-agent-"));
1221
1374
  const notesRoot = mkdtempSync(join(tmpdir(), "notesoup-shared-notes-"));
1222
1375
  const cwdAutomatic = mkdtempSync(join(tmpdir(), "notesoup-project-automatic-"));
@@ -1303,7 +1456,7 @@ test("real AgentSession: concurrent trusted projects keep reserve and automatic
1303
1456
  rmSync(cwdSession, { recursive: true, force: true });
1304
1457
  }
1305
1458
  });
1306
- test("real AgentSession: injected settings managers own live policy and ignore conflicting default files", { timeout: 20000 }, async () => {
1459
+ test("real AgentSession: injected settings managers own live policy and ignore conflicting default files", async () => {
1307
1460
  const firstManager = SettingsManager.inMemory({ compaction: { enabled: true, reserveTokens: 80_000 } });
1308
1461
  const secondManager = SettingsManager.inMemory({ compaction: { enabled: false, reserveTokens: 20_000 } });
1309
1462
  const defaultAgentDir = mkdtempSync(join(tmpdir(), "notesoup-injected-default-agent-"));
@@ -1393,7 +1546,7 @@ test("real AgentSession: injected settings managers own live policy and ignore c
1393
1546
  rmSync(notesRoot, { recursive: true, force: true });
1394
1547
  }
1395
1548
  });
1396
- test("real AgentSession: injected model overrides select the active model's reserve", { timeout: 20000 }, async () => {
1549
+ test("real AgentSession: injected model overrides select the active model's reserve", async () => {
1397
1550
  let settingsManager;
1398
1551
  let modelBId = "";
1399
1552
  const notesRoot = mkdtempSync(join(tmpdir(), "notesoup-model-override-notes-"));
@@ -1445,7 +1598,7 @@ test("real AgentSession: injected model overrides select the active model's rese
1445
1598
  rmSync(notesRoot, { recursive: true, force: true });
1446
1599
  }
1447
1600
  });
1448
- test("real AgentSession: persisted budget warning re-arms after a later abort/error", { timeout: 30000 }, async () => {
1601
+ test("real AgentSession: persisted budget warning re-arms after a later abort/error", async () => {
1449
1602
  for (const mode of ["ctx-abort", "generic-error"]) {
1450
1603
  let fixture;
1451
1604
  let warningTurnStarted;
@@ -1510,7 +1663,7 @@ test("real AgentSession: persisted budget warning re-arms after a later abort/er
1510
1663
  }
1511
1664
  }
1512
1665
  });
1513
- test("real AgentSession: warning precedes a durable checkpoint, including failed writes and an ignored warning", { timeout: 20000 }, async () => {
1666
+ test("real AgentSession: warning precedes a durable checkpoint, including failed writes and an ignored warning", async () => {
1514
1667
  for (const scenario of ["checkpoint", "write-error", "ignored-warning"]) {
1515
1668
  let fixture;
1516
1669
  fixture = await openFixture({