|
24 | 24 | import io.agentscope.core.agent.test.MockModel; |
25 | 25 | import io.agentscope.core.event.AgentResultEvent; |
26 | 26 | import io.agentscope.core.event.ConfirmResult; |
| 27 | +import io.agentscope.core.journal.InMemoryThreadJournalStore; |
27 | 28 | import io.agentscope.core.message.GenerateReason; |
28 | 29 | import io.agentscope.core.message.Msg; |
29 | 30 | import io.agentscope.core.message.MsgRole; |
|
62 | 63 | import org.junit.jupiter.params.provider.CsvSource; |
63 | 64 | import org.junit.jupiter.params.provider.ValueSource; |
64 | 65 |
|
| 66 | +/** |
| 67 | + * Every HarnessAgent in this class uses an ephemeral {@link InMemoryThreadJournalStore}. The tests |
| 68 | + * assert agent behavior over the native Thread journal (compaction, background delivery, skill |
| 69 | + * loading, spawn and resume, tool visibility), not its persistence backend, and the default |
| 70 | + * workspace journal is SQLite on Windows: one connection and one durable transaction per storage |
| 71 | + * operation costs the journal-enabled rows of the two parameterized tests 0.7-4.3s there against |
| 72 | + * 0.01-0.05s for the journal-disabled rows (0.18-0.72s and 0.05-0.21s on ubuntu). Under -T1C load |
| 73 | + * journaled invocations stopped finishing within their {@code block} deadlines (Surefire elapsed up |
| 74 | + * to 15.56s) in ten windows-latest runs between 2026-11-26 and 2026-12-02 (#4102, #4470, #4499, |
| 75 | + * #4508, #4509, #4441, #4515, #4541, #4551, #4213) while the journal-disabled rows stayed at |
| 76 | + * 0.01-0.47s. |
| 77 | + */ |
65 | 78 | class HarnessContextRegressionTest { |
66 | 79 | @TempDir Path workspace; |
67 | 80 | private final String dynamicSession = UUID.randomUUID().toString(); |
@@ -107,6 +120,7 @@ void ordinaryCompactionKeepsTheLatestUserMessageAfterSeveralToolSteps() { |
107 | 120 | try (var agent = |
108 | 121 | HarnessAgent.builder() |
109 | 122 | .workspace(workspace) |
| 123 | + .threadJournalStore(new InMemoryThreadJournalStore()) |
110 | 124 | .model(model) |
111 | 125 | .toolkit(toolkit) |
112 | 126 | .disableDefaultWorkspaceSkills() |
@@ -231,6 +245,7 @@ && new String(file.getValue(), StandardCharsets.UTF_8) |
231 | 245 | .abstractFilesystem(filesystem) |
232 | 246 | .messageBus(bus) |
233 | 247 | .journalEnabled(journalEnabled) |
| 248 | + .threadJournalStore(new InMemoryThreadJournalStore()) |
234 | 249 | .model(model) |
235 | 250 | .disableDefaultWorkspaceSkills() |
236 | 251 | .compaction( |
@@ -335,6 +350,7 @@ void newSubagentResultIsReadableByLegacyInbox() { |
335 | 350 | var sender = |
336 | 351 | HarnessAgent.builder() |
337 | 352 | .workspace(workspace) |
| 353 | + .threadJournalStore(new InMemoryThreadJournalStore()) |
338 | 354 | .abstractFilesystem(filesystem) |
339 | 355 | .messageBus(bus) |
340 | 356 | .model(new MockModel("unused")) |
@@ -434,6 +450,7 @@ void smallSkillCatalogSupportsDirectLoading(boolean dynamicSkills) throws Except |
434 | 450 | HarnessAgent.builder() |
435 | 451 | .model(model) |
436 | 452 | .workspace(workspace) |
| 453 | + .threadJournalStore(new InMemoryThreadJournalStore()) |
437 | 454 | .abstractFilesystem(new LocalFilesystem(workspace)) |
438 | 455 | .disableSubagents() |
439 | 456 | .disableCompaction(); |
@@ -526,6 +543,7 @@ void compactionFlushRequiresMemoryOptIn( |
526 | 543 | .workspace(workspace) |
527 | 544 | .abstractFilesystem(new LocalFilesystem(workspace)) |
528 | 545 | .journalEnabled(journal) |
| 546 | + .threadJournalStore(new InMemoryThreadJournalStore()) |
529 | 547 | .disableDefaultWorkspaceSkills() |
530 | 548 | .disableMemoryHooks() |
531 | 549 | .compaction( |
@@ -609,6 +627,7 @@ void dynamicSpawnResumesInNewRuntimeContext(boolean allow) throws Exception { |
609 | 627 | try (var agent = |
610 | 628 | HarnessAgent.builder() |
611 | 629 | .workspace(workspace) |
| 630 | + .threadJournalStore(new InMemoryThreadJournalStore()) |
612 | 631 | .model(model) |
613 | 632 | .abstractFilesystem(new LocalFilesystem(workspace)) |
614 | 633 | .disableDefaultWorkspaceSkills() |
@@ -657,6 +676,7 @@ void memoryToolVisibilityInheritedByBothFactories(boolean memory, boolean disabl |
657 | 676 | HarnessAgent.builder() |
658 | 677 | .model(new MockModel("ok")) |
659 | 678 | .workspace(workspace) |
| 679 | + .threadJournalStore(new InMemoryThreadJournalStore()) |
660 | 680 | .disableDefaultWorkspaceSkills() |
661 | 681 | .disableMemoryHooks(); |
662 | 682 | if (memory) builder.enableLongTermMemory(); |
|
0 commit comments