From bca9203264bbf20a6c16aa8d584628da33213ae9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=80=A7=E9=A9=8A?= Date: Thu, 19 Nov 2026 22:52:53 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=AC=AC=E4=B8=89=E8=BC=AA=E5=AF=A9?= =?UTF-8?q?=E6=9F=A5=E2=80=94=E2=80=94=E6=8F=90=E9=86=92=E6=94=B9=E7=94=A8?= =?UTF-8?q?=E5=B0=88=E7=94=A8=E4=BA=8B=E4=BB=B6=EF=BC=8C=E5=9B=9E=E5=90=88?= =?UTF-8?q?=E4=B8=AD=E9=80=94=E7=9A=84=E6=91=98=E8=A6=81=E4=B8=8D=E5=86=8D?= =?UTF-8?q?=E8=A2=AB=20120=20=E7=A7=92=E7=A1=AC=E5=88=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新事件 StreamEvent::Nudged:只有「說了就做」的提醒(含連續第二次)會重設第一次回應的期限;一般的 Retrying 恢復原本的行為(回合中途寫摘要時不再被當成「還沒開始回應」而在 120 秒中止) - 安靜步驟裡供應商自己的重試照樣重設期限 - 螢幕電腦送不出的 /指令(按鈕送的 /goal clear 等)不放回輸入框,錯誤訊息照實寫 已驗證: cargo test 740 通過、clippy 無新警告;verify-anybot chat.md「說了就做」重跑結果相同,ctl down 無殘留 未驗證: 真的慢模型在安靜步驟的期限(要真的模型);螢幕電腦的指令失敗路徑(要帳號伺服器與第二台電腦) Co-Authored-By: Claude Opus 5.5 --- src/agent.rs | 9 ++++++--- src/agent/followthrough.rs | 3 +++ src/app.rs | 9 +++++++-- src/app/mirror_ui.rs | 7 +++++-- src/providers.rs | 4 ++++ 5 files changed, 25 insertions(+), 7 deletions(-) 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…).