fix: 第三輪審查——提醒改用專用事件,回合中途的摘要不再被 120 秒硬切
- 新事件 StreamEvent::Nudged:只有「說了就做」的提醒(含連續第二次)會重設第一次回應的期限;一般的 Retrying 恢復原本的行為(回合中途寫摘要時不再被當成「還沒開始回應」而在 120 秒中止) - 安靜步驟裡供應商自己的重試照樣重設期限 - 螢幕電腦送不出的 /指令(按鈕送的 /goal clear 等)不放回輸入框,錯誤訊息照實寫 已驗證: cargo test 740 通過、clippy 無新警告;verify-anybot chat.md「說了就做」重跑結果相同,ctl down 無殘留 未驗證: 真的慢模型在安靜步驟的期限(要真的模型);螢幕電腦的指令失敗路徑(要帳號伺服器與第二台電腦) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
16ce1c6008
commit
bca9203264
|
|
@ -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 '<meta charset=utf-8><title>done</title>送出了' > 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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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).
|
||||
|
|
|
|||
|
|
@ -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() });
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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…).
|
||||
|
|
|
|||
Loading…
Reference in New Issue