Skip to content

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

Python

fix(recap+test): settings.session_recap toggle; WS transport test pins cosmetic calls off

Rach Pradhan29d13f20a75a
diff --git a/scripts/codex_ws_test.py b/scripts/codex_ws_test.py
index 74defd37..ab1cf27a 100644
--- a/scripts/codex_ws_test.py
+++ b/scripts/codex_ws_test.py
@@ -258,6 +258,13 @@ def run_scenario(
expect_sse: int,
health: str,
) -> int:
+ # Cosmetic model calls (AI title, session recap) ride the same transport
+ # and would shift every turn-count assertion below — the class of failure
+ # mainloop_recap.zig's own comment warns about. Off for the whole file.
+ harness_dir = os.path.join(tmp, ".harness")
+ os.makedirs(harness_dir, exist_ok=True)
+ with open(os.path.join(harness_dir, "settings.json"), "w", encoding="utf-8") as fh:
+ json.dump({"ai_title": False, "session_recap": False}, fh)
env = {
"HOME": tmp,
"CODEX_HOME": codex_home,
@@ -265,6 +272,10 @@ def run_scenario(
"GRAFF_FLEET": "off",
"GRAFF_NO_TELEMETRY": "1",
"GRAFF_CODEX_URL": f"http://127.0.0.1:{port}/backend-api/codex/responses",
+ # The server-compaction A/B buckets on the install id, which is fresh
+ # per tmp HOME — the compaction legs below would be 50/50 flaky against
+ # a mock that speaks only the client-side flow. Pin the client arm.
+ "GRAFF_SERVER_COMPACT": "0",
}
env.update(extra_env)
# PtySession builds the child env from os.environ.copy(), so ambient
diff --git a/src/agent.zig b/src/agent.zig
index ee63256b..acf33f87 100644
--- a/src/agent.zig
+++ b/src/agent.zig
@@ -146,6 +146,7 @@ pub const Agent = struct {
review_mode: bool = false,
show_thinking: bool = true, // stream the model's reasoning live in the TUI (/thinking); off = spinner only
ai_title: bool = true, // AI-generate the tab/session title from the first prompt (/title)
+ ai_recap: bool = true, // AI one-line status recap at turn end (settings: session_recap)
goal: ?Goal = null, // structured objective + status lifecycle (/goal, #223)
goal_note_fp: u64 = 0, // last-injected standing-goal note fingerprint (goal_state.steeringGate, #318)
goal_note_age: u32 = 0, // turns since that note was last injected (refresh interval)
diff --git a/src/mainloop_recap.zig b/src/mainloop_recap.zig
index dc14fe0f..69be0766 100644
--- a/src/mainloop_recap.zig
+++ b/src/mainloop_recap.zig
@@ -61,7 +61,9 @@ pub fn onTurnEnd(ctx: anytype, jobs: *Jobs, final_text: []const u8) void {
// Cosmetic model calls stay out of scripted sessions — the same rule the
// AI title follows (mainloop.zig): a recap request against a scripted
// mock shifts every request-count assertion (test-review-mode.py on CI).
- if (!main_mod.json_mode and !ctx.root.review_mode) jobs.start(ctx);
+ // Interactive PTY tests get the same protection via settings.session_recap
+ // (codex_ws_test.py's transport turn counts).
+ if (!main_mod.json_mode and !ctx.root.review_mode and ctx.root.ai_recap) jobs.start(ctx);
}
fn detachedTask(job: *Job, gpa: Allocator, io: Io, client: *std.http.Client, provider: provider_mod.Provider, budget: ?*@import("run_budget.zig").RunBudget, tracer: ?*@import("trace.zig").Tracer) void {
diff --git a/src/repl_glue.zig b/src/repl_glue.zig
index 3515c3ef..6f866240 100644
--- a/src/repl_glue.zig
+++ b/src/repl_glue.zig
@@ -1,15 +1,12 @@
//! The `graff repl` (chat-mode) bridge — run a full root-agent turn (tools +
//! MCP) per repl.TurnFn call, plus the model-switch/cancel adapters — and the
//! goal/eval steering-note assembly shared by both the REPL and interactive
-//! loops. Also the Codex-style steering queue drain (popSteer/
-//! resetSteerPartial/steerEcho) and the /effort /fast /ultracode persistence
-//! (save/loadThinkingSettings). Split out of main.zig (600-line goal, #123).
+//! loops. Also the steering queue drain and /effort /fast /ultracode
+//! persistence (save/loadThinkingSettings). Split out of main.zig (#123).
//!
//! The mutable steer/thinking globals (g_steer_buf, g_steer_queue,
-//! g_steer_echoed, g_steer_visible, g_out) stay declared in main.zig — shared
-//! live with agent_interrupt.zig/agent_stream.zig via the same `main_mod.g_x`
-//! pattern those files already use, so every access here goes through
-//! `main_mod.g_x`, never a local alias (would freeze its value at import time).
+//! g_steer_echoed, g_steer_visible, g_out) stay declared in main.zig and are
+//! reached via `main_mod.g_x`, never a local alias (would freeze its value).
//!
//! parseEvalScore/steerEcho/saveThinkingSettings stay pub — subagent.zig,
//! agent_compact.zig, agent_interrupt.zig, commands_model.zig back-import them.
@@ -569,6 +566,9 @@ pub fn loadThinkingSettings(io: Io, arena: Allocator, root: *Agent) void {
if (v.object.get("ai_title")) |tv| if (tv == .bool) {
root.ai_title = tv.bool;
};
+ if (v.object.get("session_recap")) |rv| {
+ if (rv == .bool) root.ai_recap = rv.bool;
+ }
}
/// REPL slash commands share the leading `/` with absolute POSIX paths. Only