graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
Merge #665 into release/v0.0.281: mid-turn stalls stay off the transcript
Cursor Agentd6f9c57dd042
diff --cc src/turn_chrome.zigindex d8fa0412,ea3805e5..a1c2b1c2--- a/src/turn_chrome.zig+++ b/src/turn_chrome.zig@@@ -37,22 -42,13 +42,19 @@@ pub fn emitRetryNotice(io: Io, class: [tool_pulse.emitNotice(io, "{s}", .{text});}- /// Count this inner-loop request, pulse from call 2, optionally pause if a- /// non-zero cap is set. Returns pause text or null to proceed. Never pauses- /// when the cap is 0. `-p` / unattended skip the pulse: it was landing on- /// stdout and eval `first_out` was "time to model call 2", not boot (ADR 0046).++/// Gate for a turn-pulse line if one is ever reintroduced. `#665` emptied++/// `formatTurnPulse`; this still skips `-p` / `--json` / subagents so a++/// future pulse cannot land on eval stdout (ADR 0046).+pub fn shouldPulseTurn(unattended: bool, json_mode: bool, sub: bool, call_n: u64) bool {+ return call_n >= 2 and !sub and !json_mode and !unattended;+}++ /// Count this inner-loop request and optionally pause if a non-zero cap is+ /// set. Returns pause text or null to proceed. Never pauses when the cap is 0.++/// Call 2+ used to print an inner-loop counter; that line is gone (ADR 0021).pub fn beforeRequest(self: *Agent) !?[]const u8 {self.model_calls_this_turn += 1;const cap = max_turn_model_calls;- if (shouldPulseTurn(main_mod.unattended, main_mod.json_mode, self.sub, self.model_calls_this_turn)) {- var buf: [120]u8 = undefined;- const text = formatTurnPulse(&buf, self.model_calls_this_turn, cap, self.tool_calls_this_turn);- if (text.len > 0) tool_pulse.emitNotice(self.io, "{s}", .{text});- }- // Call 2+ used to print an inner-loop counter line. That line is gone;- // formatTurnPulse is the pin that keeps it gone.if (cap != 0 and self.model_calls_this_turn > cap) {return try std.fmt.allocPrint(self.arena,@@@ -78,16 -74,18 +80,26 @@@ test "formatRetryNotice names HungRequetry std.testing.expectEqualStrings("· retry 1/6 · UnknownHostName", formatRetryNotice(&buf, "UnknownHostName", 1, 6));}- test "formatTurnPulse omits a denominator when the cap is unlimited" {+ test "formatTurnPulse stays off the transcript (ADR 0021)" {var buf: [80]u8 = undefined;- try std.testing.expectEqualStrings("· turn still going · model call 3 · 11 tools", formatTurnPulse(&buf, 3, 0, 11));- try std.testing.expectEqualStrings("· turn still going · model call 3/64 · 11 tools", formatTurnPulse(&buf, 3, 64, 11));+ try std.testing.expectEqualStrings("", formatTurnPulse(&buf, 3, 0, 11));+ try std.testing.expectEqualStrings("", formatTurnPulse(&buf, 3, 64, 11));+ }++ test "beforeRequest does not print an inner-loop pulse (ADR 0021)" {+ const src = @embedFile("turn_chrome.zig");+ const start = std.mem.indexOf(u8, src, "pub fn beforeRequest").?;+ const rest = src[start + 1 ..];+ const end = std.mem.indexOf(u8, rest, "\ntest ").?;+ const body = rest[0..end];+ try std.testing.expect(std.mem.indexOf(u8, body, "emitNotice") == null);+ try std.testing.expect(std.mem.indexOf(u8, body, "turn still going") == null);}++test "one-shot and --json do not pulse turn chrome onto stdout" {+ try std.testing.expect(shouldPulseTurn(false, false, false, 2));+ try std.testing.expect(!shouldPulseTurn(true, false, false, 2));+ try std.testing.expect(!shouldPulseTurn(false, true, false, 2));+ try std.testing.expect(!shouldPulseTurn(false, false, true, 2));+ try std.testing.expect(!shouldPulseTurn(false, false, false, 1));+}