Skip to content

graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs

Python

refactor(compact): compact_note -> compact_handoff_note, freeing the name for #391

Rach Pradhan585d5503b9b3
diff --git a/src/agent_compact.zig b/src/agent_compact.zig
index 170ca32d..772ad8ca 100644
--- a/src/agent_compact.zig
+++ b/src/agent_compact.zig
@@ -11,7 +11,7 @@ const main_mod = @import("main.zig");
const agent_mod = @import("agent.zig");
const Agent = agent_mod.Agent;
const goal_flow = @import("goal_flow.zig");
-const compact_note = @import("compact_note.zig"); // #411: both halves of "what survives a compaction"
+const handoff_note = @import("compact_handoff_note.zig"); // #411: both halves of "what survives a compaction"
const messages_mod = @import("messages.zig");
const textMessage = messages_mod.textMessage;
@@ -160,7 +160,7 @@ pub fn compact(self: *Agent) anyerror!usize {
}
};
- try self.messages.append(try textMessage(compact_arena, "user", try compact_note.summaryRequest(compact_arena, self)));
+ try self.messages.append(try textMessage(compact_arena, "user", try handoff_note.summaryRequest(compact_arena, self)));
// #174: establish the synthetic summary turn before pruning Responses
// reasoning. An active tool loop's reasoning is newer than the real user
// turn and must remain while that loop is in flight, but it becomes prior-
@@ -231,7 +231,7 @@ pub fn handoffMessage(self: *Agent, summary: []const u8, discarded: []const Valu
else
try rootHandoff(self, summary);
const standing = try goal_flow.compactionSnapshot(self.arena, self);
- return compact_note.handoff(self.arena, self, base, standing, discarded);
+ return handoff_note.handoff(self.arena, self, base, standing, discarded);
}
fn rootHandoff(self: *Agent, summary: []const u8) ![]const u8 {
diff --git a/src/agent_compact_summary_test.zig b/src/agent_compact_summary_test.zig
index f7fa73fd..64b17d86 100644
--- a/src/agent_compact_summary_test.zig
+++ b/src/agent_compact_summary_test.zig
@@ -5,7 +5,7 @@ const std = @import("std");
const Agent = @import("agent.zig").Agent;
const compact = @import("agent_compact.zig");
const repeatedEmptySummaryFailure = compact.repeatedEmptySummaryFailure;
-const compact_note = @import("compact_note.zig");
+const handoff_note = @import("compact_handoff_note.zig");
const session_transcript = @import("session_transcript.zig");
const compact_instruction = @import("prompts.zig").compact_instruction;
@@ -81,7 +81,7 @@ test "#411's request note leaves #379's empty-summary escalation exactly as it w
agent.context_local_tokens = agent.fullRequestEstimateTokens();
agent.compact_summary_failures = 0;
- const request = try compact_note.summaryRequest(a, &agent);
+ const request = try handoff_note.summaryRequest(a, &agent);
try std.testing.expect(std.mem.startsWith(u8, request, compact_instruction));
try std.testing.expect(std.mem.indexOf(u8, request, "durable state, re-derived") == null);
try std.testing.expect(!repeatedEmptySummaryFailure(&agent, error.EmptySummary));
diff --git a/src/compact_note.zig b/src/compact_handoff_note.zig
similarity index 98%
rename from src/compact_note.zig
rename to src/compact_handoff_note.zig
index a45e4a47..436653b4 100644
--- a/src/compact_note.zig
+++ b/src/compact_handoff_note.zig
@@ -1,5 +1,10 @@
//! #411: what SURVIVES a compaction, told to the model twice.
//!
+//! NOT `compact_note.zig` (#391), which is the other side of the same boundary:
+//! that one is the buffer-reserved turn where the MODEL writes notes to itself
+//! before rollover. This one is the HARNESS's own ground truth, injected around
+//! the handoff - hence the name. Both halves of the boundary, two modules.
+//!
//! THE PROBLEM. compact() replaces the history with a summary and never says
//! what the summary does NOT have to carry. The model therefore treats the
//! compaction as total loss and spends the summary hoarding contents - pasted