feat(repl): add /deep-seek web-research command - #137
Merged
Conversation
`/deep-seek <question>` (aliases /deepseek, /research) runs a bounded web-research pass: decompose the question, WebSearch + WebFetch sources, cross-check across sources, and synthesize a cited answer with a confidence/gaps note and a sources list. - Reuses the bounded agent-pass machinery: factor the import/dream consolidation helper into a general `run_bounded_pass(prompt, max_turns, allowed_tools)` that scopes max_turns AND a tool allowlist, restoring both afterward. `run_memory_consolidation` now delegates to it (unchanged behavior). - The pass is restricted to read-only research tools (WebSearch, WebFetch, Agent, MemorySearch, Read, Grep, Glob) — no shell, file writes, or config — so it is safe to point at questions whose answers pull in untrusted web content. The allowlist is enforced at dispatch (is_tool_permitted), not just advertised. - Bounded at 24 turns (DEEP_SEEK_MAX_TURNS) so a research fan-out can't loop indefinitely; the user keeps an interrupt point. - Registered in dispatch, the tab-completion/help source, and a new "Research" help category. Empty input prints usage (notes the BRAVE_SEARCH_API_KEY / SERPER_API_KEY requirement and the data-egress). Tests: usage-on-empty; status-line + synthesized answer; and a security test proving a non-allowlisted tool (Bash) is rejected by the gate mid-pass. Gates: cargo fmt --check, clippy --all-targets -- -D warnings, 1281 tests green.
Refines /deep-seek so it no longer depends on a search backend by default: - URL-first: the prompt now has the model propose likely official/canonical URLs from its own knowledge and verify them with WebFetch; an optional WebSearch backend (BRAVE_SEARCH_API_KEY / SERPER_API_KEY) only improves source discovery. Keeps the open-source default path key-free. - Evidence labels: every source is tagged [verified] (fetched this pass), [known] (model-prior, not fetched), or [unverified]. The prompt forbids presenting an unfetched URL as [verified], reducing hallucinated citations. - Tighter sandbox: the research pass is now restricted to web-only tools (WebSearch, WebFetch) — local file reads (Read/Grep/Glob), sub-agents (Agent), and memory access (MemorySearch) are dropped, so the pass cannot touch the local filesystem. - run_bounded_pass now intersects with any user-set restrictions instead of replacing them, via new AgentLoop::set_tool_restrictions_intersecting — so a tool the user disallowed before /deep-seek stays disallowed. Tests: local-read isolation, sub-agent isolation, user-disallow preservation, and an evidence-label prompt contract.
…ormat Two follow-ups to the URL-first deep-seek change: - Restore the directly-fetchable search-results URLs (DuckDuckGo / Google, with the query URL-encoded into `q=`) in the WebSearch "no backend" error, and add them to the "backend failed" branch too — so without a search key the model still has a concrete source-discovery path via WebFetch, not just whatever URLs it can recall. Restores encode_query_component for this. - Fix a clippy `useless_format` error (the no-backend message lost its only interpolation when the fallback URLs were removed), which would have failed CI's `clippy -D warnings` gate. Re-adds the DuckDuckGo/Google URL assertions to the WebSearch missing-key test. Gates: fmt, clippy --all-targets -- -D warnings, 1285 tests green.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a new REPL command
/deep-seek <question>(aliases/deepseek,/research) that runs a bounded, agentic web-research pass and returns a cited answer.What it does
Given a question, the pass:
WebSearchto find sources andWebFetchto read the promising ones in full (not just snippets).If no search backend is configured, it degrades gracefully — falling back to
WebFetchagainst search-engine result pages and flagging anything it can't verify.How it's built (reuses existing machinery)
run_bounded_pass(prompt, max_turns, allowed_tools)that scopes bothmax_turnsand a tool allowlist, restoring both afterward.run_memory_consolidationnow delegates to it (behavior unchanged).WebSearch,WebFetch,Agent,MemorySearch,Read,Grep,Glob. No shell, file writes, or settings/cron/provider mutation. The allowlist is enforced at dispatch (is_tool_permitted), not merely advertised — so a pass whose answer pulls in untrusted web content can't be prompt-injected into running a shell.DEEP_SEEK_MAX_TURNS) so a research fan-out can't loop indefinitely and the user keeps an interrupt point.BRAVE_SEARCH_API_KEY/SERPER_API_KEYrequirement and that question + fetched page content is sent to the model).Testing
Bash) is rejected by the gate mid-pass (the rejection lands as a tool result in the conversation, confirming the allowlist is enforced).Gates:
cargo fmt --all -- --check✓ ·cargo clippy --all-targets --all-features -- -D warnings✓ (0 warnings) · full suite 1281 passed / 0 failed.