graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
Sessions holding only a compaction blob still save
justracha6e5807ee5e1
diff --git a/src/session.zig b/src/session.zigindex 03b52793..009536a2 100644--- a/src/session.zig+++ b/src/session.zig@@ -131,8 +131,11 @@ pub fn sessionTitle(root: *Agent) []const u8 {/// durable state a resume would want back. Concretely, at least one of:/// - a user message (>= 1 message with role "user"),/// - a non-null standing goal (/goal steering),-/// - a non-empty todo list, or-/// - recorded tool activity this session.+/// - a non-empty todo list,+/// - recorded tool activity this session, or+/// - a server compaction blob. In-stream compaction prunes every prompt+/// before the blob, so a text-only turn that compacted has no user+/// message left; the blob carries it./// A truly blank draft (no user turn, no goal, no todos, no tools) is NOT/// meaningful, so saveSession skips it rather than leaving an "Untitled/// session" file on disk (#184). Callers that only want to avoid the blank-draft@@ -141,6 +144,7 @@ pub fn hasMeaningfulState(root: *Agent) bool {if (root.goal != null) return true;if (root.todos.items.len > 0) return true;if (root.tools_used.entries.items.len > 0) return true;+ if (@import("compaction_window.zig").latestBlob(root.messages.items) != null) return true;for (root.messages.items) |m| {if (m != .object) continue;if (session_peer.isHumanUserTurn(m)) return true;diff --git a/src/session_tests.zig b/src/session_tests.zigindex 86ae5e16..b01aee4d 100644--- a/src/session_tests.zig+++ b/src/session_tests.zig@@ -234,6 +234,12 @@ test "hasMeaningfulState gates the blank-draft write (#184)" {try obj.put(arena, "content", .{ .string = "hi" });try root.messages.append(.{ .object = obj });try std.testing.expect(session.hasMeaningfulState(&root));++ // In-stream compaction pruned the prompt; the blob carries it.+ root.messages = (try std.json.parseFromSliceLeaky(Value, arena,+ \\[{"type":"compaction","encrypted_content":"x"},{"type":"message","role":"assistant","content":[]}]+ , .{})).array;+ try std.testing.expect(session.hasMeaningfulState(&root));}// ── #273: the save path itself ────────────────────────────────────────────