From e74d533748f951efe9bd14bb5f8dfee8fc87cebb Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Sat, 21 Mar 2026 23:40:48 -0400 Subject: [PATCH] fix: improve blocking read end-of-response detection The original '>' detection was too broad and caught tool output lines. Now we look for '> X: ' pattern (user prompt with speaker prefix) to detect the start of a new user input, which marks the end of the previous response. --- poc-agent/src/observe.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/poc-agent/src/observe.rs b/poc-agent/src/observe.rs index a5bd127..e5f0c29 100644 --- a/poc-agent/src/observe.rs +++ b/poc-agent/src/observe.rs @@ -128,9 +128,13 @@ pub async fn cmd_read_inner(follow: bool, block: bool, debug: bool) -> anyhow::R print!("{}", line); let _ = std::io::stdout().lock().flush(); - // In blocking mode, stop when we see a new user input (line starting with ">") - if block && line.trim_start().starts_with('>') { - break; + // In blocking mode, stop when we see a new user input + // Format: "> X: " where X is a speaker (P, K, etc.) + if block && line.trim_start().starts_with("> ") { + let after_gt = line.trim_start().strip_prefix("> ").unwrap_or(""); + if after_gt.contains(':') { + break; + } } } Err(_) => break,