Skip to content

fix(go-agent): ArXiv component registration and request parity - #16808

Merged
yuzhichang merged 2 commits into
infiniflow:mainfrom
Harry-Hz-Zhang:fix/agent-ArXiv
Jul 13, 2026
Merged

yuzhichang merged 2 commits into
infiniflow:mainfrom
Harry-Hz-Zhang:fix/agent-ArXiv

Conversation

@Harry-Hz-Zhang

Copy link
Copy Markdown
Contributor

Summary

  • register the Go ArXiv canvas component and add its input form
  • align the Go ArXiv request/schema with Python by keeping only query in runtime args and moving top_n/sort_by to node params
  • keep ArXiv results consistent for canvas output and tool response handling

Test

  • bash build.sh --test ./internal/agent/tool ./internal/agent/component
image

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

coderabbitai Bot commented Jul 10, 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: 5977ed74-0c82-48a2-b044-e6601d4489ab

📥 Commits

Reviewing files that changed from the base of the PR and between 5c5ae0c and e6cacf2.

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

📝 Walkthrough

Walkthrough

The ArXiv tool now supports node-level result-count and sort configuration. A registered ArXiv canvas component invokes it, formats returned papers into JSON and text outputs, and validates configuration and queries. Tests cover registration, requests, formatting, empty input, and tool metadata.

Changes

ArXiv integration

Layer / File(s) Summary
Configurable tool execution
internal/agent/tool/arxiv.go, internal/agent/tool/arxiv_test.go
ArXiv requests use top_n and sort_by, apply defaults, validate inputs, expose only query to models, and include sortBy in generated URLs.
Canvas component and registry wiring
internal/agent/component/universe_a_wrappers.go, internal/agent/component/fixture_stubs.go, internal/agent/tool/registry.go
Adds and registers the ArXiv component, configures the tool factory, and renders results as formalized_content and json.
Integration and behavior coverage
internal/agent/component/arxiv_component_test.go, internal/agent/component/verify_p1_test.go
Tests component contracts, parameter validation, HTTP requests, result formatting, empty queries, and registration documentation bounds.

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

Sequence Diagram(s)

sequenceDiagram
  participant Canvas as arxivComponent
  participant Tool as ArxivTool
  participant API as ArXiv API
  Canvas->>Tool: Invoke query with top_n and sort_by
  Tool->>API: Send search_query, max_results, sortBy
  API-->>Tool: Return Atom XML
  Tool-->>Canvas: Return results
  Canvas-->>Canvas: Render formalized_content and json
Loading

Suggested labels: go

Poem

I’m a rabbit with papers tucked under my ear,
Sorting each result so the path is clear.
Query in, summaries bright,
JSON hops into sight—
ArXiv now burrows through code without fear.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% 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 matches the main change: registering the ArXiv component and aligning its request behavior with Python.
Description check ✅ Passed The description includes the required Summary and Test details and is sufficient for review.
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.

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

1431-1447: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Eliminate duplicated default constants by deferring to NewArxivToolWithParams.

newArxivComponent hardcodes topN := 12 and sortBy := "submittedDate", duplicating defaultArxivTopN and defaultArxivSortBy from the tool package. Since NewArxivToolWithParams already applies these exact defaults when topN <= 0 or sortBy == "", the component can pass zero values when params are absent and let the constructor handle defaults. This prevents drift if the tool defaults ever change.

♻️ Proposed refactor
 func newArxivComponent(params map[string]any) (Component, error) {
-	topN := 12
-	if v, ok := params["top_n"]; ok {
-		topN = toIntParam(v)
-	}
-	if topN <= 0 {
-		return nil, fmt.Errorf("canvas: ArXiv: top_n must be a positive integer")
-	}
-	sortBy := "submittedDate"
-	if v, ok := params["sort_by"].(string); ok && strings.TrimSpace(v) != "" {
-		sortBy = strings.TrimSpace(v)
-	}
-	if !agenttool.ArxivSortBySupported(sortBy) {
-		return nil, fmt.Errorf("canvas: ArXiv: unsupported sort_by %q", sortBy)
-	}
+	topN := 0
+	if v, ok := params["top_n"]; ok {
+		topN = toIntParam(v)
+		if topN <= 0 {
+			return nil, fmt.Errorf("canvas: ArXiv: top_n must be a positive integer")
+		}
+	}
+	sortBy := ""
+	if v, ok := params["sort_by"].(string); ok {
+		sortBy = strings.TrimSpace(v)
+	}
+	if sortBy != "" && !agenttool.ArxivSortBySupported(sortBy) {
+		return nil, fmt.Errorf("canvas: ArXiv: unsupported sort_by %q", sortBy)
+	}
 	return &arxivComponent{inner: agenttool.NewArxivToolWithParams(nil, topN, sortBy)}, nil
 }
🤖 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 1431 - 1447,
Remove the hardcoded topN and sortBy defaults from newArxivComponent, using
zero/empty values when the corresponding params are absent so
agenttool.NewArxivToolWithParams applies its defaults. Preserve validation for
explicitly provided invalid top_n and unsupported sort_by values, while allowing
absent values to reach the constructor unchanged.
🤖 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.

Nitpick comments:
In `@internal/agent/component/universe_a_wrappers.go`:
- Around line 1431-1447: Remove the hardcoded topN and sortBy defaults from
newArxivComponent, using zero/empty values when the corresponding params are
absent so agenttool.NewArxivToolWithParams applies its defaults. Preserve
validation for explicitly provided invalid top_n and unsupported sort_by values,
while allowing absent values to reach the constructor unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 756cbd42-69b8-4081-b753-25b333096b8f

📥 Commits

Reviewing files that changed from the base of the PR and between 7db3982 and 5c5ae0c.

📒 Files selected for processing (7)
  • internal/agent/component/arxiv_component_test.go
  • internal/agent/component/fixture_stubs.go
  • internal/agent/component/universe_a_wrappers.go
  • internal/agent/component/verify_p1_test.go
  • internal/agent/tool/arxiv.go
  • internal/agent/tool/arxiv_test.go
  • internal/agent/tool/registry.go

@yuzhichang

Copy link
Copy Markdown
Member

LGTM

@yuzhichang
yuzhichang merged commit 347a459 into infiniflow:main Jul 13, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants