Skip to content

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

Python

fix(fold): auto-load on the meta path too — unblocks eval/review flows

Rach Pradhan5e53e9bc81ee
diff --git a/src/agent_tools.zig b/src/agent_tools.zig
index 09faf014..13165968 100644
--- a/src/agent_tools.zig
+++ b/src/agent_tools.zig
@@ -296,8 +296,9 @@ fn clockSleepInterruptedText(arena: std.mem.Allocator, elapsed_ms: i64) ![]const
/// Handle a meta tool inline on the agent's own thread.
pub fn handleMeta(self: *Agent, call: ToolCall) !ExecResult {
// Folded natives, meta path: inline dispatch never reaches exec.zig's
- // guard chain, so the refusal must live here too — same text, same rule.
- if (!self.sub and native_fold.blocked(call.name)) return .{ .text = try native_fold.refusalText(self.arena, call.name), .is_error = true };
+ // guard chain, so auto-load lives here too — a confident call loads the
+ // schema and proceeds (user direction), same rule as gateExec.
+ if (!self.sub) native_fold.markIfFolded(call.name);
// #469: sideways coordination between co-resident root sessions.
if (std.mem.eql(u8, call.name, peer_channel.tool_name)) return peer_channel.handleMessage(self, call);
if (std.mem.eql(u8, call.name, "attempt_completion")) {
diff --git a/src/native_fold.zig b/src/native_fold.zig
index 984a761c..404fdf9a 100644
--- a/src/native_fold.zig
+++ b/src/native_fold.zig
@@ -154,6 +154,14 @@ pub fn refusalText(gpa: Allocator, name: []const u8) ![]u8 {
);
}
+/// agent_tools' meta path and exec's gateExec share this: a confident call
+/// to a folded tool loads it in place of the old refusal (user direction —
+/// the refuse → load → retry dance cost a round trip, and the eval/review
+/// flows' blind eval calls starved on it: test-review-mode RunBudgetExhausted).
+pub fn markIfFolded(name: []const u8) void {
+ if (blocked(name)) markLoaded(name);
+}
+
/// exec.zig layer 2 as one expression for the guard chain. A call to a
/// folded, not-yet-loaded tool AUTO-LOADS it and proceeds (user direction):
/// the tool is advertised in the deferred listing, the call itself shows the