Skip to content

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

Python

fix: keep unattended turns alive after a background shell

Cursor Agentace10de823be
diff --git a/src/subagent_interactive.zig b/src/subagent_interactive.zig
index c0484452..b461d383 100644
--- a/src/subagent_interactive.zig
+++ b/src/subagent_interactive.zig
@@ -26,6 +26,10 @@ pub fn configure(on: bool) void {
}
pub fn request(ctx: tools.ToolCtx) void {
+ // ACP and other unattended sessions have no prompt to hand back. Ending
+ // the turn here skips the model's next tool (the retention fixture's
+ // readiness check) and the desktop reports a finished turn too early.
+ if (@import("main.zig").unattended) return;
if (ctx.interactive_children and !ctx.from_sub) requested.store(true, .release);
}
diff --git a/src/subagent_tests.zig b/src/subagent_tests.zig
index ffd54e06..d88b5973 100644
--- a/src/subagent_tests.zig
+++ b/src/subagent_tests.zig
@@ -348,6 +348,12 @@ test "interactive children yield once without cancellation or a model request" {
interactive.request(ctx); // headless callers retain wait-until-exit behavior
try std.testing.expect((try interactive.beforeRequest(&root)) == null);
ctx.interactive_children = true;
+ const main_mod = @import("main.zig");
+ const saved_unattended = main_mod.unattended;
+ main_mod.unattended = true;
+ interactive.request(ctx);
+ try std.testing.expect((try interactive.beforeRequest(&root)) == null);
+ main_mod.unattended = saved_unattended;
interactive.request(ctx);
const text = (try interactive.beforeRequest(&root)).?;
try std.testing.expect(std.mem.indexOf(u8, text, "keep using the prompt") != null);