Repository navigation
refactor(go-agent): unify tool-backed canvas components - #16912
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (11)
🚧 Files skipped from review as they are similar to previous changes (8)
📝 WalkthroughWalkthroughTool-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. ChangesTool-backed Canvas integration
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
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (3)
internal/agent/component/universe_a_wrappers.go (2)
778-790: 🔒 Security & Privacy | 🔵 Trivial | 💤 Low valueStatic analysis flags
sha1.Sum(CWE-327) — likely a non-issue here, but consider a non-crypto hash.
keenableHashIntuses 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, usinghash/fnvorsha256instead 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 winExtract the shared hash/truncation helper
keenableHashIntandtruncateKeenableRunesare byte-for-byte the same asgithubHashIntandtruncateGitHubRunesininternal/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 | 🔵 TrivialBoundary test doesn't verify which chunk was kept.
TestGitHub_LimitReferencesKeepsBoundaryChunkonly checkslen(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
📒 Files selected for processing (10)
internal/agent/component/fixture_stubs.gointernal/agent/component/github.gointernal/agent/component/github_test.gointernal/agent/component/tool_component.gointernal/agent/component/tool_component_test.gointernal/agent/component/universe_a_wrappers.gointernal/agent/tool/github.gointernal/agent/tool/github_test.gointernal/agent/tool/registry.gointernal/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
There was a problem hiding this comment.
♻️ Duplicate comments (1)
internal/agent/tool/github_test.go (1)
231-250: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winDead assertion:
repository["private"]check runs before any processing.Lines 231-234 check
repository["private"] != falseon the manually constructedresultsmap, beforeBuildReferencesorBuildComponentOutputsare 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
📒 Files selected for processing (5)
internal/agent/component/tool_component.gointernal/agent/component/tool_component_test.gointernal/agent/tool/github.gointernal/agent/tool/github_test.gointernal/agent/tool/tool2component.go
🚧 Files skipped from review as they are similar to previous changes (1)
- internal/agent/component/tool_component.go
There was a problem hiding this comment.
Actionable comments posted: 16
🧹 Nitpick comments (3)
internal/agent/component/production_chain_fixes_test.go (1)
62-90: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAssert the v1 parameter translation, not only the wrapper type.
Construction and the
*ToolBackedComponentassertion do not prove the stateddb_type, numericport, ortop_n → max_recordsbehavior. 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 liftConsolidate 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 forsummary,title, andpdf_url.internal/agent/tool/wikipedia.go#L299-L375: replace the Wikipedia-specific helper set with the same adapter configured forcontent,title, andurl.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 winRemove 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
📒 Files selected for processing (50)
internal/agent/component/arxiv_component_test.gointernal/agent/component/bgpt_component_test.gointernal/agent/component/duckduckgo_component_test.gointernal/agent/component/exesql_component_test.gointernal/agent/component/fixture_stubs.gointernal/agent/component/google_component_test.gointernal/agent/component/google_scholar_component_test.gointernal/agent/component/keenable_component_test.gointernal/agent/component/production_chain_fixes_test.gointernal/agent/component/pubmed_component_test.gointernal/agent/component/searxng.gointernal/agent/component/searxng_test.gointernal/agent/component/tavily_component_test.gointernal/agent/component/tool_component.gointernal/agent/component/tool_component_test.gointernal/agent/component/tool_dispatch_test.gointernal/agent/component/universe_a_wrappers.gointernal/agent/component/wencai.gointernal/agent/component/wencai_test.gointernal/agent/component/wikipedia_component_test.gointernal/agent/tool/arxiv.gointernal/agent/tool/arxiv_test.gointernal/agent/tool/bgpt.gointernal/agent/tool/bgpt_test.gointernal/agent/tool/duckduckgo.gointernal/agent/tool/duckduckgo_test.gointernal/agent/tool/email.gointernal/agent/tool/email_test.gointernal/agent/tool/exesql.gointernal/agent/tool/exesql_test.gointernal/agent/tool/google.gointernal/agent/tool/google_scholar.gointernal/agent/tool/google_scholar_test.gointernal/agent/tool/google_test.gointernal/agent/tool/keenable.gointernal/agent/tool/keenable_test.gointernal/agent/tool/pubmed.gointernal/agent/tool/pubmed_test.gointernal/agent/tool/registry.gointernal/agent/tool/registry_test.gointernal/agent/tool/searxng.gointernal/agent/tool/searxng_test.gointernal/agent/tool/tavily.gointernal/agent/tool/tavily_test.gointernal/agent/tool/wencai.gointernal/agent/tool/wencai_test.gointernal/agent/tool/wikipedia.gointernal/agent/tool/wikipedia_test.gointernal/agent/tool/yahoo_finance.gointernal/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
903d2b6 to
c4ae8e1
Compare
There was a problem hiding this comment.
Actionable comments posted: 6
🧹 Nitpick comments (4)
internal/agent/tool/github.go (1)
195-215: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDescribe 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 winKeep the defaults constructor package-private.
NewYahooFinanceToolWithDefaultsaccepts the unexportedyahooFinanceParams, so external callers cannot construct its second argument. Rename it tonewYahooFinanceToolWithDefaultsand 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 winRemove 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 winRemove 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
📒 Files selected for processing (57)
internal/agent/component/arxiv_component_test.gointernal/agent/component/bgpt_component_test.gointernal/agent/component/duckduckgo_component_test.gointernal/agent/component/email.gointernal/agent/component/email_test.gointernal/agent/component/exesql_component_test.gointernal/agent/component/fixture_stubs.gointernal/agent/component/github.gointernal/agent/component/github_test.gointernal/agent/component/google_component_test.gointernal/agent/component/google_scholar_component_test.gointernal/agent/component/keenable_component_test.gointernal/agent/component/production_chain_fixes_test.gointernal/agent/component/pubmed_component_test.gointernal/agent/component/searxng.gointernal/agent/component/searxng_test.gointernal/agent/component/tavily_component_test.gointernal/agent/component/tool_component.gointernal/agent/component/tool_component_test.gointernal/agent/component/tool_dispatch_test.gointernal/agent/component/universe_a_wrappers.gointernal/agent/component/wencai.gointernal/agent/component/wencai_test.gointernal/agent/component/wikipedia_component_test.gointernal/agent/tool/arxiv.gointernal/agent/tool/arxiv_test.gointernal/agent/tool/bgpt.gointernal/agent/tool/bgpt_test.gointernal/agent/tool/duckduckgo.gointernal/agent/tool/duckduckgo_test.gointernal/agent/tool/email.gointernal/agent/tool/email_test.gointernal/agent/tool/exesql.gointernal/agent/tool/exesql_test.gointernal/agent/tool/github.gointernal/agent/tool/github_test.gointernal/agent/tool/google.gointernal/agent/tool/google_scholar.gointernal/agent/tool/google_scholar_test.gointernal/agent/tool/google_test.gointernal/agent/tool/keenable.gointernal/agent/tool/keenable_test.gointernal/agent/tool/pubmed.gointernal/agent/tool/pubmed_test.gointernal/agent/tool/registry.gointernal/agent/tool/registry_test.gointernal/agent/tool/searxng.gointernal/agent/tool/searxng_test.gointernal/agent/tool/tavily.gointernal/agent/tool/tavily_test.gointernal/agent/tool/tool2component.gointernal/agent/tool/wencai.gointernal/agent/tool/wencai_test.gointernal/agent/tool/wikipedia.gointernal/agent/tool/wikipedia_test.gointernal/agent/tool/yahoo_finance.gointernal/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
There was a problem hiding this comment.
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 winSynchronize the handler's request capture.
The handler writes to
gotPath,gotMethod,gotAuth, andgotBodywhile the test goroutine reads them afterInvokableRunreturns. Although a successful HTTP round-trip provides an implicit synchronization edge, using unsynchronized shared variables inhttptesthandlers 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
📒 Files selected for processing (11)
internal/agent/tool/google_scholar.gointernal/agent/tool/google_scholar_test.gointernal/agent/tool/registry.gointernal/agent/tool/searxng.gointernal/agent/tool/searxng_test.gointernal/agent/tool/tavily.gointernal/agent/tool/tavily_test.gointernal/agent/tool/wikipedia.gointernal/agent/tool/wikipedia_test.gointernal/agent/tool/yahoo_finance.gointernal/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
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:
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/...