Skip to content

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

Python

refactor: compact prewarm wire-up to hold the 600-line ceiling

Rach Pradhan711035e6eeb7
diff --git a/src/agent.zig b/src/agent.zig
index 3e05be3a..d57aeee6 100644
--- a/src/agent.zig
+++ b/src/agent.zig
@@ -91,9 +91,7 @@ pub const Agent = struct {
// Codex Responses WS delta transport: one WS held ACROSS user turns (codex_chain.zig), sending previous_response_id + only new items. Reset by closeCodexWs.
codex_ws: ?*ws.WsClient = null,
codex_prev_id: ?[]const u8 = null, // last response.id (gpa-owned); null = re-anchor with full input
- /// Codex WS prewarm in flight (openai/codex `generate:false`): the body
- /// writer emits no input items and no transport fields, so the server
- /// prepares instructions+tools state that turn 1 chains onto.
+ /// Codex WS prewarm in flight (openai/codex `generate:false`): the writer emits no input/transport fields, so the server prepares instructions+tools state that turn 1 chains onto.
ws_prewarm: bool = false,
codex_sent_upto: usize = 0, // messages the server already holds; delta = messages[codex_sent_upto..]
codex_chain_rewrites: u32 = 0, // history_rewrites when the chain was anchored; a later compaction/trim invalidates it
diff --git a/src/agent_request_body_responses.zig b/src/agent_request_body_responses.zig
index a93a08e1..dc17917e 100644
--- a/src/agent_request_body_responses.zig
+++ b/src/agent_request_body_responses.zig
@@ -56,14 +56,8 @@ pub fn write(self: *Agent, s: *std.json.Stringify, tools: ?[]const u8, force_too
// this item server-side, so only a full anchor writes it.
if (!chain and explicit_cache) try writeCacheAnchor(s);
const from = if (chain) self.codex_sent_upto else 0;
- // Prewarm (openai/codex `generate:false`): prepare instructions+tools state
- // with NO input items — the real turn chains onto the warmup response id.
- if (self.ws_prewarm) {
- try s.endArray();
- } else {
- for (self.messages.items[from..]) |m| try s.write(m);
- try s.endArray();
- }
+ if (!self.ws_prewarm) for (self.messages.items[from..]) |m| try s.write(m); // prewarm: NO input items; turn 1 chains onto the warmup id
+ try s.endArray();
if (tools) |t| {
const payload = blk: {
var next = t;
@@ -96,6 +90,11 @@ pub fn write(self: *Agent, s: *std.json.Stringify, tools: ?[]const u8, force_too
// #379: compaction summaries run at low — a high-effort reasoner can
// complete with only reasoning items and zero output text.
try s.write(if (self.compaction_request or self.server_compaction_request) "low" else @import("effort_route.zig").wireEffort(self.provider.model, @tagName(self.reasoning)));
+ // summary:auto streams reasoning_summary_text.delta (reasoningDelta already parses it); without it silent reasoning emits NO frames — the stall watchdog cannot tell thinking from a dead socket.
+ if (is_codex) {
+ try s.objectField("summary");
+ try s.write("auto");
+ }
try s.endObject();
try s.objectField("include");
try s.beginArray();
@@ -107,17 +106,10 @@ pub fn write(self: *Agent, s: *std.json.Stringify, tools: ?[]const u8, force_too
server_compact.noteExposure(self);
try server_compact.writeContextManagement(self, s);
if (self.output_schema) |schema_json| try writeTextFormat(s, schema_json);
- // Prewarm: no transport fields (stream) and generate:false — connection
- // setup, not inference (openai/codex prewarm_websocket, Responses WS docs).
- if (self.ws_prewarm) {
- try s.objectField("generate");
- try s.write(false);
- return;
- }
- // No top-level max_output_tokens: the codex backend rejects it
- // ("Unsupported parameter") on gpt-5.6-* — codex sets it only as a tool argument.
- try s.objectField("stream");
- try s.write(true);
+ // Prewarm: generate:false and no transport fields — connection setup, not inference (openai/codex).
+ if (self.ws_prewarm) try s.objectField("generate") else try s.objectField("stream");
+ // No top-level max_output_tokens: codex rejects it ("Unsupported parameter") on gpt-5.6-*.
+ if (self.ws_prewarm) try s.write(false) else try s.write(true);
}
fn supportsExplicitPromptCache(self: *const Agent) bool {
diff --git a/src/main.zig b/src/main.zig
index 10c76a7d..85b18902 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -579,8 +579,7 @@ test { // ── Unit tests (`zig build test`): pull in tests from imported modu
_ = @import("agent_server_compact.zig"); // server-side autocompact (codex Responses)
_ = @import("compact_status.zig");
_ = @import("agent_request_search_tests.zig");
- _ = @import("agent_ws_steer.zig"); // gpt-6-astra response.steer
- _ = @import("agent_ws_prewarm.zig"); // codex generate:false prewarm
+ _ = @import("agent_ws_steer.zig");
_ = @import("tui_acp_updates.zig");
_ = @import("acp_preauth.zig"); // credential-free ACP loop must stay in the test root
_ = @import("task_outcome.zig"); // goal-outcome telemetry events