graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
fix: -p uses stall-watched streaming, not a 5-minute POST
Cursor Agentd590b3e9382f
diff --git a/architecture.md b/architecture.mdindex cf5e82b2..413c4950 100644--- a/architecture.md+++ b/architecture.md@@ -121,8 +121,9 @@ as codex).### StreamingRoot-agent requests stream on **all three** wire formats. `request()` decides-per call: `live = !sub && out != null && !stream_quiet` (compaction sets-`stream_quiet`; subagents always take the buffered `post()` path). When live,+per call: `live = !sub` (`Agent.usesLiveTransport`). `-p` and compaction set+`out=null` / `stream_quiet` to mute paint, not to leave the stall-watched+path; subagents always take the buffered `postWatched()` path. When live,`buildBody` adds `stream:true` (openai also gets`stream_options:{include_usage:true}` so token counts survive — dropped andretried once if a provider rejects it, same pattern as the soft-strictdiff --git a/docs/adr/0046-flash-omits-default-effort.md b/docs/adr/0046-flash-omits-default-effort.mdindex 37a237fb..6703ab75 100644--- a/docs/adr/0046-flash-omits-default-effort.md+++ b/docs/adr/0046-flash-omits-default-effort.md@@ -34,6 +34,9 @@ interactive-length essays on every `-p` turn.Do not pass `glm-5.3` (that row is zai).- Compact lean one-shot **descriptions** only (same names and JSONschemas). Do not drop to four tools. Do not steal Pi's heap.+- Root `-p` uses the streaming transport (`usesLiveTransport` = `!sub`).+ `out=null` / `stream_quiet` mute paint only. The 5-minute+ `postWatched` deadline is for subagents, not one-shots.## Consequences@@ -60,5 +63,8 @@ still the JSONL `session` line.\*first was the call-2 stdout pulse. `validated` 164s / 46k / 10 →**57s / 11k / 4**. `json-stream` and `cookie-store` still SIGKILL at-300s after that pulse. `label-sort` finished (174s) but still fails+300s after that pulse: the second model call took `postWatched`+(~250s of silence, then `retry` / 5xx) because `-p` gated `live` on+`out != null && !stream_quiet`. Root one-shots now `postLive` so the+30s head-stall fires. `label-sort` finished (174s) but still failsthe hidden check. Do not steal Pi's heap.diff --git a/docs/adr/README.md b/docs/adr/README.mdindex b6749a54..ceb95413 100644--- a/docs/adr/README.md+++ b/docs/adr/README.md@@ -56,7 +56,7 @@ record only when you need the evidence or the edge cases.| [0043](0043-pi-swe-same-seat.md) | Pi SWE A/B uses `pi-xai` on the SuperGrok seat; do not steal Pi's catalog or heap from the json-stream pass. || [0044](0044-oneshot-skips-learn-auto.md) | `-p` and `--json` skip learn auto-init; the Pi SWE wall gap was a 38s `graff-pinned` copy, not their catalog. || [0045](0045-glm-flash-swe-codegraff.md) | Codegraff `glm-5.3-flash` SWE: Pi 5/6 in 758s, graff 3/6 with three 300s timeouts; do not steal Pi's heap. |-| [0046](0046-flash-omits-default-effort.md) | Flash / Gemini omit default `medium` `reasoning_effort`; lean `-p` shortens tool prose, not the keep-list. |+| [0046](0046-flash-omits-default-effort.md) | Flash / Gemini omit default `medium` `reasoning_effort`; lean `-p` shortens tool prose, not the keep-list; `-p` streams (paint stays quiet). |## When to write onediff --git a/graff-evals/harnesses.json b/graff-evals/harnesses.jsonindex 9e8042a7..c09d7c3e 100644--- a/graff-evals/harnesses.json+++ b/graff-evals/harnesses.json@@ -22,6 +22,7 @@"usage": "graff-stderr","capabilities": ["output-schema"],"schema_args": ["--output-schema", "{schema}"],+ "env": {"GRAFF_POST_DEADLINE_SECS": "90"},"default_model": "grok-4.6"},"graff-dev-rlm": {diff --git a/src/additional_tests.zig b/src/additional_tests.zigindex 0c9258c3..f6d9cf82 100644--- a/src/additional_tests.zig+++ b/src/additional_tests.zig@@ -5,3 +5,7 @@ test {_ = @import("agent_server_compact_tests.zig");_ = @import("provider_codegraff_tests.zig");}++test "oneshot -p still uses the live stall-watched transport" {+ try @import("agent_tests.zig").oneshotUsesLiveTransport(@import("agent.zig").Agent);+}diff --git a/src/agent.zig b/src/agent.zigindex dbf65268..98f19254 100644--- a/src/agent.zig+++ b/src/agent.zig@@ -197,7 +197,7 @@ pub const Agent = struct {/// Text streamed so far in the current request — on Esc-interrupt this is/// what survives into history (with an "[interrupted]" marker appended).partial_text: std.ArrayList(u8) = .empty,- stream_quiet: bool = false, // suppress live streaming (one-shot and internal requests)+ stream_quiet: bool = false, // mute live paint (one-shot / compact); transport still streamscompaction_request: bool = false, // the current model call is the synthetic compaction-summary requestserver_compaction_request: bool = false, // force one explicit Codex in-stream compaction passresponses_output_limit: ?u32 = null, // auxiliary override (title=64); compaction always uses 4096@@ -269,6 +269,11 @@ pub const Agent = struct {return true;}+ /// Root streams even on `-p`; `out`/`stream_quiet` only mute paint.+ pub fn usesLiveTransport(self: *const Agent) bool {+ return !self.sub;+ }+pub fn toolsJson(self: *const Agent) []const u8 {return @import("agent_catalog.zig").toolsJson(self);}diff --git a/src/agent_request.zig b/src/agent_request.zigindex 3cbf5ae0..a5f450aa 100644--- a/src/agent_request.zig+++ b/src/agent_request.zig@@ -217,7 +217,7 @@ pub fn request(self: *Agent, tools_in: ?[]const u8) !std.json.ObjectMap {var openai404_retries: usize = 0; // #opencode-parity: bounded retries for OpenAI's spurious model 404sconst max_openai404_retries: usize = 2;rebuild: while (true) {- const live = !self.sub and self.out != null and !self.stream_quiet;+ const live = self.usesLiveTransport();self.streamed_text = false;self.streamed_args = .none;const body = try self.buildBody(tools, force, live, stream_usage);diff --git a/src/agent_tests.zig b/src/agent_tests.zigindex f103777c..2c4c93a9 100644--- a/src/agent_tests.zig+++ b/src/agent_tests.zig@@ -81,3 +81,20 @@ pub fn lazyRootTools(comptime Agent: type) !void {try std.testing.expect(std.mem.indexOf(u8, agent.tools_anthropic, "bench (search)") != null);try std.testing.expectEqual(@as(usize, 0), agent.tools_responses.len);}++/// `-p` sets `out=null` and `stream_quiet` so stdout stays the answer, but+/// the root still takes postLive (head/stream stall) instead of the 5-minute+/// watched POST that burned json-stream / cookie-store to a 300s SIGKILL.+pub fn oneshotUsesLiveTransport(comptime Agent: type) !void {+ var root: Agent = undefined;+ root.sub = false;+ root.out = null;+ root.stream_quiet = true;+ try std.testing.expect(root.usesLiveTransport());++ var child: Agent = undefined;+ child.sub = true;+ child.out = null;+ child.stream_quiet = true;+ try std.testing.expect(!child.usesLiveTransport());+}diff --git a/src/http.zig b/src/http.zigindex 2aa9ac13..2d513f03 100644--- a/src/http.zig+++ b/src/http.zig@@ -191,9 +191,10 @@ fn post(gpa: Allocator, client: *std.http.Client, provider: Provider, body: []co/// Hard ceiling on one non-streaming request. The legitimate worst case/// observed (a 160k-token subagent context) completed in ~134s; anything/// past this is a hung response, not a slow one. Tunable via-/// GRAFF_POST_DEADLINE_SECS (#544): non-streaming callers (one-shots,-/// subagents) have no inter-chunk stall signal, so this deadline is their-/// ONLY hang detector — a harness with a tighter task timeout lowers it.+/// GRAFF_POST_DEADLINE_SECS (#544): non-streaming callers (subagents)+/// have no inter-chunk stall signal, so this deadline is their only hang+/// detector — a harness with a tighter task timeout lowers it. Root `-p`+/// streams (ADR 0046); this ceiling is not that path's hang detector.pub var post_deadline_ms: u64 = 5 * 60 * 1000;pub const WatchdogFired = enum { esc, deadline };diff --git a/src/session_run.zig b/src/session_run.zigindex d755e66e..0ff4c2df 100644--- a/src/session_run.zig+++ b/src/session_run.zig@@ -115,7 +115,7 @@ pub fn runReplCommand(gpa: Allocator, io: Io, environ_map: anytype, root: *agent/// One-shot print mode (`-p`/bare positional prompt): run the single prompt/// to completion, print the final text to stdout, exit. Tool progress goes-/// to stderr (say() with no out writer), streaming stays quiet, and the gate+/// to stderr (say() with no out writer), paint stays quiet, and the gate/// denies anything not pre-approved instead of prompting (there's no one to/// ask). Moved out of main() verbatim (600-line goal); `root`/`tracer` are/// already stable main()-owned storage by the time this runs.