refactor(search): remove the Gemini search backend

The user asked to drop it: nobody had the Gemini CLI login or a key set up,
and Exa then Wikipedia cover the voice use. webSearch is now live Chrome,
Exa, Brave (opt-in), Wikipedia. Removes the CLI/REST backends, the
GEMINI_* settings, the Docker login mount and checks, and updates the specs
and docs/llm_contexts.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-18 09:24:11 +09:00
parent 59c3f33c2c
commit af1276cf6b
26 changed files with 66 additions and 504 deletions

View File

@@ -2,7 +2,7 @@
Performs an internet search and returns text facts for the reply LLM to
ground its answer in. Provider order: the on-screen Chrome while the
broadcast is live, then Exa, then Gemini, then Brave (opt-in), then
broadcast is live, then Exa, then Brave (opt-in), then
Wikipedia, then an honest "found nothing" envelope. Used for any query that needs current,
external, or entity-specific information the assistant can't derive from
memory.
@@ -58,21 +58,15 @@ is visible on the Go-Live stream. `run()` reads the broadcast capability flag
Exa answered the field questions in Korean in 0.4 to 1.5 s with the
right pages and needs no page fetch of its own. Any failure (non-200,
error result, timeout, nothing parsed) moves on.
2. **Gemini**, only when Exa found nothing and only when it can work, with
the sub-mode chosen by `cfg.gemini_auth` (env `GEMINI_AUTH`, default `oauth`):
- `oauth`: `gemini_cli_search()` runs the Gemini CLI
(`gemini -p <query> -o json --skip-trust`, default approval mode) on the
user's Google-account login with its web-search grounding, and only when
`gemini_oauth_ready()` sees `~/.gemini/oauth_creds.json`. Without a login
the CLI is not started (it cost about 2 s per search, live 2026-11-18).
`GEMINI_API_KEY` / `GOOGLE_API_KEY` are stripped from the child env.
- `apikey`: `gemini_search()` REST path (`google_search` grounding), keyed
by `GEMINI_API_KEY` / `GEMINI_MODEL`.
3. **Brave Search** (opt-in, keyed), see the fallback chain below.
4. **Wikipedia** (zero-config), see the fallback chain below.
5. **Nothing-found envelope** when every provider failed.
2. **Brave Search** (opt-in, keyed), see the fallback chain below.
3. **Wikipedia** (zero-config), see the fallback chain below.
4. **Nothing-found envelope** when every provider failed.
Chrome, Exa and Gemini return the same fenced `UNTRUSTED WEB EXTRACT` shape.
Gemini (the Gemini CLI with a Google login, or the REST API with a key) was
removed 2026-11-18 at the user's request: nobody had it set up, and Exa then
Wikipedia cover the voice use.
Chrome and Exa return the same fenced `UNTRUSTED WEB EXTRACT` shape.
**Brave cascade fetch**: Brave gives links only, so the top 3 are fetched
**in parallel** under a single `_CASCADE_WALL_CLOCK_SEC` (8s) wall-clock cap.
@@ -161,11 +155,11 @@ a softer "please don't invent" lets chatty larger models wriggle past.
### Wall-clock budget
The whole provider chain (Exa + Gemini + Brave + Wikipedia) is capped by
The whole provider chain (Exa + Brave + Wikipedia) is capped by
`_TOTAL_WALL_CLOCK_SEC` (20s). Each cascade is further bounded by
`_CASCADE_WALL_CLOCK_SEC` (8s) per fetch pool. Exa's request timeout
(8s) and Gemini's subprocess timeout shrink to the remaining budget. Before
Gemini, Brave and Wikipedia, the remaining budget is checked; if exhausted,
(8s) shrinks to the remaining budget. Before
Brave and Wikipedia, the remaining budget is checked; if exhausted,
the remaining providers are skipped and the nothing-found envelope is
emitted. This is
the ceiling that turns "every provider timed out" from a ~40s hang into
@@ -174,7 +168,7 @@ is not negotiable.
### Fallback chain
When Exa and Gemini yield nothing, the tool walks a fallback chain before
When Exa yields nothing, the tool walks a fallback chain before
giving up:
1. **Brave Search** (opt-in, keyed). Runs only when
@@ -255,7 +249,6 @@ default.
message and does not hit the network.
- `brave_search_api_key` (str, default `""`): opt-in Brave key. Empty
string means "not configured" — the tool skips straight to Wikipedia.
- `gemini_auth` / `gemini_api_key` / `gemini_model`: the Gemini step (above).
- `wikipedia_fallback_enabled` (bool, default `true`): zero-config last
resort. Set to `false` to disable the Wikipedia network call entirely.
@@ -264,9 +257,8 @@ default.
Regression tests (`tests/tools/builtin/test_web_search.py`,
`tests/test_web_search_broadcast_routing.py`, `evals/test_web_search_fallback.py`) assert:
1. **Order**: live broadcast -> Chrome; otherwise Exa first; Gemini only when
Exa found nothing and a login (oauth) or key (apikey) is present; then
Brave, then Wikipedia, then the nothing-found envelope.
1. **Order**: live broadcast -> Chrome; otherwise Exa first; when Exa found
nothing, Brave, then Wikipedia, then the nothing-found envelope.
2. **Exa parsing**: the `---`-separated Title/URL/Highlights format, UTF-8
decoding of a charset-less event stream, and `[]` on non-200, an error
result or an exception.
@@ -289,8 +281,9 @@ Regression tests (`tests/tools/builtin/test_web_search.py`,
### Non-goals
- Unbounded provider plurality — the chain is scoped to Chrome (live
broadcast) → Exa → Gemini → Brave (opt-in) → Wikipedia. DuckDuckGo was
removed 2026-11-18 (bot-check page on every request); a user-pluggable
broadcast) → Exa → Brave (opt-in) → Wikipedia. DuckDuckGo was
removed 2026-11-18 (bot-check page on every request) and Gemini the same
day (user's request); a user-pluggable
provider registry is out of scope.
- JS rendering — we fetch raw HTML only. SPA-heavy pages may return
nothing useful; the cascade handles this by trying the next result.