feat(google): native Google Search grounding on the v2026.5.22 train#6
Conversation
The one-shot release workflow referenced scripts/build-all.mjs, which does not exist (run 30116666722 failed on it); the fork builds with pnpm build + pnpm ui:build. Release notes were also hardcoded to an old fix — now a dispatch input. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ROUNDING Port of main's PR #4 onto the v2026.5.22 release train (the transport lives in extensions/google here). Env-gated google_search injection with includeServerSideToolInvocations, groundingMetadata normalized onto the assistant message as webGrounding (sources ranked by citation count), a 'grounding' agent event at message end, and a content-free delta.dojo_grounding chunk on the OpenAI-compat endpoint. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
💬 Review Comments
Comments — 0 blockers, 1 P2, 1 P3. Confidence: 3.60/5.00.
Walkthrough
Walkthrough
This PR introduces native Google Search grounding for the Gemini model transport on the v2026.5.22 train. It normalizes Google's grounding metadata onto the assistant message and surfaces it via a new grounding event stream so that clients (like the Dojo web-chat proxy) can display cited sources.
Reviewed Areas
I reviewed extensions/google/transport-stream.ts, src/agents/pi-embedded-subscribe.handlers.messages.ts, src/gateway/openai-http.ts, and .github/workflows/cut-dojo-tarball.yml.
Safety Rationale
The changes are safely guarded behind the OPENCLAW_GOOGLE_GROUNDING feature flag and do not alter the main execution path when disabled.
Verdict
Changes suggested — 0 blockers, 1 P2, 1 P3.
🟡 P2 — Major
.github/workflows/cut-dojo-tarball.yml:42— 🟡 P2 (major) — Shell injection and quoting vulnerability in workflow dispatch script.
Expanding workflow inputs directly via ${{ inputs.tag }} and ${{ inputs.notes }} inside inline shell scripts creates a potential script injection vector if special characters or quotes are included in the inputs. It also causes the step to fail with syntax errors if the notes contain double quotes.
Passing these inputs as environment variables securely prevents shell expansion and ensures quoting reliability.
[pass 1]
🔵 P3 — Minor
extensions/google/transport-stream.ts:719— 🔵 P3 (minor) — Potential duplication and inflated citation counts during streaming re-entries.
If mergeWebGrounding is called multiple times across successive chunks in the stream (which can happen if multiple chunks contain the groundingMetadata block), the current logic will repeatedly find and append queries and add to existing.cited counts, causing citation numbers to inflate.
Since the metadata object from Gemini represents the complete state of search grounding rather than an incremental delta, we can avoid state-tracking bugs by completely overwriting output.webGrounding with a fresh object constructed from the latest metadata on each invocation.
[pass 1]
Total findings: 1 compliance, 1 business context (2 total)
| - name: Publish release | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| run: | |
There was a problem hiding this comment.
🟡 P2 (major) — Shell injection and quoting vulnerability in workflow dispatch script.
Expanding workflow inputs directly via ${{ inputs.tag }} and ${{ inputs.notes }} inside inline shell scripts creates a potential script injection vector if special characters or quotes are included in the inputs. It also causes the step to fail with syntax errors if the notes contain double quotes.
Passing these inputs as environment variables securely prevents shell expansion and ensures quoting reliability.
[pass 1]
| * `functionDeclarations` additionally requires | ||
| * `toolConfig.includeServerSideToolInvocations` (the API 400s without it). | ||
| * The resulting `groundingMetadata` is normalized onto the assistant output | ||
| * as `webGrounding`. |
There was a problem hiding this comment.
🔵 P3 (minor) — Potential duplication and inflated citation counts during streaming re-entries.
If mergeWebGrounding is called multiple times across successive chunks in the stream (which can happen if multiple chunks contain the groundingMetadata block), the current logic will repeatedly find and append queries and add to existing.cited counts, causing citation numbers to inflate.
Since the metadata object from Gemini represents the complete state of search grounding rather than an incremental delta, we can avoid state-tracking bugs by completely overwriting output.webGrounding with a fresh object constructed from the latest metadata on each invocation.
[pass 1]
|
CI triage — none of the reds touch this diff (3 files:
53 checks green including OpenGrep PR-diff. Merging to keep the v2026.5.22 tarball train moving. |
Port of #4 (merged to main) onto
dojo/v2026.5.22-fixes— the branch the production tarball is actually cut from (main's package version regressed to 2026.4.6 and its tarball fails plugin install on a missing@slack/web-api; dispatch run 30116666722/30117462878 evidence). The transport here lives inextensions/google/transport-stream.ts.Also carries the
cut-dojo-tarball.ymlworkflow (+ its build-script fix from #5) so the tarball can be cut from this ref.extensions/google/transport-stream.test.ts: 50/50 green with the change.Created by Claude Code on behalf of @StevenMendez
🤖 Generated with Claude Code