Skip to content

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

Python

Merge branch 'fix/compaction-quiet-delivery' into release/v0.0.302.26

justrach5b4a8e127652
diff --cc src/agent_empty_completion.zig
index 45a10f6a,e7a7e01a..6e7aef6f
--- a/src/agent_empty_completion.zig
+++ b/src/agent_empty_completion.zig
@@@ -428,36 -448,24 +452,58 @@@ test "exact reply bypasses only fake do
}
}
+test "#1518 lean bounce skips questions and a spent model-call budget" {
+ var state = std.heap.ArenaAllocator.init(std.testing.allocator);
+ defer state.deinit();
+ const old_unattended = main_mod.unattended;
+ const old_lean = no_local_tools.lean;
+ const old_enabled = no_local_tools.enabled;
+ main_mod.unattended = true;
+ no_local_tools.lean = true;
+ no_local_tools.enabled = false;
+ defer {
+ main_mod.unattended = old_unattended;
+ no_local_tools.lean = old_lean;
+ no_local_tools.enabled = old_enabled;
+ }
+ var budget: @import("run_budget.zig").RunBudget = .{ .max_model_calls = 1 };
+ budget.model_calls.store(1, .release);
+ const cases = .{
+ .{ "What does parse() return for an empty string?", false, false },
+ .{ "Fix the off-by-one in fib.py", true, false },
+ .{ "Fix the off-by-one in fib.py", false, true },
+ };
+ inline for (cases) |case| {
+ var self = pendingFixture(state.allocator());
+ self.empty_completion_retries = 0;
+ self.call_kind = .title; // suppress fixture notices without initializing a writer
+ self.tool_calls_this_turn = 0;
+ self.model_calls_this_turn = 1;
+ if (case[1]) self.run_budget = &budget;
+ try self.messages.append(try messages.textMessage(self.arena, "user", case[0]));
+ const before = self.messages.items.len;
+ try std.testing.expectEqual(case[2], try handle(&self, "It returns an empty list.", before));
+ }
+}
++
+ test "#1582 an informational question does not resume an earlier task's untouched checklist" {
+ var arena = std.heap.ArenaAllocator.init(std.testing.allocator);
+ defer arena.deinit();
+ var self = pendingFixture(arena.allocator());
+ try self.todos.append(self.arena, .{ .content = "ship the parser fix", .status = "in_progress" });
+ try self.messages.append(try messages.textMessage(self.arena, "user", "Explain how the cache works"));
+ var state = PendingWork.begin(&self);
+ try std.testing.expectEqualStrings("It is an LRU.", (try state.finish(&self, "It is an LRU.")).?);
+ try std.testing.expectEqual(@as(usize, 1), self.messages.items.len); // no reminder
+ try std.testing.expectEqualStrings("in_progress", self.todos.items[0].status); // kept, not resumed
+
+ // An informational turn that changed the checklist owns it.
+ state = PendingWork.begin(&self);
+ self.todos.items[0].status = "pending";
+ try std.testing.expect((try state.finish(&self, "Explained.")) == null);
+
+ // A work request still reconciles the same untouched checklist.
+ try self.messages.append(try messages.textMessage(self.arena, "user", "Keep going and fix it"));
+ state = PendingWork.begin(&self);
+ try std.testing.expect((try state.finish(&self, "Stopping here.")) == null);
+ }
diff --cc src/task_intent.zig
index 32c1ec03,b359cd99..7428ea71
--- a/src/task_intent.zig
+++ b/src/task_intent.zig
@@@ -41,7 -45,14 +45,14 @@@ pub fn classify(text: []const u8) Inten
var words = std.mem.tokenizeAny(u8, text, " \t\r\n,;:!?()[]{}\"`");
while (words.next()) |raw| {
const word = std.mem.trim(u8, raw, ".");
+ if (after_report and oneOf(word, &.{ "it", "this", "that", "them" })) return .general;
+ if (publish_window > 0) {
+ if (oneOf(word, &.{ "issue", "issues", "ticket", "bug", "pr" })) return .general;
+ publish_window -= 1;
+ }
+ after_report = std.ascii.eqlIgnoreCase(word, "report");
+ if (oneOf(word, &.{ "file", "open", "raise", "post", "submit", "publish", "report" })) publish_window = 3;
- if (oneOf(word, &.{ "fix", "edit", "implement", "add", "remove", "delete", "rename", "refactor", "write", "create", "update", "patch", "build", "test", "lint", "run", "merge", "push", "deploy", "commit" })) return .general;
+ if (actionWord(word)) return .general;
if (oneOf(word, &.{ "summarize", "summarise", "summary", "explain", "describe", "overview", "map", "research", "investigate", "lookup" })) informational = true;
if (std.ascii.eqlIgnoreCase(word, "read-only")) informational = true;
}
@@@ -155,9 -170,37 +185,44 @@@ test "summary checkpoint is once, prese
try std.testing.expectEqual(@as(usize, 5), agent.messages.items.len);
}
+test "only a request naming an action counts as one (#1518)" {
+ for ([_][]const u8{ "Fix src/parser.zig", "Make `python3 test.py` print OK. Do not edit the tests.", "Reply with exactly: pong; then create target.txt" }) |text|
+ try std.testing.expect(requestsAction(text));
+ for ([_][]const u8{ "What does parse() return for an empty string?", "Which module owns retries?", "what is 2+2" }) |text|
+ try std.testing.expect(!requestsAction(text));
+}
++
+ test "#1581 an explanation that also asks to publish stays actionable" {
+ for ([_][]const u8{
+ "Explain why the build fails and file an issue",
+ "Investigate the crash and open a GitHub issue for it",
+ "Explain the error and report it",
+ "Research the regression, then raise a ticket",
+ }) |text| try std.testing.expectEqual(Intent.general, classify(text));
+ try std.testing.expectEqual(Intent.informational, classify("Explain the bug report format"));
+ try std.testing.expectEqual(Intent.informational, classify("Describe the file layout"));
+ }
+
+ test "#1581 only a summary request gets the repository checkpoint" {
+ var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);
+ defer arena_state.deinit();
+ const a = arena_state.allocator();
+ const messages = @import("messages.zig");
+ var agent: Agent = undefined;
+ agent.arena = a;
+ agent.messages = .init(a);
+ agent.sub = false;
+ agent.review_mode = false;
+ agent.tracer = null;
+ agent.provider.kind = .openai;
+ agent.model_calls_this_turn = 4;
+ agent.tool_calls_this_turn = 0;
+ try agent.messages.append(try messages.textMessage(a, "user", "Investigate why login fails"));
+ var state = State.begin(&agent);
+ try state.beforeRequest(&agent);
+ const sent = try std.json.Stringify.valueAlloc(a, agent.messages.items[1], .{});
+ try std.testing.expect(std.mem.indexOf(u8, sent, "Internal reminder, not a new user request.") != null);
+ try std.testing.expect(std.mem.indexOf(u8, sent, "every deliverable it named") != null);
+ try std.testing.expect(std.mem.indexOf(u8, sent, "repository's purpose") == null);
+ try std.testing.expectEqualStrings("Investigate why login fails", messages.latestUserText(agent.messages.items));
+ }