Skip to content

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

Python

prompt cache HUD: hash the tools actually sent

justrache69c5880a05f
diff --git a/src/agent_request.zig b/src/agent_request.zig
index 922053fc..32930e52 100644
--- a/src/agent_request.zig
+++ b/src/agent_request.zig
@@ -221,7 +221,10 @@ pub fn request(self: *Agent, tools_in: ?[]const u8) !std.json.ObjectMap {
defer self.gpa.free(body);
if (!self.sub) {
const hud = @import("prompt_cache_hud.zig");
- hud.noteRequest(self.io, self.systemPrompt(), tools orelse "");
+ // Hash what goes out: where loaded tools ride announcements, the tail is not sent (ADR 0221).
+ const at = @import("additional_tools.zig");
+ const sent = if (tools) |t| (if (at.active(self.provider)) at.stripTail(self, self.scratchAlloc(), t) else t) else "";
+ hud.noteRequest(self.io, self.systemPrompt(), sent);
var aff_buf: [96]u8 = undefined;
hud.noteAffinity(
http_headers.promptCacheKey(self.io, self.label, self, &aff_buf),
diff --git a/src/mcp_schema_gate_tests.zig b/src/mcp_schema_gate_tests.zig
index 48603f01..927264a2 100644
--- a/src/mcp_schema_gate_tests.zig
+++ b/src/mcp_schema_gate_tests.zig
@@ -419,7 +419,8 @@ test "mixed native MCP loads preserve earlier emitted tool entries" {
const loaded = try gate.loadInto(a, fat, load);
try testing.expectEqual(@as(usize, 1), loaded.loaded);
const routes = [_]struct { id: []const u8, kind: @import("provider.zig").Provider.Kind, model: []const u8 }{
- .{ .id = "codegraff", .kind = .openai, .model = "mimo-v2.5" },
+ // MiMo sends the loaded tail as a system message instead (additional_tools_tests.zig).
+ .{ .id = "deepseek", .kind = .openai, .model = "deepseek-v4-pro" },
.{ .id = "xai", .kind = .responses, .model = "grok-4.6" },
.{ .id = "codex", .kind = .responses, .model = "gpt-6-sol" },
};