Skip to content

search: Gemini Google Search grounding provider (Wave 3) - #82

Merged
FMXExpress merged 1 commit into
mainfrom
claude/web-search-wave3-gemini
May 30, 2026
Merged

FMXExpress merged 1 commit into
mainfrom
claude/web-search-wave3-gemini

Conversation

@FMXExpress

Copy link
Copy Markdown
Owner

Sixth and (per the maintainer call) final port from picoclaw's web-search lineup. Gemini isn't a traditional search endpoint — it's the Gemini LLM with google_search as an enabled tool, so the API returns a synthesised answer plus the source URLs the model consulted. The adapter folds that into ISearchProvider's uniform shape the same way Perplexity does:

  • Hits[0] — Title="Gemini summary", URL= first grounding URL if any, Snippet= answer text truncated to 1200 chars.
  • Hits[1..] — remaining groundingChunks[].web entries with real {title, uri} pairs Gemini supplies (unlike Perplexity which returns bare URLs).

Caps total hits at the caller's count.

PasClaw.Search.Gemini

POST https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent?key=<api-key>
{ "contents":[{"parts":[{"text":Q}]}], "tools":[{"google_search":{}}] }

Model hardcoded to gemini-1.5-flash — free-tier-friendly, supports google_search grounding, fast. Switching to 1.5-pro or 2.0-flash is a one-constant patch; not adding a config field for one provider.

Response parsing has two helpers:

Helper What it does
ExtractAnswer Walks candidates[0].content.parts[].text and concatenates non-empty pieces.
ExtractGroundingURLs Walks candidates[0].groundingMetadata.groundingChunks[].web → fills parallel Titles/URLs arrays up to their declared length. Drops chunks with no uri.

Factory + env

Two case branches under one if — gemini or google_search both map to the Gemini provider, picoclaw uses the longer label and either works here. Env probe reads $PASCLAW_GEMINI_API_KEY first, then falls back to $PASCLAW_GOOGLE_API_KEY (some users already have the Google-branded var set from gcloud / AI Studio defaults).

README

  • Env-var table picks up PASCLAW_GEMINI_API_KEY (with the _GOOGLE_API_KEY note).
  • Provider table grows a sixth row explaining the google_search-grounding shape.
  • Repo-layout search/ line spells out the full set of six providers.

Verification

  • make — clean build under FPC 3.2.2.
  • pasclaw status and --help byte-identical.

What's next

Closes the picoclaw web-search catch-up at six providers. Maintainer skipped GLM (Zhipu) and Baidu (Qianfan) — narrower Delphi/FPC audience for the Chinese-ecosystem auth ceremonies; can land later if anyone shows up wanting them.

PR ordering

This branch stacks on PR #81 (Wave 2 — SearXNG + Perplexity) so the factory case ladder lands in one coherent shape rather than fighting textual conflicts. Please merge #81 first; this PR's base will auto-retarget to main after that.

https://claude.ai/code/session_01TBcLtmpj7dqA5tyFbGnQon


Generated by Claude Code

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3a2fc1c8a3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

PasClaw.Providers.HTTP;

const
GEMINI_MODEL = 'gemini-1.5-flash';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Use the legacy grounding tool with 1.5 Flash

With GEMINI_MODEL hardcoded to gemini-1.5-flash, the request body below enables the google_search tool, but Google's grounding docs show Gemini 1.5 REST requests using the legacy google_search_retrieval field and reserve google_search for Gemini 2.0+ models. In the default configuration this provider will send an invalid tool payload and fail instead of returning search results; either switch the default model to a 2.0+/2.5 model or emit the 1.5-specific tool shape.

Useful? React with 👍 / 👎.


if (Kind = 'gemini') or (Kind = 'google_search') then
begin
Key := PickKey(Cfg.WebSearch.APIKey, 'PASCLAW_GEMINI_API_KEY');

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Honor PASCLAW_GOOGLE_API_KEY before config

For Gemini, PickKey returns Cfg.WebSearch.APIKey before this branch ever checks PASCLAW_GOOGLE_API_KEY, so a user with any api_key in config cannot override it with the Google-branded env var despite the new README documenting that either Gemini env var overrides api_key. This matters when rotating secrets or keeping a stale placeholder in config: PASCLAW_GOOGLE_API_KEY is silently ignored unless the config key is empty.

Useful? React with 👍 / 👎.

Sixth and (per the maintainer call) final port from picoclaw's
web-search lineup. Gemini isn't a traditional search endpoint — it's
the Gemini LLM with google_search as an enabled tool, so the API
returns a synthesised answer plus the source URLs the model
consulted. The adapter folds that into ISearchProvider's uniform
shape the same way Perplexity does:

  Hits[0]   = the synthesised answer (title="Gemini summary",
              URL=first grounding URL if any, snippet=text truncated
              to 1200 chars).
  Hits[1..] = remaining groundingChunks[].web entries with real
              {title, uri} pairs Gemini supplies (unlike Perplexity
              which returns bare URLs).

Caps total hits at the caller's count.

PasClaw.Search.Gemini
  Endpoint: POST https://generativelanguage.googleapis.com/v1beta/
                 models/gemini-1.5-flash:generateContent?key=<api-key>
  Body:     { "contents":[{"parts":[{"text":Q}]}],
              "tools":[{"google_search":{}}] }
  Model is hardcoded to gemini-1.5-flash — free-tier-friendly,
  supports google_search grounding, fast. Switching to 1.5-pro or
  2.0-flash is a one-constant patch; we don't add another config
  field for one provider.

  Response parsing has two helpers:
    ExtractAnswer        walks candidates[0].content.parts[].text
                          and concatenates non-empty pieces.
    ExtractGroundingURLs walks candidates[0].groundingMetadata.
                          groundingChunks[].web → fills parallel
                          Titles/URLs arrays up to their declared
                          length. Drops chunks with no uri.

Factory
  Two case branches under one if — "gemini" or "google_search" both
  map to the Gemini provider, picoclaw uses the longer label and I
  want either to work. Reads $PASCLAW_GEMINI_API_KEY first, then
  $PASCLAW_GOOGLE_API_KEY as a fallback (some users already have
  the Google-branded var set from gcloud / aistudio defaults
  rather than the explicit Gemini key name).

dproj DCCReference for the new unit. Makefile unchanged (channels
dir already on UNIT_DIRS).

README
  env-var table picks up PASCLAW_GEMINI_API_KEY (with note that
  PASCLAW_GOOGLE_API_KEY works too). Provider table grows a sixth
  row explaining the google_search-grounding shape. Repo-layout
  search/ line spells out the full set of six providers.

Verified locally:
  make builds clean under FPC 3.2.2.
  pasclaw status / --help byte-identical.

Closes the picoclaw web-search catch-up. Maintainer skipped GLM
(Zhipu) and Baidu (Qianfan) — narrower Delphi/FPC audience for the
Chinese-ecosystem auth ceremonies; can land later if anyone shows
up wanting them.

PR ordering: this stacks on PR #81 (Wave 2 — SearXNG + Perplexity)
so the factory case ladder lands in one coherent shape rather than
fighting textual conflicts. Merge #81 first.

https://claude.ai/code/session_01TBcLtmpj7dqA5tyFbGnQon
@FMXExpress
FMXExpress force-pushed the claude/web-search-wave3-gemini branch from 3a2fc1c to 3f1e8af Compare May 30, 2026 00:22
@FMXExpress
FMXExpress changed the base branch from claude/web-search-wave2 to main May 30, 2026 00:23
@FMXExpress
FMXExpress merged commit f12c372 into main May 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants