graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
feat(cache): GRAFF_CODEX_FULL_RESEND experiment flag + per-call body dump
Rach Pradhan0a293e4de055
diff --git a/src/agent_request.zig b/src/agent_request.zigindex 3e0f4c9a..bafd35e9 100644--- a/src/agent_request.zig+++ b/src/agent_request.zig@@ -205,6 +205,15 @@ pub fn request(self: *Agent, tools_in: ?[]const u8) !std.json.ObjectMap {// json_mode's stdout.if (reqStatsArmed()) {std.debug.print(" [req] body={d}B tools={d}B system={d}B messages~={d}B\n", .{ body.len, if (tools) |t| t.len else 0, self.sys_normal.len, body.len -| (if (tools) |t| t.len else 0) -| self.sys_normal.len });+ // Per-call body dump, for byte-diffing consecutive requests (cache-prefix forensics).+ const dump_seq = struct {+ var n: usize = 0;+ };+ dump_seq.n += 1;+ var dpath: [64]u8 = undefined;+ if (std.fmt.bufPrint(&dpath, "/tmp/graff-body-{d:0>3}.json", .{dump_seq.n})) |p| {+ Io.Dir.cwd().writeFile(self.io, .{ .sub_path = p, .data = body }) catch {};+ } else |_| {}// One dump per process: the assembled system prompt, for offline segment attribution (#476).const dumped = struct {var done: bool = false;diff --git a/src/codex_chain.zig b/src/codex_chain.zigindex 10029ed3..b027ff40 100644--- a/src/codex_chain.zig+++ b/src/codex_chain.zig@@ -33,8 +33,16 @@ pub fn propsFor(self: *const Agent) u64 {return propsFp(self.provider.model, @tagName(self.reasoning), self.fast, self.toolsJson(), self.systemPrompt());}+/// GRAFF_CODEX_FULL_RESEND=1 (armed by session_settings.applyEnvKnobs):+/// never chain — every turn sends the full input, opencode's only shape+/// (they carry no previous_response_id at all). Experiment flag for the+/// cache-hit work: chained turns read back ~0 cached tokens, so the delta+/// optimization trades cheap cache reads for full-price re-uploads.+pub var g_force_full_resend = false;+/// May this request chain onto the held response instead of re-anchoring?pub fn chainUsable(self: *const Agent) bool {+ if (g_force_full_resend) return false;return usable(self.codex_ws != null,self.codex_prev_id != null,diff --git a/src/session_settings.zig b/src/session_settings.zigindex 59e0e28c..a9d92684 100644--- a/src/session_settings.zig+++ b/src/session_settings.zig@@ -95,6 +95,9 @@ pub fn applyEnvKnobs(arena: Allocator, environ_map: anytype) !void {if (environ_map.get("GRAFF_LEAN") != null) no_local_tools.lean = true;// GRAFF_REQ_STATS: presence-based request-anatomy print (agent_request).agent_request.g_req_stats = environ_map.get("GRAFF_REQ_STATS") != null;+ // GRAFF_CODEX_FULL_RESEND: presence-based — never chain previous_response_id+ // (codex_chain); the opencode-shape experiment for cache-hit measurement.+ if (environ_map.get("GRAFF_CODEX_FULL_RESEND") != null) @import("codex_chain.zig").g_force_full_resend = true;// GRAFF_NO_NATIVE_FOLD: presence-based — restore full power-tool schemas// in every request (the pre-fold interactive surface).if (environ_map.get("GRAFF_NO_NATIVE_FOLD") != null) native_fold.enabled = false;