From ccc9554ef4927fdf11742e27c6ed1e637a6c83a6 Mon Sep 17 00:00:00 2001 From: Hunter Bown Date: Sat, 25 Apr 2026 12:51:12 -0500 Subject: [PATCH] fix(#25): strip phantom web.run references from prompts and web_search tool MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace all web.run mentions with web_search in prompt files (base, agent, yolo, plan, normal) and update web_search.rs description. Model was trying web.run which doesn't exist, wasting turns on validation errors. Also remove [cite:ref_id] citation format which required web.run's ref_id system. Partial fix for #25 — web_search reliability improvements (real search provider) still needed. --- crates/tui/src/prompts/agent.txt | 7 +++---- crates/tui/src/prompts/base.txt | 2 +- crates/tui/src/prompts/normal.txt | 3 +-- crates/tui/src/prompts/plan.txt | 3 +-- crates/tui/src/prompts/yolo.txt | 7 +++---- crates/tui/src/tools/web_search.rs | 16 ++++++++-------- 6 files changed, 17 insertions(+), 21 deletions(-) diff --git a/crates/tui/src/prompts/agent.txt b/crates/tui/src/prompts/agent.txt index 9d530397..5fc93bf3 100644 --- a/crates/tui/src/prompts/agent.txt +++ b/crates/tui/src/prompts/agent.txt @@ -15,11 +15,11 @@ Tool selection guidance: - Use read_file to confirm context; do not assume file contents. - Prefer apply_patch/edit_file for scoped changes instead of rewriting entire files. - Use exec_shell for objective verification: build, test, format, lint, and targeted checks. -- Use web.run when local context is insufficient or time-sensitive, and cite sources as [cite:ref_id]. +- Use web_search when local context is insufficient or time-sensitive, and cite sources as (ref_id). Web browsing and citations: -- Use web.run when info might have changed or you are unsure. -- Cite non-trivial factual claims using [cite:ref_id] (the ref_id returned by web.run). +- Use web_search when info might have changed or you are unsure. +- Cite non-trivial factual claims using (ref_id) (the ref_id returned by web_search). - Place citations at the end of the sentence/paragraph they support; do not dump all citations at the end. - Quote limits: do not quote more than 25 words verbatim from a single non-lyrical source (10 words for lyrics). - Avoid reproducing full articles or large excerpts; prefer short quotes + paraphrase. @@ -42,7 +42,6 @@ FILE OPERATIONS: - edit_file: Search and replace text in a file - apply_patch: Apply a unified diff patch to a file - grep_files: Search files by regex -- web.run: Browse the web (search/open/click/find/screenshot/image_query) with ref_ids for citations - web_search: Quick web search (fallback when citations are not needed) - request_user_input: Ask the user short multiple-choice questions diff --git a/crates/tui/src/prompts/base.txt b/crates/tui/src/prompts/base.txt index b0e63316..565e178d 100644 --- a/crates/tui/src/prompts/base.txt +++ b/crates/tui/src/prompts/base.txt @@ -12,7 +12,7 @@ Tool selection guidance: - Use read tools to confirm context; avoid guessing about file contents. - Prefer targeted edits (apply_patch/edit) over full rewrites when possible. - Use shell tools for build/test/format/lint and other objective verification. -- Use web.run for time-sensitive or uncertain facts; include citations as [cite:ref_id]. +- Use web_search for time-sensitive or uncertain facts; include citations as (ref_id). - Issue independent tool calls in parallel (emit multiple tool_calls in a single turn) instead of serializing them. - Use request_user_input to ask short multiple-choice questions when needed. diff --git a/crates/tui/src/prompts/normal.txt b/crates/tui/src/prompts/normal.txt index 6adf3765..4d66dd8b 100644 --- a/crates/tui/src/prompts/normal.txt +++ b/crates/tui/src/prompts/normal.txt @@ -11,7 +11,6 @@ Available tools in this mode: - edit_file: Search and replace text in a file (ask first) - apply_patch: Apply a unified diff patch (ask first) - grep_files: Search files by regex -- web.run: Browse the web (search/open/click/find/screenshot/image_query) with ref_ids for citations - web_search: Quick web search (fallback when citations are not needed) - request_user_input: Ask the user short multiple-choice questions @@ -49,7 +48,7 @@ Tool selection guidance: - When approved to edit, prefer apply_patch/edit_file for targeted diffs. - When approved to run commands, use exec_shell for build/test/format/lint and other objective checks. - For long-running or interactive commands, use exec_shell with background: true, then exec_shell_wait/exec_shell_interact for output/input. Use tty: true when a program requires a TTY. -- When you need up-to-date or uncertain info, use web.run and cite sources as [cite:ref_id]. +- When you need up-to-date or uncertain info, use web_search and cite sources as (ref_id). Testing and stop conditions (after approval to edit/run commands): - After any change, run the most relevant tests/checks before declaring success. diff --git a/crates/tui/src/prompts/plan.txt b/crates/tui/src/prompts/plan.txt index ef89c6ad..15f1cf07 100644 --- a/crates/tui/src/prompts/plan.txt +++ b/crates/tui/src/prompts/plan.txt @@ -27,7 +27,6 @@ EXPLORATION: - list_dir: Browse directories in the workspace - read_file: Read file contents to understand context - grep_files: Search files by regex -- web.run: Browse the web (search/open/click/find/screenshot/image_query) with ref_ids for citations - web_search: Quick web search (fallback when citations are not needed) - request_user_input: Ask the user short multiple-choice questions @@ -47,7 +46,7 @@ PARALLEL TOOL USE: Guidelines: - Prefer tool-centric planning for complex or implementation-grounded requests: use grep_files/list_dir/read_file to ground the plan in the actual codebase when that grounding materially improves the plan. - Do not explore the repo just to produce a straightforward quick/high-level plan. -- Use web.run for time-sensitive or uncertain facts, and cite sources as [cite:ref_id]. +- Use web_search for time-sensitive or uncertain facts, and cite sources as (ref_id). - Use update_plan to create structured plans with one step in_progress at a time. - Each step should be specific, actionable, and include expected outcomes. - Include explicit verification steps (tests/checks) after each planned change. diff --git a/crates/tui/src/prompts/yolo.txt b/crates/tui/src/prompts/yolo.txt index a765cff7..ff7c8e97 100644 --- a/crates/tui/src/prompts/yolo.txt +++ b/crates/tui/src/prompts/yolo.txt @@ -15,11 +15,11 @@ Tool selection guidance: - Use read_file to confirm context; do not assume file contents. - Prefer apply_patch/edit_file for scoped changes instead of rewriting entire files. - Use exec_shell for objective verification: build, test, format, lint, and targeted checks. -- Use web.run when local context is insufficient or time-sensitive, and cite sources as [cite:ref_id]. +- Use web_search when local context is insufficient or time-sensitive, and cite sources as (ref_id). Web browsing and citations: -- Use web.run when info might have changed or you are unsure. -- Cite non-trivial factual claims using [cite:ref_id] (the ref_id returned by web.run). +- Use web_search when info might have changed or you are unsure. +- Cite non-trivial factual claims using (ref_id) (the ref_id returned by web_search). - Place citations at the end of the sentence/paragraph they support; do not dump all citations at the end. - Quote limits: do not quote more than 25 words verbatim from a single non-lyrical source (10 words for lyrics). - Avoid reproducing full articles or large excerpts; prefer short quotes + paraphrase. @@ -42,7 +42,6 @@ FILE OPERATIONS: - edit_file: Search and replace text in a file - apply_patch: Apply a unified diff patch to a file - grep_files: Search files by regex -- web.run: Browse the web (search/open/click/find/screenshot/image_query) with ref_ids for citations - web_search: Quick web search (fallback when citations are not needed) - request_user_input: Ask the user short multiple-choice questions diff --git a/crates/tui/src/tools/web_search.rs b/crates/tui/src/tools/web_search.rs index 5002c41e..fb3c0bf3 100644 --- a/crates/tui/src/tools/web_search.rs +++ b/crates/tui/src/tools/web_search.rs @@ -1,7 +1,7 @@ -//! Compatibility web search helper backed by DuckDuckGo HTML results. +//! Web search tool backed by DuckDuckGo HTML results (with Bing fallback). //! -//! Prefer `web.run` for new browsing calls. This legacy surface remains available -//! for older prompts and configs that still reference `web_search`. +//! This is the primary web search surface for agents. For browsing workflows +//! (page open, click, screenshot) use a direct URL approach instead. use super::spec::{ ApprovalRequirement, ToolCapability, ToolContext, ToolError, ToolResult, ToolSpec, optional_u64, @@ -93,7 +93,7 @@ impl ToolSpec for WebSearchTool { } fn description(&self) -> &'static str { - "Compatibility web search helper. Prefer web.run for canonical browsing workflows." + "Search the web using DuckDuckGo or Bing and return structured results with URLs and snippets." } fn input_schema(&self) -> Value { @@ -106,11 +106,11 @@ impl ToolSpec for WebSearchTool { }, "q": { "type": "string", - "description": "Search query alias accepted for compatibility with web.run-style calls." + "description": "Search query." }, "search_query": { "type": "array", - "description": "Compatibility form from web.run: [{\"q\":\"...\", \"max_results\": 5}]", + "description": "Array form for advanced queries: [{\"q\":\"...\", \"max_results\": 5}]", "items": { "type": "object", "properties": { @@ -510,9 +510,9 @@ mod tests { } #[test] - fn extract_search_query_accepts_web_run_shape() { + fn extract_search_query_accepts_array_form() { let input = json!({"search_query": [{"q": "deepseek api", "max_results": 3}]}); - let query = extract_search_query(&input).expect("web.run shape should parse"); + let query = extract_search_query(&input).expect("array form should parse"); assert_eq!(query, "deepseek api"); assert_eq!(optional_search_max_results(&input), 3); }