graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
peer channel: deliver at every step boundary, not just turn entry (#469)
Rach Pradhane7c175dff0bf
diff --git a/src/agent.zig b/src/agent.zigindex ab779c99..a2fcf431 100644--- a/src/agent.zig+++ b/src/agent.zig@@ -315,9 +315,6 @@ pub const Agent = struct {try self.ensureRootTools(self.provider.kind);// No per-turn teardown: the socket and the chain span user turns, guarded by codex_chain.usable instead.self.completed = null;- // #469: co-resident sessions' queued messages land at the turn boundary- // — durable in history, visible as events, never mid-turn.- peer_channel.deliverInbound(self);if (!self.sub) esc_cancel.store(false, .release); // fresh turn, no stale cancelwhile (true) {// Esc during a tool join (set by escWatchTask) lands here: the@@ -327,6 +324,12 @@ pub const Agent = struct {if (!self.sub) esc_cancel.store(false, .release);return error.Interrupted;}+ // #469: co-resident sessions' queued channel messages land at EVERY+ // step boundary, so a working session picks a peer's note up+ // mid-task (between tool batches) and can act on it in the same+ // turn — durable in history, visible as an event. Offset-based:+ // an empty channel costs one small stat per step.+ peer_channel.deliverInbound(self);// #193: pre-send overflow gate. A single turn's tool-output burst can// push the input past the model's wall before the between-turns 80%// meter (last_context_tokens, server-reported) catches up. Estimate thediff --git a/src/peer_channel.zig b/src/peer_channel.zigindex fdf5d0be..aa5ba358 100644--- a/src/peer_channel.zig+++ b/src/peer_channel.zig@@ -7,10 +7,11 @@//! except sideways, between roots. Queued, one-way, never synchronous.//! - /tell <session> <text>: the user's own line into a peer's inbox.//! - /sessions: the saved-session list gains a "live now" section.-//! - deliverInbound: drains our inbox at the turn boundary (agent.runTurn)-//! so a peer's message lands in context as a first-class note — durable in-//! history, visible to the user as an event, never mid-turn (#430's-//! input-inversion path can move it mid-turn later).+//! - deliverInbound: drains the channel at every step boundary of the turn+//! loop (agent.runTurn), so a peer's message lands mid-task — between tool+//! batches — as a first-class note, durable in history and visible to the+//! user as an event. True mid-request injection (interrupting a streamed+//! response) remains #430 territory; step boundaries are the safe seams.const std = @import("std");