graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
fix: omit an empty tool catalog from every request body (#695)
Rach Pradhanc624d6d29193
diff --git a/src/agent_request.zig b/src/agent_request.zigindex bec3949c..605628b1 100644--- a/src/agent_request.zig+++ b/src/agent_request.zig@@ -106,6 +106,9 @@ pub fn request(self: *Agent, tools_in: ?[]const u8) !std.json.ObjectMap {// budget can never pay for — which is how the audit smoke died narrating.// compaction/title requests pass tools=null already and skip this whole.var tools = tools_in;+ if (self.tracer) |tr| {+ if (tools) |t| if (t.len == 0) tr.note("tools", "empty catalog at request time (#695)");+ }if (self.run_budget) |b| if (budget_permit) |p| {if (b.max_model_calls != 0 and p.call_number == b.max_model_calls and tools != null) {tools = null;diff --git a/src/agent_request_body.zig b/src/agent_request_body.zigindex 04fc5e6c..de282796 100644--- a/src/agent_request_body.zig+++ b/src/agent_request_body.zig@@ -22,7 +22,9 @@ pub fn responsesOutputLimit(self: *const Agent) u32 {return self.responses_output_limit orelse max_tokens;}-pub fn buildBody(self: *Agent, tools: ?[]const u8, force_tool: bool, stream: bool, stream_usage: bool) ![]u8 {+pub fn buildBody(self: *Agent, tools_in: ?[]const u8, force_tool: bool, stream: bool, stream_usage: bool) ![]u8 {+ // #695: an EMPTY catalog string means "omit tools" — `""` serialized the malformed `"tools":,` that 400s every provider (0.0.280).+ const tools: ?[]const u8 = if (tools_in) |t| (if (t.len == 0) null else t) else null;var aw: Io.Writer.Allocating = .init(self.gpa);errdefer aw.deinit();var s: std.json.Stringify = .{ .writer = &aw.writer };diff --git a/src/agent_request_body_responses.zig b/src/agent_request_body_responses.zigindex 3c91f448..cae659cc 100644--- a/src/agent_request_body_responses.zig+++ b/src/agent_request_body_responses.zig@@ -318,6 +318,43 @@ fn testAgentFor(arena: std.mem.Allocator, id: []const u8, kind: @import("provide};}+// #695: the wide-native RLM showcase invalidated `tools_responses` and never+// rebuilt it, and the next body serialized `"tools":,` — an HTTP 400 on+// every provider. The serialization guard in buildBody turns an empty+// catalog string into "omit the field" on all three wires; this pins that+// so no future invalidate-without-rebuild can reach the wire malformed.+test "#695: an empty catalog string is omitted from the body, never serialized as tools:, (#695)" {+ var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);+ defer arena_state.deinit();+ const a = arena_state.allocator();++ var responses = try testAgentFor(a, "codex", .responses, "gpt-5.6-sol");+ const rb = try responses.buildBody("", false, true, true);+ defer std.testing.allocator.free(rb);+ try std.testing.expect(std.mem.indexOf(u8, rb, "\"tools\":,") == null);+ try std.testing.expect(std.mem.indexOf(u8, rb, "\"tool_choice\"") == null);+ try std.testing.expect(std.mem.indexOf(u8, rb, "\"parallel_tool_calls\"") == null);++ var chat = try testAgentFor(a, "xai", .openai, "grok-4.6");+ const cb = try chat.buildBody("", false, true, true);+ defer std.testing.allocator.free(cb);+ try std.testing.expect(std.mem.indexOf(u8, cb, "\"tools\":,") == null);+ try std.testing.expect(std.mem.indexOf(u8, cb, "\"tool_choice\"") == null);++ var anthropic = try testAgentFor(a, "anthropic", .anthropic, "claude-sonnet-5");+ const ab = try anthropic.buildBody("", false, true, true);+ defer std.testing.allocator.free(ab);+ try std.testing.expect(std.mem.indexOf(u8, ab, "\"tools\":,") == null);+ try std.testing.expect(std.mem.indexOf(u8, ab, "\"tool_choice\"") == null);++ // A real catalog still rides every wire untouched.+ var live = try testAgentFor(a, "codex", .responses, "gpt-5.6-sol");+ const catalog = "[{\"type\":\"function\",\"name\":\"bash\",\"description\":\"\"}]";+ const lb = try live.buildBody(catalog, false, true, true);+ defer std.testing.allocator.free(lb);+ try std.testing.expect(std.mem.indexOf(u8, lb, "\"name\":\"bash\"") != null);+}+test "GPT-5.6 Platform marks the stable prefix; Codex and older routes do not" {var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);defer arena_state.deinit();