Skip to content

fix(go-agent): add Google search wrapper component and tool registry - #16768

Merged
yuzhichang merged 6 commits into
infiniflow:mainfrom
Harry-Hz-Zhang:fix/agent-google
Jul 9, 2026
Merged

yuzhichang merged 6 commits into
infiniflow:mainfrom
Harry-Hz-Zhang:fix/agent-google

Conversation

@Harry-Hz-Zhang

Copy link
Copy Markdown
Contributor

Summary

  • Implemented googleComponent wrapper to bridge the canvas component contract with Eino's SerpApi-backed GoogleTool.
  • Added parameter alias mapping (query to q, max_results to num) and content formatting logic to match Python search result representation.
  • Registered the "Google" component and the "google" tool factory in the Go agent runtime to support web search nodes.
image

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. 💞 feature Feature request, pull request that fullfill a new feature. labels Jul 9, 2026
@Harry-Hz-Zhang Harry-Hz-Zhang added 🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration labels Jul 9, 2026
@coderabbitai

coderabbitai Bot commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7521fab7-6fe6-4ce5-b7ad-599816d90f99

📥 Commits

Reviewing files that changed from the base of the PR and between a50fd63 and 6d0af6d.

📒 Files selected for processing (6)
  • internal/agent/component/fixture_stubs.go
  • internal/agent/component/universe_a_wrappers.go
  • internal/agent/component/verify_p1_test.go
  • internal/agent/tool/google.go
  • internal/agent/tool/google_test.go
  • internal/agent/tool/registry.go
🚧 Files skipped from review as they are similar to previous changes (4)
  • internal/agent/component/fixture_stubs.go
  • internal/agent/tool/registry.go
  • internal/agent/tool/google_test.go
  • internal/agent/component/universe_a_wrappers.go

📝 Walkthrough

Walkthrough

The Google tool now uses SerpApi with updated inputs, defaults, and result parsing. A new Google component wrapper and registry path wire it into canvas and agent tool loading, with tests updated for the new contract.

Changes

Google Tool SerpApi Migration and Component Wiring

Layer / File(s) Summary
Google tool SerpApi request/response rewrite
internal/agent/tool/google.go
Replaces CSE-oriented modeling with SerpApi request building, defaults merging, InputForm(), and organic_results-to-results output mapping.
Registry construction for Google tool
internal/agent/tool/registry.go
Switches the "google" registry entry to a param-aware builder that validates allowed keys and constructs the tool with node-level defaults.
Google component wrapper and canvas wiring
internal/agent/component/universe_a_wrappers.go, internal/agent/component/fixture_stubs.go
Adds googleComponent wrapping agenttool.GoogleTool, normalizing outputs and structured errors; registers the component under "Google" and adds interface assertions.
Tests for Google tool, component, and registration counts
internal/agent/tool/google_test.go, internal/agent/component/google_component_test.go, internal/agent/component/tool_dispatch_test.go, internal/agent/component/verify_p1_test.go
Updates and adds tests for URL building, parsing, input forms, defaults, component wiring, DSL param loading, and the expanded P1 registration count range.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Suggested reviewers: yuzhichang

Poem

A rabbit hopped through search and code,
Swapped CSE for SerpApi road 🐰
With q and api_key in tow,
The canvas now knows how to show.
Hooray, the burrow’s search is bright!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 9.52% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding the Google wrapper component and registry support.
Description check ✅ Passed The description includes the required Summary section and clearly describes the main implementation and registry changes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Harry-Hz-Zhang
Harry-Hz-Zhang marked this pull request as draft July 9, 2026 03:53
@Harry-Hz-Zhang
Harry-Hz-Zhang marked this pull request as ready for review July 9, 2026 03:53

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (1)
internal/agent/component/universe_a_wrappers.go (1)

122-124: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low value

GetInputForm allocates a new GoogleTool unnecessarily.

c.inner is already a *agenttool.GoogleTool and InputForm doesn't depend on tool state. Use c.inner.InputForm() to avoid the extra allocation.

♻️ Proposed fix
 func (c *googleComponent) GetInputForm() map[string]any {
-	return agenttool.NewGoogleTool().InputForm()
+	return c.inner.InputForm()
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/agent/component/universe_a_wrappers.go` around lines 122 - 124,
`googleComponent.GetInputForm` is creating a fresh `GoogleTool` instead of using
the existing wrapped instance. Update `GetInputForm` to call
`c.inner.InputForm()` directly on the `googleComponent` wrapper so it reuses the
already-constructed `agenttool.GoogleTool` and avoids the extra allocation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/agent/component/universe_a_wrappers.go`:
- Around line 94-95: The doc comment on googleComponent still references Python
migration history and should be rewritten to describe the current runtime
behavior only. Update the comment above googleComponent to explain its role as a
wrapper around internal/agent/tool/GoogleTool and how it adapts Google tool
outputs for the active canvas flow, removing any mention of Python or migration
context.

In `@internal/agent/tool/google.go`:
- Around line 104-108: The `num` default is inconsistent across `Info`,
`InputForm`, and `buildGoogleURL`; align them to a single value, preferably 6 as
the code already uses. Update the `Info` description in `google.go`, the
`InputForm` default value for `num`, and the fallback in `buildGoogleURL` so all
three references match and the UI, documentation, and runtime behavior are
consistent.
- Around line 36-38: The doc comments on googleParams and
GoogleParam.get_input_form still reference Python migration history instead of
the Go runtime path. Update those comments in the google tool code to describe
the current Go-facing JSON/input behavior only, keeping the explanation aligned
with InvokableRun and the accepted aliases without mentioning Python or
migration origins.
- Around line 214-239: `mergeGoogleDefaults` is applying defaults to primary
fields before alias values are normalized, which can override explicit agent
input from `MaxResults`/`Query`. Update the merge flow in `mergeGoogleDefaults`
so alias fields are resolved first in `googleParams` (for example, prefer
`MaxResults` over `Num` and `Query` over `Q` when provided), then fill only
still-empty primary fields from defaults. Make sure `buildGoogleURL` continues
to read the normalized primary fields after this change so agent-supplied values
always take precedence.

---

Nitpick comments:
In `@internal/agent/component/universe_a_wrappers.go`:
- Around line 122-124: `googleComponent.GetInputForm` is creating a fresh
`GoogleTool` instead of using the existing wrapped instance. Update
`GetInputForm` to call `c.inner.InputForm()` directly on the `googleComponent`
wrapper so it reuses the already-constructed `agenttool.GoogleTool` and avoids
the extra allocation.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b7939102-26e0-4864-b781-d326fb5f8831

📥 Commits

Reviewing files that changed from the base of the PR and between ae96e63 and 26f00e5.

📒 Files selected for processing (8)
  • internal/agent/component/fixture_stubs.go
  • internal/agent/component/google_component_test.go
  • internal/agent/component/tool_dispatch_test.go
  • internal/agent/component/universe_a_wrappers.go
  • internal/agent/component/verify_p1_test.go
  • internal/agent/tool/google.go
  • internal/agent/tool/google_test.go
  • internal/agent/tool/registry.go

Comment thread internal/agent/tool/google.go Resolved
Comment thread internal/agent/tool/google.go Resolved
Comment thread internal/agent/tool/google.go Resolved
@Harry-Hz-Zhang
Harry-Hz-Zhang requested a review from yuzhichang July 9, 2026 05:06
@yuzhichang
yuzhichang merged commit 5c8b51c into infiniflow:main Jul 9, 2026
3 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Jul 15, 2026
2 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration 💞 feature Feature request, pull request that fullfill a new feature. size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants