From 2878e43321b0a03b93d8ccc939c002e44805164e Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 2 Nov 2026 10:41:07 +0000 Subject: [PATCH 1/2] daily: answer knowledge questions directly instead of verifying each claim with tools A daily-mode session asked a conceptual Rust question and the agent spent 9 serial tool calls (writing and compiling demo programs) before answering, then 3 more on the follow-up. The reasoning shows why: the prompt had no rule for answering from knowledge, and the memory snapshot's "wants verifiable evidence at each step" preference was read as applying to every reply. - prompt: daily guidelines now say to answer knowledge questions directly, use tools only when the answer depends on files, the machine, the web or current facts, and batch independent calls in one step - prompt: only name web_search when it is registered - memory: the snapshot header says entries apply where they fit the request - memory tool: patch an existing entry instead of adding a near-duplicate Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_014BrrmTSo67QjKWqpBLxeWZ --- Cargo.lock | 2 +- src/memory.rs | 3 ++- src/prompt.rs | 33 +++++++++++++++++++++++++++++++-- src/tools/memory.rs | 3 ++- 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a662b57..0cd4933 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1244,7 +1244,7 @@ dependencies = [ [[package]] name = "limbo" -version = "0.4.0" +version = "0.4.1" dependencies = [ "anyhow", "async-trait", diff --git a/src/memory.rs b/src/memory.rs index 5a0e135..da664c3 100644 --- a/src/memory.rs +++ b/src/memory.rs @@ -74,7 +74,8 @@ impl MemorySnapshot { } Some(format!( "\n\n\nPersistent memory from earlier sessions (a snapshot taken when this session started; \ - facts the user states now take precedence):\n\n{}\n\n", + facts the user states now take precedence). Apply each entry where it fits the current request; a \ + preference about how to run work tasks does not turn a plain question into a task:\n\n{}\n\n", sections.join("\n\n") )) } diff --git a/src/prompt.rs b/src/prompt.rs index 89b49a5..97255fc 100644 --- a/src/prompt.rs +++ b/src/prompt.rs @@ -24,8 +24,15 @@ const GUIDELINES_TAIL: &str = "- Use read to examine files before editing\n- Use (edits[].old_text must match exactly)\n- Use write only for new files or complete rewrites\n- Be concise in your \ responses\n- Show file paths clearly when working with files"; -const DAILY_GUIDELINES_TAIL: &str = "- For current facts, search (web_search) and read the sources (web_fetch) \ -before answering; cite the URLs you relied on\n- Save substantial outputs (notes, reports, drafts) as files in the \ +/// Daily mode answers a lot of plain questions. Without this line, models +/// with a shell treat "explain X" as "prove X on this machine" and spend a +/// tool call per claim before replying. +const DAILY_ANSWER_DIRECTLY: &str = "- Answer questions you can answer from your own knowledge (concepts, \ +explanations, opinions, comparisons) directly, without tools. Use tools only when the answer depends on the user's \ +files, this machine, the web or current facts, or when the user asks you to check or run something\n- When you do \ +use tools, make independent calls together in one step instead of one call per step"; + +const DAILY_GUIDELINES_TAIL: &str = "- Save substantial outputs (notes, reports, drafts) as files in the \ working directory and give their paths\n- Reply in the user's language; lead with the answer and keep it concise"; pub fn first_sentence(d: &str) -> &str { @@ -84,6 +91,16 @@ pub fn build_system_prompt_with( if has("task") { s.push_str("\n- Delegate self-contained research or side work to a subagent with task; run several in parallel when they are independent"); } + if daily { + s.push('\n'); + s.push_str(DAILY_ANSWER_DIRECTLY); + // Only name web_search when it is registered (it needs a provider key). + s.push_str(if has("web_search") { + "\n- For current facts, search (web_search) and read the sources (web_fetch) before answering; cite the URLs you relied on" + } else { + "\n- For current facts, read the sources (web_fetch) before answering; cite the URLs you relied on" + }); + } s.push('\n'); s.push_str(if daily { DAILY_GUIDELINES_TAIL @@ -150,5 +167,17 @@ mod tests { let p = build_system_prompt(®, Path::new("/nonexistent")); assert!(p.contains("- read: Read the contents of a file")); assert!(!p.contains("- bash:")); + assert!(!p.contains("without tools")); + } + + #[test] + fn daily_prompt_answers_directly_and_names_only_registered_search() { + let mut reg = ToolRegistry::core(true); + reg.daily_mode = true; + let p = build_system_prompt(®, Path::new("/nonexistent")); + assert!(p.contains("directly, without tools")); + assert!(p.contains("independent calls together in one step")); + assert!(!p.contains("web_search")); + assert!(p.contains("read the sources (web_fetch)")); } } diff --git a/src/tools/memory.rs b/src/tools/memory.rs index 7aed041..efb817f 100644 --- a/src/tools/memory.rs +++ b/src/tools/memory.rs @@ -11,7 +11,8 @@ const DESCRIPTION: &str = "Save durable facts to persistent memory that survives injected into every future session, so keep entries compact and high-signal. Writes take effect from the next \ session.\n\nHOW: make all changes to one target in ONE call via 'operations' (each item: {action, content?, \ old_text?}). The batch applies atomically and the character limit is checked only on the final result, so one \ -call can remove or patch stale entries to free room and add new ones.\n\nWHEN: only for facts that hold in every \ +call can remove or patch stale entries to free room and add new ones. When an entry on the same subject exists, patch it instead of adding a \ +near-duplicate.\n\nWHEN: only for facts that hold in every \ session regardless of task: who the user is, their preferences and style, stable environment facts, standing \ conventions, corrections the user made.\n\nSKIP: trivial or easily re-discovered facts, raw data, task progress, \ completed-work logs, temporary TODOs. Reusable procedures belong in a skill.\n\nTARGETS: 'user' = who the user is \ From 11f5aaa3bda376d308b1efd57a8468c18c90fc68 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 2 Nov 2026 10:45:55 +0000 Subject: [PATCH 2/2] daily: say when web_search is missing instead of dropping it silently web_search registers only when a DeepSeek key resolves. With a non-deepseek model provider (e.g. a local gateway) and no [web_search] api_key, auth entry or DEEPSEEK_API_KEY, the tool was left out with no sign, and daily sessions quietly lost search. Show a warning in the TUI and the headless REPL at startup and when daily mode is turned on, with how to fix it or turn it off ([web_search] enabled = false silences it). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_014BrrmTSo67QjKWqpBLxeWZ --- src/agent.rs | 16 ++++++++++++++++ src/commands.rs | 24 ++++++++++++++++++++++++ src/headless.rs | 10 +++++++++- src/tui/app.rs | 7 +++++++ 4 files changed, 56 insertions(+), 1 deletion(-) diff --git a/src/agent.rs b/src/agent.rs index 70adcd7..7d9a3ca 100644 --- a/src/agent.rs +++ b/src/agent.rs @@ -1619,6 +1619,22 @@ pub(crate) mod tests { c } + #[test] + fn web_search_notice_only_in_daily_mode_when_enabled_but_missing() { + let dir = tempfile::tempdir().unwrap(); + let sessions = dir.path().join("sessions"); + let mut cfg = test_config("http://127.0.0.1:9/v1"); + // An unknown provider never registers, whatever keys this machine has. + cfg.web_search.provider = "nope".into(); + let mut agent = Agent::new(cfg, dir.path(), &sessions).unwrap(); + assert!(crate::commands::web_search_missing_notice(&agent).is_none()); + agent.set_daily_mode(true); + let n = crate::commands::web_search_missing_notice(&agent).unwrap(); + assert!(n.contains("\"nope\"")); + agent.config.web_search.enabled = false; + assert!(crate::commands::web_search_missing_notice(&agent).is_none()); + } + #[tokio::test] async fn full_turn_with_tool_call_and_resume() { let dir = tempfile::tempdir().unwrap(); diff --git a/src/commands.rs b/src/commands.rs index ad46066..91ed69f 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -33,6 +33,30 @@ pub fn daily_toggle_notice(enabled: bool) -> &'static str { } } +/// Why `web_search` is missing in daily mode, or None when it is registered +/// or the user turned it off (`[web_search] enabled = false`). +/// +/// The tool is left out quietly when no DeepSeek key resolves, and a daily +/// session without search falls back to guessing or to `web_fetch` on URLs +/// it already knows, so say it once where the user can see it. +pub fn web_search_missing_notice(agent: &crate::agent::Agent) -> Option { + let s = &agent.config.web_search; + if !agent.daily_mode() || !s.enabled || agent.registry.get("web_search").is_some() { + return None; + } + Some(if s.provider != "deepseek" { + format!( + "web_search 未启用:不支持的 provider \"{}\"(目前只支持 deepseek)", + s.provider + ) + } else { + "web_search 未启用:找不到 DeepSeek API key。在 ~/.limbo/config.toml 的 [web_search] 里设 \ + api_key,或 `limbo auth` 登录 deepseek,或设置 DEEPSEEK_API_KEY;不需要搜索可设 \ + [web_search] enabled = false" + .to_string() + }) +} + pub fn daily_only_notice(command: &str) -> String { format!("{command} 只在 daily 模式可用(/daily-mode on 开启)") } diff --git a/src/headless.rs b/src/headless.rs index e6c2a67..cae5f76 100644 --- a/src/headless.rs +++ b/src/headless.rs @@ -573,7 +573,12 @@ impl Repl { }, "daily-mode" => match parse_toggle(arg, agent.daily_mode()) { None => self.p.line(cmds::DAILY_USAGE), - Some(on) if agent.set_daily_mode(on) => self.p.line(cmds::daily_toggle_notice(on)), + Some(on) if agent.set_daily_mode(on) => { + self.p.line(cmds::daily_toggle_notice(on)); + if let Some(n) = cmds::web_search_missing_notice(agent) { + self.p.line(&n); + } + } Some(on) => self.p.line(&cmds::unchanged_notice("Daily mode ", on)), }, "memory" | "learn" if !agent.daily_mode() => { @@ -779,6 +784,9 @@ pub async fn run_repl(agent: Agent, json_mode: bool) -> i32 { if let Some(g) = pump::live_goal(a) { println!("🎯 goal:{}({})", g.text, g.status); } + if let Some(n) = cmds::web_search_missing_notice(a) { + println!("{n}"); + } } } let (line_tx, mut lines) = mpsc::unbounded_channel::>(); diff --git a/src/tui/app.rs b/src/tui/app.rs index 37d58a5..9a80571 100644 --- a/src/tui/app.rs +++ b/src/tui/app.rs @@ -395,6 +395,9 @@ impl App { ), ); } + if let Some(n) = app.agent.as_ref().and_then(cmds::web_search_missing_notice) { + app.notice(NoticeKind::Warn, n); + } if !app.steer.is_empty() { app.notice( NoticeKind::Info, @@ -1790,6 +1793,7 @@ impl App { Some(on) if a.set_daily_mode(on) => { self.skills_scope = (a.workdir.clone(), on); self.skills = discover_skills(&a.workdir, on); + let search_missing = cmds::web_search_missing_notice(a); self.notice( NoticeKind::Info, if on { @@ -1799,6 +1803,9 @@ impl App { }, ); self.notice(NoticeKind::Info, cmds::daily_toggle_notice(on)); + if let Some(n) = search_missing { + self.notice(NoticeKind::Warn, n); + } } Some(on) => self.toast(cmds::unchanged_notice("Daily mode ", on)), }