diff --git a/src/agent.rs b/src/agent.rs index 6d70c3d..0c98eb9 100644 --- a/src/agent.rs +++ b/src/agent.rs @@ -2177,7 +2177,9 @@ pub fn spawn(job: Job, bot_id: u64, tx: Sender<(u64, StreamEvent)>, cancel: Arc< // (Words and calls as they come say only 「it is answering」: an empty thought, which // adds nothing to the chat but tells the watchdog output started.) let hushed = |ev: StreamEvent| match ev { - StreamEvent::Alive | StreamEvent::Retrying(_) => send(StreamEvent::Alive), + StreamEvent::Alive => send(StreamEvent::Alive), + // (The service's own retry restarts the wait for a first word, as in any step.) + StreamEvent::Retrying(w) => send(StreamEvent::Nudged(w)), StreamEvent::Text(_) | StreamEvent::Thinking(_) | StreamEvent::ToolCall(_) => send(StreamEvent::Thinking(String::new())), _ => {} }; @@ -2296,6 +2298,7 @@ pub fn spawn(job: Job, bot_id: u64, tx: Sender<(u64, StreamEvent)>, cancel: Arc< if let Some(short) = again.filter(|_| !steered && nudged_in_a_row < followthrough::MAX_IN_A_ROW && nudged_total < followthrough::MAX_PER_TURN) { nudged_in_a_row += 1; nudged_total += 1; + send(StreamEvent::Nudged(followthrough::NUDGE_LINE.into())); history.push(msg); history.push(Message { wake: true, ..Message::user(&followthrough::nudge(short)) }); hush = true; @@ -2344,7 +2347,7 @@ pub fn spawn(job: Job, bot_id: u64, tx: Sender<(u64, StreamEvent)>, cancel: Arc< nudged_in_a_row += 1; nudged_total += 1; log::info!("AnyBot:Bot 說了要做卻沒呼叫工具({short:?}),提醒它接著做(這一輪第 {nudged_total} 次)"); - send(StreamEvent::Retrying("說了要做還沒動手,提醒它接著做…".into())); + send(StreamEvent::Nudged(followthrough::NUDGE_LINE.into())); history.push(Message { wake: true, ..Message::user(&followthrough::nudge(short)) }); hush = true; continue; @@ -5683,7 +5686,7 @@ echo 'done送出了' > done.html; (setsid pyt (_, StreamEvent::Thinking(t)) if t.is_empty() => quiet_output = true, (_, StreamEvent::StepDone(m)) => shown.push((m.text.clone(), m.tool_calls.len())), (_, StreamEvent::ToolResult(m)) => results.push(m.text.clone()), - (_, StreamEvent::Retrying(w)) if w.contains("接著做") => nudged = true, + (_, StreamEvent::Nudged(w)) if w.contains("接著做") => nudged = true, (_, StreamEvent::NeedApproval(a)) => { let _ = a.reply.send(ApprovalAnswer::Once); } diff --git a/src/agent/followthrough.rs b/src/agent/followthrough.rs index 1562ec6..63b99c8 100644 --- a/src/agent/followthrough.rs +++ b/src/agent/followthrough.rs @@ -12,6 +12,9 @@ /// step is set aside and the turn ends as it was. pub const DONE_MARK: &str = "〔到此為止〕"; +/// The status line while the bot is told to go on. +pub const NUDGE_LINE: &str = "說了要做還沒動手,提醒它接著做…"; + /// Nudges in a row (no tool call between them) before the turn is let end. pub const MAX_IN_A_ROW: usize = 2; /// Nudges in one turn, whatever happened between them: a guard, not a budget. diff --git a/src/app.rs b/src/app.rs index 466ebcd..24c75a7 100644 --- a/src/app.rs +++ b/src/app.rs @@ -3040,10 +3040,15 @@ impl App { live.produced = true; live.status = None; } - // A new try (or a quiet step after a nudge): the first-response deadline again. StreamEvent::Retrying(msg) => { live.status = Some(msg.clone()); live.started = Instant::now(); + } + // A quiet step after a nudge: the first-response deadline again (no NextStep + // comes for it, and the step before had produced output). + StreamEvent::Nudged(msg) => { + live.status = Some(msg.clone()); + live.started = Instant::now(); live.produced = false; } // A new model step gets the first-response deadline again. @@ -3174,7 +3179,7 @@ impl App { let mut settle_with = None; let Some(b) = self.state.bot_mut(id) else { continue }; match ev { - StreamEvent::Alive | StreamEvent::Retrying(_) | StreamEvent::NeedApproval(_) | StreamEvent::AppAction(_) | StreamEvent::React(_) | StreamEvent::Attach(_) => continue, + StreamEvent::Alive | StreamEvent::Retrying(_) | StreamEvent::Nudged(_) | StreamEvent::NeedApproval(_) | StreamEvent::AppAction(_) | StreamEvent::React(_) | StreamEvent::Attach(_) => continue, StreamEvent::Steered(m, qid) => { b.messages.push(m); // Delivered, once this chat is on disk (saved at the next frame). diff --git a/src/app/mirror_ui.rs b/src/app/mirror_ui.rs index 17d9823..24450ab 100644 --- a/src/app/mirror_ui.rs +++ b/src/app/mirror_ui.rs @@ -1568,10 +1568,13 @@ impl App { } }; if let Err(e) = sent { - *err.lock().unwrap() = format!("訊息沒有送到大腦(已放回輸入框):{e}"); + let back_in = if text.trim_start().starts_with('/') { "" } else { "(已放回輸入框)" }; + *err.lock().unwrap() = format!("訊息沒有送到大腦{back_in}:{e}"); // Take back the message shown ahead of time; its words and files go back to the input. resync.store(true, Ordering::SeqCst); - if let Some(tx) = &back { + // (A command a button sent — 「/goal clear」 — isn't the person's words: it + // doesn't go into the input, where it would join what they type next.) + if let Some(tx) = back.as_ref().filter(|_| !text.trim_start().starts_with('/')) { let _ = tx.send(Incoming::Unsent { bot, text: text.clone(), atts: atts.clone() }); } } diff --git a/src/providers.rs b/src/providers.rs index a280565..342bf59 100644 --- a/src/providers.rs +++ b/src/providers.rs @@ -226,6 +226,10 @@ pub enum StreamEvent { Alive, /// A retry is about to happen; the text says why. Retrying(String), + /// 說了就做 (agent/followthrough.rs): the bot was told to go on; its next step runs quietly + /// (no bubble until it shows something). The status line, and the first-response deadline + /// again — unlike Retrying, which also comes while a summary is written mid-turn. + Nudged(String), /// The model asked for a tool; shown at once, run after the step ends. ToolCall(ToolCall), /// A tool's state changed (waiting for approval, running, done…).