Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ public static void main(String[] args) throws Exception {
CompactionConfig.builder()
.triggerMessages(6)
.keepMessages(2)
// keepTokens defaults to dynamic mode (-1), which the
// middleware resolves from the model context window to a
// large token budget (e.g. ~8k) that always exceeds this
// short demo conversation — so the message-count keep
// window (keepMessages) is never used and compaction never
// fires. Set keepTokens(0) to force message-count keep mode
// so compaction actually triggers after a few turns.
.keepTokens(0)
.build())
.memory(
MemoryConfig.builder()
Expand Down Expand Up @@ -118,11 +126,20 @@ public static void main(String[] args) throws Exception {
System.out.println();
}

// Wait briefly for the asynchronous memory flush / consolidation to finish
// writing before we read the generated files back from disk.
Thread.sleep(3000);

// ── Check generated memory files ────────────────────────────────────

System.out.println("── Memory files on disk ──\n");

Path memoryDir = workspace.resolve("memory");
// Memory files are written under the runtime-data namespace derived from the
// RuntimeContext (default IsolationScope.USER falls back to sessionId when no
// userId is set), e.g. <workspace>/<sessionId>/memory/. Resolve the paths through
// the agent's WorkspaceManager so we read from the same location they were written
// to, rather than assuming they live directly under the workspace root.
Path memoryDir = agent.getWorkspaceManager().getMemoryDir(ctx);
if (Files.isDirectory(memoryDir)) {
Files.list(memoryDir).sorted().forEach(p -> System.out.println(" " + p.getFileName()));
} else {
Expand All @@ -141,7 +158,7 @@ public static void main(String[] args) throws Exception {
}
}

Path memoryMd = workspace.resolve("MEMORY.md");
Path memoryMd = agent.getWorkspaceManager().resolveRuntimeDataPath(ctx, "MEMORY.md");
if (Files.exists(memoryMd)) {
String content = Files.readString(memoryMd);
System.out.println("\n── MEMORY.md content ──");
Expand All @@ -152,9 +169,6 @@ public static void main(String[] args) throws Exception {
}
}

// Wait briefly for async flush to complete before printing final state
Thread.sleep(3000);

System.out.println("\nWorkspace: " + workspace);
System.out.println("\n" + "=".repeat(60));
System.out.println("Done.");
Expand Down
Loading