Skip to content

refactor(go-agent): unify tool-backed canvas components - #16912

Merged
yuzhichang merged 6 commits into
infiniflow:mainfrom
Harry-Hz-Zhang:refact/tool-component
Jul 15, 2026
Merged

yuzhichang merged 6 commits into
infiniflow:mainfrom
Harry-Hz-Zhang:refact/tool-component

Conversation

@Harry-Hz-Zhang

@Harry-Hz-Zhang Harry-Hz-Zhang commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR consolidates Eino-backed Agent tools behind the shared ToolBackedComponent implementation and aligns their Canvas configuration,
runtime inputs, output conversion, validation, and registration.

What changed

  • Migrated these Canvas components to the unified tool-backed path:

    • Tavily Search and Extract
    • Execute SQL
    • Google
    • Yahoo Finance
    • Email
    • DuckDuckGo
    • Wikipedia
    • Google Scholar
    • ArXiv
    • PubMed
    • BGPT
    • GitHub
    • WenCai
    • SearXNG
    • Keenable Search
  • Removed superseded component wrappers and their duplicate tests.

  • Added dedicated registry builders for node-level configuration and validation.

  • Kept model-emitted runtime inputs separate from Canvas node configuration.

  • Moved Email defaults, template resolution, recipient parsing, SMTP execution, and output conversion into the owning tool.

  • Added complete ToolComponent specifications for Canvas inputs, outputs, and input forms.

  • Preserved raw upstream fields where downstream workflows may depend on them.

  • Added workflow registration coverage for all migrated component names.

  • Kept HTTP Request, Docs Generator, and Browser as standalone components because they are not Eino-backed tools.

Testing

Passed:

bash build.sh --test ./internal/agent/tool/...
bash build.sh --test ./internal/agent/component/...
bash build.sh --test ./internal/agent/runtime/...

image image image

@dosubot dosubot Bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Jul 14, 2026
@Harry-Hz-Zhang Harry-Hz-Zhang added ci Continue Integration ☯️ refactor Pull request that refactor/refine code labels Jul 14, 2026
@coderabbitai

coderabbitai Bot commented Jul 14, 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: e2ecd196-2fce-4946-a872-7517f43b0f47

📥 Commits

Reviewing files that changed from the base of the PR and between c4ae8e1 and 9b14739.

📒 Files selected for processing (11)
  • internal/agent/tool/google_scholar.go
  • internal/agent/tool/google_scholar_test.go
  • internal/agent/tool/registry.go
  • internal/agent/tool/searxng.go
  • internal/agent/tool/searxng_test.go
  • internal/agent/tool/tavily.go
  • internal/agent/tool/tavily_test.go
  • internal/agent/tool/wikipedia.go
  • internal/agent/tool/wikipedia_test.go
  • internal/agent/tool/yahoo_finance.go
  • internal/agent/tool/yahoo_finance_test.go
🚧 Files skipped from review as they are similar to previous changes (8)
  • internal/agent/tool/searxng_test.go
  • internal/agent/tool/google_scholar.go
  • internal/agent/tool/wikipedia.go
  • internal/agent/tool/searxng.go
  • internal/agent/tool/yahoo_finance_test.go
  • internal/agent/tool/google_scholar_test.go
  • internal/agent/tool/tavily.go
  • internal/agent/tool/registry.go

📝 Walkthrough

Walkthrough

Tool-backed Canvas integration adds shared tool contracts, reusable adapters, parameter-aware registry builders, and Canvas output/reference handling across multiple tools. Legacy bespoke wrappers and broad fixture registrations are removed or narrowed.

Changes

Tool-backed Canvas integration

Layer / File(s) Summary
Tool contracts and adapter execution
internal/agent/tool/tool2component.go, internal/agent/component/tool_component.go, internal/agent/component/tool_component_test.go
Defines shared contracts and routes registered tools through ToolBackedComponent, including invocation, output conversion, retrieval state updates, error handling, and workflow tests.
Tool contracts and result adaptation
internal/agent/tool/*.go, internal/agent/tool/*_test.go
Adds Canvas specifications, default merging, empty-query handling, generic result preservation, deterministic references, token-limited formatted content, and component output builders.
Parameter-aware registry builders
internal/agent/tool/registry.go, internal/agent/tool/registry_test.go
Adds typed node-parameter builders and validation, accepts Canvas-shaped parameters, and updates canonical tool aliases.
Component registry consolidation
internal/agent/component/fixture_stubs.go, internal/agent/component/universe_a_wrappers.go, internal/agent/component/production_chain_fixes_test.go, internal/agent/component/email.go
Removes bespoke production-backed component wrappers and tests, narrows fixture registrations, and updates retrieval dataset resolution and retained component checks.

Estimated code review effort: 5 (Critical) | ~120 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Canvas
  participant ToolBackedComponent
  participant Tool
  participant CanvasState
  Canvas->>ToolBackedComponent: Invoke component inputs
  ToolBackedComponent->>Tool: Run JSON arguments
  Tool-->>ToolBackedComponent: Return results envelope
  ToolBackedComponent->>Tool: Build references and component outputs
  ToolBackedComponent->>CanvasState: Record retrieval chunks
  ToolBackedComponent-->>Canvas: Return json and formalized_content
Loading

Possibly related PRs

  • infiniflow/ragflow#16849: Directly overlaps with the GitHub component implementation and registration replaced by the tool-backed adapter.
  • infiniflow/ragflow#16854: Directly overlaps with the removed SearXNG component wiring and tests.
  • infiniflow/ragflow#16895: Touches the same email implementation while this change updates its parameter and component contract.

Suggested reviewers: yuzhichang

Poem

A rabbit wires each tool in line,
Canvas outputs hop and shine.
Search chunks gather, neat and bright,
Empty queries rest light.
Old wrappers fade into the snow. 🐇

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.27% 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 is concise and accurately summarizes the main change: unifying tool-backed Canvas components.
Description check ✅ Passed The description includes a clear summary, changed areas, and testing notes, which satisfies the repo template well.
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.

@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: 1

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

778-790: 🔒 Security & Privacy | 🔵 Trivial | 💤 Low value

Static analysis flags sha1.Sum (CWE-327) — likely a non-issue here, but consider a non-crypto hash.

keenableHashInt uses SHA-1 purely to derive a deterministic numeric ID from content (not for integrity/auth), so this isn't exploitable in the way CWE-327 usually implies. That said, using hash/fnv or sha256 instead would satisfy the scanner and better signal intent (non-cryptographic ID derivation) to future readers.

♻️ Non-cryptographic hash alternative
-func keenableHashInt(value string, modulus int64) int64 {
-	sum := sha1.Sum([]byte(value))
-	number := new(big.Int).SetBytes(sum[:])
-	return new(big.Int).Mod(number, big.NewInt(modulus)).Int64()
-}
+func keenableHashInt(value string, modulus int64) int64 {
+	h := fnv.New64a()
+	_, _ = h.Write([]byte(value))
+	return int64(h.Sum64() % uint64(modulus))
+}
🤖 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 778 - 790,
Replace the SHA-1 usage in keenableHashInt with a non-cryptographic
deterministic hash such as hash/fnv, while preserving the function’s
string-to-modulus int64 behavior and handling the existing modulus calculation
consistently.

Source: Linters/SAST tools


725-732: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Extract the shared hash/truncation helper

keenableHashInt and truncateKeenableRunes are byte-for-byte the same as githubHashInt and truncateGitHubRunes in internal/agent/tool/github.go. Pull them into a shared internal utility so the two reference builders stay in sync.

🤖 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 725 - 732,
Extract the duplicated keenableHashInt and truncateKeenableRunes implementations
into a shared internal utility, then update both the Keenable reference builder
and the GitHub code using githubHashInt and truncateGitHubRunes to call the
shared helpers. Preserve the existing hashing and rune-truncation behavior and
remove the duplicate local definitions.
internal/agent/tool/github_test.go (1)

255-263: 🎯 Functional Correctness | 🔵 Trivial

Boundary test doesn't verify which chunk was kept.

TestGitHub_LimitReferencesKeepsBoundaryChunk only checks len(limited) == 1, not that the retained chunk is actually the boundary (first) one, despite the test name's implication.

🧪 Strengthen the assertion
 	limited := limitGitHubReferences(chunks, 1)
 	if len(limited) != 1 {
 		t.Fatalf("limited chunks = %d, want 1", len(limited))
 	}
+	if limited[0]["content"] != "first repository description" {
+		t.Fatalf("limited chunk = %#v, want the boundary (first) chunk", limited[0])
+	}
🤖 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/tool/github_test.go` around lines 255 - 263, Strengthen
TestGitHub_LimitReferencesKeepsBoundaryChunk by asserting that the retained
element in limited is the first repository description, not just that the result
length is one. Keep the existing length assertion and verify the retained
chunk’s content directly.
🤖 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/tool/github_test.go`:
- Around line 222-253: Remove the pre-processing private-field assertion in
TestGitHub_ReferencesAndOutputsPreserveRawResults and validate results after
BuildReferences and BuildComponentOutputs have run. Assert that the JSON output
preserves the repository’s private field, while keeping the existing reference
and rendered-content checks intact.

---

Nitpick comments:
In `@internal/agent/component/universe_a_wrappers.go`:
- Around line 778-790: Replace the SHA-1 usage in keenableHashInt with a
non-cryptographic deterministic hash such as hash/fnv, while preserving the
function’s string-to-modulus int64 behavior and handling the existing modulus
calculation consistently.
- Around line 725-732: Extract the duplicated keenableHashInt and
truncateKeenableRunes implementations into a shared internal utility, then
update both the Keenable reference builder and the GitHub code using
githubHashInt and truncateGitHubRunes to call the shared helpers. Preserve the
existing hashing and rune-truncation behavior and remove the duplicate local
definitions.

In `@internal/agent/tool/github_test.go`:
- Around line 255-263: Strengthen TestGitHub_LimitReferencesKeepsBoundaryChunk
by asserting that the retained element in limited is the first repository
description, not just that the result length is one. Keep the existing length
assertion and verify the retained chunk’s content directly.
🪄 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: 0b2dfff7-ad2e-447c-9620-8b429f4d2bf4

📥 Commits

Reviewing files that changed from the base of the PR and between 26161ce and f2c7e5b.

📒 Files selected for processing (10)
  • internal/agent/component/fixture_stubs.go
  • internal/agent/component/github.go
  • internal/agent/component/github_test.go
  • internal/agent/component/tool_component.go
  • internal/agent/component/tool_component_test.go
  • internal/agent/component/universe_a_wrappers.go
  • internal/agent/tool/github.go
  • internal/agent/tool/github_test.go
  • internal/agent/tool/registry.go
  • internal/agent/tool/tool2component.go
💤 Files with no reviewable changes (4)
  • internal/agent/component/github_test.go
  • internal/agent/component/fixture_stubs.go
  • internal/agent/component/github.go
  • internal/agent/tool/registry.go

Comment thread internal/agent/tool/github_test.go Resolved

@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.

♻️ Duplicate comments (1)
internal/agent/tool/github_test.go (1)

231-250: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Dead assertion: repository["private"] check runs before any processing.

Lines 231-234 check repository["private"] != false on the manually constructed results map, before BuildReferences or BuildComponentOutputs are ever called. This can never fail and doesn't actually verify that "raw repository fields" survive the output-building pipeline.

Move the check to execute against the final outputs["json"] array.

🧪 Proposed fix to validate post-processing results
-	repository := results[0].(map[string]any)
-	if repository["private"] != false {
-		t.Fatalf("raw repository fields were lost: %#v", repository)
-	}
 	envelope := map[string]any{"results": results}
 
 	chunks, docAggs := github.BuildReferences(context.Background(), envelope)
 	if len(chunks) != 1 || len(docAggs) != 1 {
 		t.Fatalf("references = %#v / %#v", chunks, docAggs)
 	}
 	if chunks[0]["document_name"] != "ragflow" || chunks[0]["similarity"] != 1 {
 		t.Fatalf("reference metadata = %#v", chunks[0])
 	}
 	outputs := github.BuildComponentOutputs(envelope)
 	if _, exists := envelope["chunks"]; exists {
 		t.Fatalf("component output conversion mutated the tool envelope: %#v", envelope)
 	}
 	if results, ok := outputs["json"].([]any); !ok || len(results) != 1 {
 		t.Fatalf("component json output = %#v", outputs["json"])
 	}
+	if raw, ok := results[0].(map[string]any); !ok || raw["private"] != false {
+		t.Fatalf("raw repository fields were lost: %#v", results[0])
+	}
🤖 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/tool/github_test.go` around lines 231 - 250, Move the
repository["private"] preservation assertion from the initial results map to the
decoded results in outputs["json"] after BuildComponentOutputs returns. Validate
the final JSON array contains the repository entry and that its private field
remains false, while preserving the existing output-shape checks.
🤖 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.

Duplicate comments:
In `@internal/agent/tool/github_test.go`:
- Around line 231-250: Move the repository["private"] preservation assertion
from the initial results map to the decoded results in outputs["json"] after
BuildComponentOutputs returns. Validate the final JSON array contains the
repository entry and that its private field remains false, while preserving the
existing output-shape checks.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7e62736c-722c-4369-9afa-e667f1054db4

📥 Commits

Reviewing files that changed from the base of the PR and between f2c7e5b and 3654a9d.

📒 Files selected for processing (5)
  • internal/agent/component/tool_component.go
  • internal/agent/component/tool_component_test.go
  • internal/agent/tool/github.go
  • internal/agent/tool/github_test.go
  • internal/agent/tool/tool2component.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • internal/agent/component/tool_component.go

@dosubot dosubot Bot added size:XXL This PR changes 1000+ lines, ignoring generated files. and removed size:XL This PR changes 500-999 lines, ignoring generated files. labels Jul 15, 2026
@yuzhichang
yuzhichang self-requested a review July 15, 2026 06:53

@yuzhichang yuzhichang left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jul 15, 2026

@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: 16

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

62-90: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Assert the v1 parameter translation, not only the wrapper type.

Construction and the *ToolBackedComponent assertion do not prove the stated db_type, numeric port, or top_n → max_records behavior. Retain a focused assertion against the wrapped tool defaults or observable query-limit behavior.

As per coding guidelines, “Preserve valid behavior with focused tests, but remove tests that protect obsolete behavior.”

🤖 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/production_chain_fixes_test.go` around lines 62 -
90, Strengthen TestExeSQL_V1DSLParamsAccepted to verify the translated v1
parameters, not just successful construction and the ToolBackedComponent type.
Inspect the wrapped tool’s configuration or use an observable query-limit
behavior to assert the default db_type is mysql, float64 port 3306 is accepted
correctly, and top_n 50 becomes max_records 50; retain only assertions for
supported behavior.

Source: Coding guidelines

internal/agent/tool/arxiv.go (1)

297-386: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy lift

Consolidate the duplicated reference-building pipeline into one reusable adapter.

Both implementations repeat sanitization, truncation, deterministic IDs, chunk/document construction, newline normalization, and token-budget rendering.

  • internal/agent/tool/arxiv.go#L297-L386: replace the ArXiv-specific helper set with the shared adapter configured for summary, title, and pdf_url.
  • internal/agent/tool/wikipedia.go#L299-L375: replace the Wikipedia-specific helper set with the same adapter configured for content, title, and url.

As per coding guidelines, converge coexisting implementations to one path and remove duplicate code. <coding_guidelines>

🤖 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/tool/arxiv.go` around lines 297 - 386, Replace the
ArXiv-specific reference helpers around ArxivTool.BuildReferences and
BuildComponentOutputs in internal/agent/tool/arxiv.go:297-386 with the shared
reusable adapter, configured for summary, title, and pdf_url; remove the
duplicated sanitization, truncation, ID generation, chunk/document construction,
newline normalization, and token-budget rendering. Apply the same consolidation
in internal/agent/tool/wikipedia.go:299-375, configuring the adapter for
content, title, and url, so both tools use one reference-building path.

Source: Coding guidelines

internal/agent/tool/email.go (1)

45-46: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Remove migration-history wording from runtime comments.

Describe the current Go/Canvas contract directly rather than documenting Python parity.

  • internal/agent/tool/email.go#L45-L46: describe node configuration and invocation inputs without referencing Python.
  • internal/agent/tool/keenable.go#L66-L67: state that complete upstream objects are preserved for Canvas JSON.
  • internal/agent/tool/keenable.go#L72-L73: describe the current tool envelope.
  • internal/agent/tool/keenable.go#L311-L311: describe the Canvas surface directly.
  • internal/agent/tool/keenable.go#L335-L335: describe reference construction directly.
  • internal/agent/tool/tavily.go#L84-L85: describe raw-result preservation directly.
  • internal/agent/tool/tavily.go#L90-L91: describe the current envelope.
  • internal/agent/tool/tavily.go#L580-L580: describe the Canvas surface directly.

As per coding guidelines, “Do not add compatibility wording to comments or documentation.”

🤖 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/tool/email.go` around lines 45 - 46, Replace migration-history
and Python-parity wording in the runtime comments. In
internal/agent/tool/email.go lines 45-46, describe node configuration and
invocation inputs; in internal/agent/tool/keenable.go lines 66-67, 72-73, 311,
and 335, describe preserved upstream objects, the current tool envelope, the
Canvas surface, and reference construction directly; in
internal/agent/tool/tavily.go lines 84-85, 90-91, and 580, describe raw-result
preservation, the current envelope, and the Canvas surface directly. Do not add
compatibility wording.

Source: Coding guidelines

🤖 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/fixture_stubs.go`:
- Around line 17-23: Update the package documentation near the component
registry to list only the registered entries: Retrieval aliases, CodeExec,
Generate, Answer, Iteration, and IterationItem. Clearly distinguish production
TavilySearch and ExeSQL as direct-only test constructors, and remove the stale
claim that they are registered.

In `@internal/agent/component/universe_a_wrappers.go`:
- Around line 342-378: Update the logging calls in the tenant and user lookup
branches around GetKBByNameAndUserID to stop emitting raw tenantID, userID,
kbName, and kb.ID values. Remove those identifier fields or replace them with
the project’s established redacted/correlation-value helper, while preserving
the existing debug and warning messages and error logging.
- Around line 359-369: Update the dataset-resolution flow around
GetKBByNameAndUserID and its DAO implementation to filter for StatusValid before
applying the single-result limit, then reject or deterministically select among
multiple valid matches instead of relying on unordered results. Preserve the
existing user-visibility checks and return behavior in the surrounding
resolution logic.

In `@internal/agent/tool/bgpt.go`:
- Around line 295-309: Update renderBGPTReferences to calculate each reference
block’s token cost before appending it, and stop when adding that block would
exceed the reserved maxTokens budget. Preserve the existing 97% threshold and
return already-accepted blocks without including the over-budget reference.

In `@internal/agent/tool/email.go`:
- Around line 48-57: Update the email construction and sending flow to use
ToEmail only for the To header and CCEmail only for the CC header, and include
SenderName when formatting the From header. Keep a combined ToEmail/CCEmail
recipient list only for SMTP envelope recipients (RCPT TO), preserving distinct
message headers.
- Around line 237-242: Update the SMTP flow around client.Extension("STARTTLS")
to fail immediately when STARTTLS is not advertised, returning an appropriate
error instead of proceeding to submitEmail. Preserve the existing StartTLS
negotiation and error propagation when the extension is available, and only call
submitEmail after successful TLS setup.

In `@internal/agent/tool/exesql.go`:
- Around line 362-392: Update BuildComponentOutputs to preserve multi-row
results as the rows array rather than wrapping it in an extra array, while
retaining the single-row content object shortcut only when exactly one row
exists. In renderExeSQLMarkdown, apply the content shortcut only for a
single-row input; render all rows normally when multiple rows are present. Add a
regression case covering at least two rows.

In `@internal/agent/tool/google.go`:
- Around line 139-154: The GoogleTool ComponentSpec metadata is missing form
definitions for the declared api_key, country, and language inputs. Update
GoogleTool.InputForm() to include entries for all three fields, marking api_key
as secret, while preserving the existing form metadata for q, start, and num.
- Around line 300-317: Update renderGoogleReferences so each fully formatted
reference block is constructed and token-counted before being appended to
blocks. Include the ID, title, URL, content, and formatting in the prospective
token count, and stop before appending when maxTokens would be exceeded while
preserving the existing maxTokens <= 0 behavior.

In `@internal/agent/tool/keenable_test.go`:
- Line 210: Remove the migration-history comment above
TestKeenable_MissingQuery, leaving the test name and assertions unchanged.

In `@internal/agent/tool/registry.go`:
- Around line 309-322: Update the Google Scholar parameter validation around
year_low and year_high to reject configurations where both bounds are set and
defaults.YearLow exceeds defaults.YearHigh. Return a validation error consistent
with the existing positive-integer checks while preserving valid and partially
specified ranges.

In `@internal/agent/tool/tavily_test.go`:
- Around line 475-508: Update TestTavilyExtract_UsesNodeDefaults to synchronize
request capture: have the httptest handler send gotAuth and the decoded request
body through a buffered channel, then receive the captured values before
asserting them. Remove direct unsynchronized reads of handler-written variables
while preserving the existing authorization and body assertions.

In `@internal/agent/tool/tavily.go`:
- Around line 368-373: Update the request construction near the include flag
handling so the merged values from params.IncludeRawContent and
params.IncludeImages are sent instead of hardcoded false values. Preserve
explicit runtime and node-provided settings, and remove any now-unnecessary
compatibility handling only if these parameters are intentionally unsupported.
- Around line 291-296: Update the empty-query check in the Tavily parameter flow
around mergeTavilyParams to use strings.TrimSpace(p.Query) == "" so
whitespace-only queries return the existing empty tavily envelope without
calling the external API.

In `@internal/agent/tool/wikipedia.go`:
- Line 205: Update the Results JSON tag on wikipediaEnvelope so an empty slice
is serialized as results: [] instead of being omitted by omitempty. Preserve the
empty-query return in wikipediaJSON, and update its test to assert the raw
response includes the results key.

In `@internal/agent/tool/yahoo_finance.go`:
- Around line 44-48: Check yahooFinanceResponse.QuoteResponse.Error in the Yahoo
Finance response handling before processing the result or returning success.
When the error object is present, propagate it as a failure instead of treating
the empty result as successful; preserve the existing successful path when no
error is returned.

---

Nitpick comments:
In `@internal/agent/component/production_chain_fixes_test.go`:
- Around line 62-90: Strengthen TestExeSQL_V1DSLParamsAccepted to verify the
translated v1 parameters, not just successful construction and the
ToolBackedComponent type. Inspect the wrapped tool’s configuration or use an
observable query-limit behavior to assert the default db_type is mysql, float64
port 3306 is accepted correctly, and top_n 50 becomes max_records 50; retain
only assertions for supported behavior.

In `@internal/agent/tool/arxiv.go`:
- Around line 297-386: Replace the ArXiv-specific reference helpers around
ArxivTool.BuildReferences and BuildComponentOutputs in
internal/agent/tool/arxiv.go:297-386 with the shared reusable adapter,
configured for summary, title, and pdf_url; remove the duplicated sanitization,
truncation, ID generation, chunk/document construction, newline normalization,
and token-budget rendering. Apply the same consolidation in
internal/agent/tool/wikipedia.go:299-375, configuring the adapter for content,
title, and url, so both tools use one reference-building path.

In `@internal/agent/tool/email.go`:
- Around line 45-46: Replace migration-history and Python-parity wording in the
runtime comments. In internal/agent/tool/email.go lines 45-46, describe node
configuration and invocation inputs; in internal/agent/tool/keenable.go lines
66-67, 72-73, 311, and 335, describe preserved upstream objects, the current
tool envelope, the Canvas surface, and reference construction directly; in
internal/agent/tool/tavily.go lines 84-85, 90-91, and 580, describe raw-result
preservation, the current envelope, and the Canvas surface directly. Do not add
compatibility wording.
🪄 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: c39a90a0-cde1-4e4c-9054-950a67ed47fa

📥 Commits

Reviewing files that changed from the base of the PR and between 3654a9d and 48952e4.

📒 Files selected for processing (50)
  • internal/agent/component/arxiv_component_test.go
  • internal/agent/component/bgpt_component_test.go
  • internal/agent/component/duckduckgo_component_test.go
  • internal/agent/component/exesql_component_test.go
  • internal/agent/component/fixture_stubs.go
  • internal/agent/component/google_component_test.go
  • internal/agent/component/google_scholar_component_test.go
  • internal/agent/component/keenable_component_test.go
  • internal/agent/component/production_chain_fixes_test.go
  • internal/agent/component/pubmed_component_test.go
  • internal/agent/component/searxng.go
  • internal/agent/component/searxng_test.go
  • internal/agent/component/tavily_component_test.go
  • internal/agent/component/tool_component.go
  • internal/agent/component/tool_component_test.go
  • internal/agent/component/tool_dispatch_test.go
  • internal/agent/component/universe_a_wrappers.go
  • internal/agent/component/wencai.go
  • internal/agent/component/wencai_test.go
  • internal/agent/component/wikipedia_component_test.go
  • internal/agent/tool/arxiv.go
  • internal/agent/tool/arxiv_test.go
  • internal/agent/tool/bgpt.go
  • internal/agent/tool/bgpt_test.go
  • internal/agent/tool/duckduckgo.go
  • internal/agent/tool/duckduckgo_test.go
  • internal/agent/tool/email.go
  • internal/agent/tool/email_test.go
  • internal/agent/tool/exesql.go
  • internal/agent/tool/exesql_test.go
  • internal/agent/tool/google.go
  • internal/agent/tool/google_scholar.go
  • internal/agent/tool/google_scholar_test.go
  • internal/agent/tool/google_test.go
  • internal/agent/tool/keenable.go
  • internal/agent/tool/keenable_test.go
  • internal/agent/tool/pubmed.go
  • internal/agent/tool/pubmed_test.go
  • internal/agent/tool/registry.go
  • internal/agent/tool/registry_test.go
  • internal/agent/tool/searxng.go
  • internal/agent/tool/searxng_test.go
  • internal/agent/tool/tavily.go
  • internal/agent/tool/tavily_test.go
  • internal/agent/tool/wencai.go
  • internal/agent/tool/wencai_test.go
  • internal/agent/tool/wikipedia.go
  • internal/agent/tool/wikipedia_test.go
  • internal/agent/tool/yahoo_finance.go
  • internal/agent/tool/yahoo_finance_test.go
💤 Files with no reviewable changes (14)
  • internal/agent/component/google_component_test.go
  • internal/agent/component/searxng_test.go
  • internal/agent/component/wencai_test.go
  • internal/agent/component/exesql_component_test.go
  • internal/agent/component/wikipedia_component_test.go
  • internal/agent/component/bgpt_component_test.go
  • internal/agent/component/google_scholar_component_test.go
  • internal/agent/component/tavily_component_test.go
  • internal/agent/component/wencai.go
  • internal/agent/component/keenable_component_test.go
  • internal/agent/component/pubmed_component_test.go
  • internal/agent/component/duckduckgo_component_test.go
  • internal/agent/component/searxng.go
  • internal/agent/component/arxiv_component_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • internal/agent/component/tool_component.go

Comment thread internal/agent/tool/bgpt.go Resolved
Comment thread internal/agent/tool/email.go Resolved
Comment thread internal/agent/tool/tavily_test.go Resolved
Comment thread internal/agent/tool/tavily.go Resolved
Comment thread internal/agent/tool/tavily.go Resolved
Comment thread internal/agent/tool/wikipedia.go Resolved
Comment thread internal/agent/tool/yahoo_finance.go Resolved
@Harry-Hz-Zhang
Harry-Hz-Zhang force-pushed the refact/tool-component branch from 903d2b6 to c4ae8e1 Compare July 15, 2026 07:46

@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: 6

🧹 Nitpick comments (4)
internal/agent/tool/github.go (1)

195-215: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Describe the current Canvas behavior, not Python migration parity.

Proposed cleanup
-// ComponentSpec returns the Python-compatible GitHub Canvas surface.
+// ComponentSpec returns the GitHub Canvas contract.
@@
-// BuildReferences creates the chunks and document aggregates Python's
-// ToolBase._retrieve_chunks records for GitHub results.
+// BuildReferences creates retrieval chunks and document aggregates
+// for GitHub results.

As per coding guidelines, keep documentation aligned with the current runtime path rather than migration history.

🤖 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/tool/github.go` around lines 195 - 215, Update the
documentation comments around GitHubTool.ComponentSpec and BuildReferences to
describe the current Canvas/runtime behavior rather than Python compatibility or
migration parity. Remove references to Python-specific ToolBase records and use
terminology matching the active GitHub tool implementation.

Source: Coding guidelines

internal/agent/tool/yahoo_finance.go (1)

92-100: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Keep the defaults constructor package-private.

NewYahooFinanceToolWithDefaults accepts the unexported yahooFinanceParams, so external callers cannot construct its second argument. Rename it to newYahooFinanceToolWithDefaults and retain only the usable public constructors.

As per coding guidelines, “Reduce public surface area by making helpers private or internal when possible.”

🤖 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/tool/yahoo_finance.go` around lines 92 - 100, The defaults
constructor exposes an unusable public API because it accepts the unexported
yahooFinanceParams type. Rename NewYahooFinanceToolWithDefaults to
newYahooFinanceToolWithDefaults and update all internal call sites, while
retaining only the usable public constructors.

Source: Coding guidelines

internal/agent/tool/keenable.go (1)

66-73: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Remove migration-history language from current Go documentation.

  • internal/agent/tool/keenable.go#L66-L73: document the upstream response and public envelope directly.
  • internal/agent/tool/keenable.go#L311-L338: describe the Canvas contract and reference construction without Python parity.
  • internal/agent/tool/tavily.go#L84-L94: document raw-field preservation as the current output contract.
  • internal/agent/tool/tavily.go#L580-L602: describe the Canvas surface without calling it Python-compatible.

As per coding guidelines, keep Go documentation aligned with the current runtime path and remove compatibility wording.

🤖 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/tool/keenable.go` around lines 66 - 73, Update documentation
at internal/agent/tool/keenable.go:66-73 for keenableResponse and
keenableEnvelope to describe the current upstream response and public envelope
directly; update internal/agent/tool/keenable.go:311-338 to describe the Canvas
contract and reference construction without Python-parity language; update
internal/agent/tool/tavily.go:84-94 to document raw-field preservation as the
current output contract; and update internal/agent/tool/tavily.go:580-602 to
describe the Canvas surface without compatibility wording.

Source: Coding guidelines

internal/agent/tool/searxng.go (1)

227-253: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Remove migration-specific Python references from Go documentation.

Describe the current Canvas contract and reference conversion directly.

Proposed wording
-// ComponentSpec returns the Python-compatible SearXNG Canvas surface.
+// ComponentSpec returns the SearXNG Canvas contract.
...
-// BuildReferences builds the same references as Python ToolBase._retrieve_chunks.
+// BuildReferences converts SearXNG results into reference chunks.

As per coding guidelines, “do not add compatibility wording to comments or documentation.”

🤖 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/tool/searxng.go` around lines 227 - 253, Update the comments
on ComponentSpec and BuildReferences to describe the current Canvas contract and
reference conversion directly, removing migration-specific references to Python,
ToolBase, or compatibility behavior. Keep the implementation unchanged and
retain concise descriptions of each method’s actual responsibility.

Source: Coding guidelines

🤖 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/tool/arxiv.go`:
- Around line 345-361: Update renderArxivReferences in
internal/agent/tool/arxiv.go (345-361), the corresponding renderer in
internal/agent/tool/pubmed.go (306-323), and the corresponding renderer in
internal/agent/tool/tavily.go (457-477) to construct each complete reference
block first, calculate tokens for the full block, and only append it when it
remains within the configured budget; apply the token check before appending
while preserving the existing maxTokens threshold behavior.

In `@internal/agent/tool/github.go`:
- Around line 283-298: The reference-limiting logic must reject a block before
it exceeds the prompt budget. In internal/agent/tool/github.go lines 283-298,
update limitGitHubReferences to compare the prospective token total before
adding the current chunk and return chunks[:index] when the threshold would be
crossed; update internal/agent/tool/duckduckgo.go lines 301-317 to perform the
equivalent prospective-total check before appending the rendered block.
- Around line 146-147: Update the query emptiness check in the GitHub request
flow to trim surrounding whitespace before deciding whether the query is empty.
Ensure whitespace-only values use the existing githubJSON empty-results path,
while non-blank queries continue to be sent to GitHub.

In `@internal/agent/tool/google_scholar.go`:
- Around line 278-295: Update renderGoogleScholarReferences in
internal/agent/tool/google_scholar.go:278-295, the SearxNG renderer in
internal/agent/tool/searxng.go:323-348, and the Wikipedia renderer in
internal/agent/tool/wikipedia.go:334-351 to build each complete reference block
first, tokenize the finalized block, and reject it before appending when
usedTokens plus blockTokens exceeds the 97% maxTokens threshold; update
accounting only for blocks that are appended.

In `@internal/agent/tool/tavily.go`:
- Around line 381-396: Update TavilyTool.ComponentSpec and the corresponding
Tavily Extract component specification to include InputForm metadata for every
declared input, including topic, include_domains, exclude_domains,
extract_depth, and format. Use appropriate labels and input types consistent
with the existing query form entry so all advertised inputs are configurable
through the Canvas form contract.

In `@internal/agent/tool/yahoo_finance.go`:
- Around line 149-155: Update the Yahoo Finance request flow around
mergeYahooFinanceParams and buildYahooFinanceURL so enabled section flags
determine which data is fetched and rendered, rather than always using the quote
endpoint and table. Implement support for History, Financials, BalanceSheet,
CashFlowStatement, and News selections, or remove those unsupported switches
from the node contract to prevent unrelated quote data from being returned.

---

Nitpick comments:
In `@internal/agent/tool/github.go`:
- Around line 195-215: Update the documentation comments around
GitHubTool.ComponentSpec and BuildReferences to describe the current
Canvas/runtime behavior rather than Python compatibility or migration parity.
Remove references to Python-specific ToolBase records and use terminology
matching the active GitHub tool implementation.

In `@internal/agent/tool/keenable.go`:
- Around line 66-73: Update documentation at
internal/agent/tool/keenable.go:66-73 for keenableResponse and keenableEnvelope
to describe the current upstream response and public envelope directly; update
internal/agent/tool/keenable.go:311-338 to describe the Canvas contract and
reference construction without Python-parity language; update
internal/agent/tool/tavily.go:84-94 to document raw-field preservation as the
current output contract; and update internal/agent/tool/tavily.go:580-602 to
describe the Canvas surface without compatibility wording.

In `@internal/agent/tool/searxng.go`:
- Around line 227-253: Update the comments on ComponentSpec and BuildReferences
to describe the current Canvas contract and reference conversion directly,
removing migration-specific references to Python, ToolBase, or compatibility
behavior. Keep the implementation unchanged and retain concise descriptions of
each method’s actual responsibility.

In `@internal/agent/tool/yahoo_finance.go`:
- Around line 92-100: The defaults constructor exposes an unusable public API
because it accepts the unexported yahooFinanceParams type. Rename
NewYahooFinanceToolWithDefaults to newYahooFinanceToolWithDefaults and update
all internal call sites, while retaining only the usable public constructors.
🪄 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: 90d0928a-87b4-482c-b00e-b4f550c48e22

📥 Commits

Reviewing files that changed from the base of the PR and between 48952e4 and c4ae8e1.

📒 Files selected for processing (57)
  • internal/agent/component/arxiv_component_test.go
  • internal/agent/component/bgpt_component_test.go
  • internal/agent/component/duckduckgo_component_test.go
  • internal/agent/component/email.go
  • internal/agent/component/email_test.go
  • internal/agent/component/exesql_component_test.go
  • internal/agent/component/fixture_stubs.go
  • internal/agent/component/github.go
  • internal/agent/component/github_test.go
  • internal/agent/component/google_component_test.go
  • internal/agent/component/google_scholar_component_test.go
  • internal/agent/component/keenable_component_test.go
  • internal/agent/component/production_chain_fixes_test.go
  • internal/agent/component/pubmed_component_test.go
  • internal/agent/component/searxng.go
  • internal/agent/component/searxng_test.go
  • internal/agent/component/tavily_component_test.go
  • internal/agent/component/tool_component.go
  • internal/agent/component/tool_component_test.go
  • internal/agent/component/tool_dispatch_test.go
  • internal/agent/component/universe_a_wrappers.go
  • internal/agent/component/wencai.go
  • internal/agent/component/wencai_test.go
  • internal/agent/component/wikipedia_component_test.go
  • internal/agent/tool/arxiv.go
  • internal/agent/tool/arxiv_test.go
  • internal/agent/tool/bgpt.go
  • internal/agent/tool/bgpt_test.go
  • internal/agent/tool/duckduckgo.go
  • internal/agent/tool/duckduckgo_test.go
  • internal/agent/tool/email.go
  • internal/agent/tool/email_test.go
  • internal/agent/tool/exesql.go
  • internal/agent/tool/exesql_test.go
  • internal/agent/tool/github.go
  • internal/agent/tool/github_test.go
  • internal/agent/tool/google.go
  • internal/agent/tool/google_scholar.go
  • internal/agent/tool/google_scholar_test.go
  • internal/agent/tool/google_test.go
  • internal/agent/tool/keenable.go
  • internal/agent/tool/keenable_test.go
  • internal/agent/tool/pubmed.go
  • internal/agent/tool/pubmed_test.go
  • internal/agent/tool/registry.go
  • internal/agent/tool/registry_test.go
  • internal/agent/tool/searxng.go
  • internal/agent/tool/searxng_test.go
  • internal/agent/tool/tavily.go
  • internal/agent/tool/tavily_test.go
  • internal/agent/tool/tool2component.go
  • internal/agent/tool/wencai.go
  • internal/agent/tool/wencai_test.go
  • internal/agent/tool/wikipedia.go
  • internal/agent/tool/wikipedia_test.go
  • internal/agent/tool/yahoo_finance.go
  • internal/agent/tool/yahoo_finance_test.go
💤 Files with no reviewable changes (18)
  • internal/agent/component/bgpt_component_test.go
  • internal/agent/component/pubmed_component_test.go
  • internal/agent/component/duckduckgo_component_test.go
  • internal/agent/component/tavily_component_test.go
  • internal/agent/component/email_test.go
  • internal/agent/component/wikipedia_component_test.go
  • internal/agent/component/github_test.go
  • internal/agent/component/github.go
  • internal/agent/component/searxng.go
  • internal/agent/component/arxiv_component_test.go
  • internal/agent/component/google_component_test.go
  • internal/agent/component/wencai.go
  • internal/agent/component/exesql_component_test.go
  • internal/agent/component/searxng_test.go
  • internal/agent/component/email.go
  • internal/agent/component/keenable_component_test.go
  • internal/agent/component/google_scholar_component_test.go
  • internal/agent/component/wencai_test.go
🚧 Files skipped from review as they are similar to previous changes (24)
  • internal/agent/component/tool_dispatch_test.go
  • internal/agent/tool/tool2component.go
  • internal/agent/tool/arxiv_test.go
  • internal/agent/component/production_chain_fixes_test.go
  • internal/agent/tool/wikipedia_test.go
  • internal/agent/tool/pubmed_test.go
  • internal/agent/tool/wencai.go
  • internal/agent/component/tool_component.go
  • internal/agent/tool/keenable_test.go
  • internal/agent/component/tool_component_test.go
  • internal/agent/tool/wencai_test.go
  • internal/agent/component/universe_a_wrappers.go
  • internal/agent/tool/registry_test.go
  • internal/agent/tool/email_test.go
  • internal/agent/tool/exesql.go
  • internal/agent/tool/exesql_test.go
  • internal/agent/tool/duckduckgo_test.go
  • internal/agent/tool/searxng_test.go
  • internal/agent/component/fixture_stubs.go
  • internal/agent/tool/github_test.go
  • internal/agent/tool/google_scholar_test.go
  • internal/agent/tool/tavily_test.go
  • internal/agent/tool/google_test.go
  • internal/agent/tool/email.go

Comment thread internal/agent/tool/arxiv.go Resolved
Comment thread internal/agent/tool/github.go Resolved
Comment thread internal/agent/tool/github.go Resolved
Comment thread internal/agent/tool/google_scholar.go Resolved
Comment thread internal/agent/tool/tavily.go Resolved
Comment thread internal/agent/tool/yahoo_finance.go Resolved

@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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
internal/agent/tool/tavily_test.go (1)

348-388: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Synchronize the handler's request capture.

The handler writes to gotPath, gotMethod, gotAuth, and gotBody while the test goroutine reads them after InvokableRun returns. Although a successful HTTP round-trip provides an implicit synchronization edge, using unsynchronized shared variables in httptest handlers is a known anti-pattern that can trigger the Go race detector if the client times out or cancels.

Capture the values through a buffered channel instead.

🛠️ Proposed fix
-	var gotPath, gotAuth, gotMethod string
-	var gotBody map[string]any
+	type requestData struct {
+		path   string
+		method string
+		auth   string
+		body   map[string]any
+	}
+	reqChan := make(chan requestData, 1)
+
 	srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
-		gotPath = r.URL.Path
-		gotMethod = r.Method
-		gotAuth = r.Header.Get("Authorization")
-		_ = json.NewDecoder(r.Body).Decode(&gotBody)
+		var body map[string]any
+		_ = json.NewDecoder(r.Body).Decode(&body)
+		reqChan <- requestData{
+			path:   r.URL.Path,
+			method: r.Method,
+			auth:   r.Header.Get("Authorization"),
+			body:   body,
+		}
 		w.Header().Set("Content-Type", "application/json")
 		_, _ = w.Write([]byte(`{"results":[{"url":"https://example.com","raw_content":"hello"}]}`))
 	}))
 	defer srv.Close()
 
 	helper := NewHTTPHelper().WithClient(&http.Client{Transport: rewriteHostTransport(srv.URL)})
 	tool := NewTavilyExtractToolWith(helper)
 	out, err := tool.InvokableRun(context.Background(),
 		`{"urls":"https://a.example, https://b.example","api_key":"key-xyz","extract_depth":"advanced","format":"text"}`)
 	if err != nil {
 		t.Fatalf("InvokableRun: %v", err)
 	}
 	if out == "" {
 		t.Fatal("InvokableRun returned empty string")
 	}
-	if gotMethod != http.MethodPost {
-		t.Errorf("method = %q, want POST", gotMethod)
-	}
-	if !strings.HasSuffix(gotPath, "extract") {
-		t.Errorf("path = %q, want .../extract", gotPath)
-	}
-	if gotAuth != "Bearer key-xyz" {
-		t.Errorf("Authorization = %q, want %q", gotAuth, "Bearer key-xyz")
-	}
-	urls, ok := gotBody["urls"].([]any)
+
+	var got requestData
+	select {
+	case got = <-reqChan:
+	default:
+		t.Fatal("handler was not called")
+	}
+
+	if got.method != http.MethodPost {
+		t.Errorf("method = %q, want POST", got.method)
+	}
+	if !strings.HasSuffix(got.path, "extract") {
+		t.Errorf("path = %q, want .../extract", got.path)
+	}
+	if got.auth != "Bearer key-xyz" {
+		t.Errorf("Authorization = %q, want %q", got.auth, "Bearer key-xyz")
+	}
+	urls, ok := got.body["urls"].([]any)
 	if !ok || len(urls) != 2 || urls[0] != "https://a.example" || urls[1] != "https://b.example" {
-		t.Errorf("body.urls = %#v, want two trimmed URLs", gotBody["urls"])
+		t.Errorf("body.urls = %#v, want two trimmed URLs", got.body["urls"])
 	}
-	if gotBody["extract_depth"] != "advanced" {
-		t.Errorf("body.extract_depth = %v, want advanced", gotBody["extract_depth"])
+	if got.body["extract_depth"] != "advanced" {
+		t.Errorf("body.extract_depth = %v, want advanced", got.body["extract_depth"])
 	}
-	if gotBody["format"] != "text" {
-		t.Errorf("body.format = %v, want text", gotBody["format"])
+	if got.body["format"] != "text" {
+		t.Errorf("body.format = %v, want text", got.body["format"])
 	}
🤖 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/tool/tavily_test.go` around lines 348 - 388, Replace the
unsynchronized gotPath, gotMethod, gotAuth, and gotBody variables in the
httptest handler with a buffered channel carrying the captured request data.
Have the handler send one snapshot after decoding the request, then receive that
snapshot after InvokableRun before performing the existing assertions,
preserving all current validation behavior.
🤖 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.

Outside diff comments:
In `@internal/agent/tool/tavily_test.go`:
- Around line 348-388: Replace the unsynchronized gotPath, gotMethod, gotAuth,
and gotBody variables in the httptest handler with a buffered channel carrying
the captured request data. Have the handler send one snapshot after decoding the
request, then receive that snapshot after InvokableRun before performing the
existing assertions, preserving all current validation behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9c53a0b5-9a8f-42ad-9531-3b8965d1a101

📥 Commits

Reviewing files that changed from the base of the PR and between c4ae8e1 and 9b14739.

📒 Files selected for processing (11)
  • internal/agent/tool/google_scholar.go
  • internal/agent/tool/google_scholar_test.go
  • internal/agent/tool/registry.go
  • internal/agent/tool/searxng.go
  • internal/agent/tool/searxng_test.go
  • internal/agent/tool/tavily.go
  • internal/agent/tool/tavily_test.go
  • internal/agent/tool/wikipedia.go
  • internal/agent/tool/wikipedia_test.go
  • internal/agent/tool/yahoo_finance.go
  • internal/agent/tool/yahoo_finance_test.go
🚧 Files skipped from review as they are similar to previous changes (8)
  • internal/agent/tool/google_scholar_test.go
  • internal/agent/tool/yahoo_finance.go
  • internal/agent/tool/wikipedia.go
  • internal/agent/tool/yahoo_finance_test.go
  • internal/agent/tool/wikipedia_test.go
  • internal/agent/tool/google_scholar.go
  • internal/agent/tool/registry.go
  • internal/agent/tool/tavily.go

@Harry-Hz-Zhang
Harry-Hz-Zhang marked this pull request as draft July 15, 2026 08:26
@Harry-Hz-Zhang
Harry-Hz-Zhang marked this pull request as ready for review July 15, 2026 08:26
@yuzhichang
yuzhichang merged commit a7da78d into infiniflow:main Jul 15, 2026
9 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration lgtm This PR has been approved by a maintainer ☯️ refactor Pull request that refactor/refine code size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants