Skip to content

fix(go-agent): Added PubMed component support - #16817

Merged
yuzhichang merged 4 commits into
infiniflow:mainfrom
Hz-186:fix/agent-PubMed
Jul 11, 2026
Merged

fix(go-agent): Added PubMed component support#16817
yuzhichang merged 4 commits into
infiniflow:mainfrom
Hz-186:fix/agent-PubMed

Conversation

@Hz-186

@Hz-186 Hz-186 commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Merge upstream main and retain PubMed component support.
  • Preserve newly registered tool components and update registry verification.

Tests

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

@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jul 10, 2026
@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

PubMed retrieval now uses esearch followed by efetch XML, with configurable node defaults for top_n and email. A new canvas component exposes trimmed query input, formatted content, raw JSON results, registration, and upstream error propagation.

Changes

PubMed integration

Layer / File(s) Summary
PubMed tool flow and result schema
internal/agent/tool/pubmed.go, internal/agent/tool/pubmed_test.go
The tool exposes only query, retrieves PMIDs through esearch, fetches XML articles through efetch, and formats title, URL, authors, journal data, DOI, and abstract content.
Registry configuration and defaults
internal/agent/tool/registry.go, internal/agent/tool/pubmed_test.go
The registry validates top_n and email, rejects unsupported parameters, and constructs PubMed tools with merged defaults.
Canvas component wrapper and registration
internal/agent/component/universe_a_wrappers.go, internal/agent/component/fixture_stubs.go, internal/agent/component/pubmed_component_test.go, internal/agent/component/verify_p1_test.go
The PubMed component forwards only the trimmed query, returns formatted and JSON outputs, propagates tool errors, and is registered with component contract tests.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Canvas
  participant pubMedComponent
  participant PubMedTool
  participant NCBI
  Canvas->>pubMedComponent: Invoke query
  pubMedComponent->>PubMedTool: InvokableRun query
  PubMedTool->>NCBI: esearch query
  NCBI-->>PubMedTool: PMID list
  PubMedTool->>NCBI: efetch PMIDs as XML
  NCBI-->>PubMedTool: XML articles
  PubMedTool-->>pubMedComponent: JSON envelope
  pubMedComponent-->>Canvas: formalized_content and json
Loading

Suggested labels: 💞 feature, 🧪 test, go

Suggested reviewers: yuzhichang, yingfeng, JinHai-CN

Poem

I’m a rabbit with papers to find,
XML carrots neatly aligned.
Queries hop, results appear,
Titles and abstracts gathered near.
PubMed now burrows clear!

🚥 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
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.
Title check ✅ Passed The title is concise and matches the main change: adding PubMed component support.
Description check ✅ Passed The description includes the required Summary section and enough context plus tests for reviewers.

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.

@Hz-186 Hz-186 added 🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration labels Jul 10, 2026
@Hz-186
Hz-186 marked this pull request as draft July 10, 2026 09:34
@Hz-186
Hz-186 marked this pull request as ready for review July 10, 2026 09:34

@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

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/agent/component/universe_a_wrappers.go`:
- Around line 1728-1737: In the error-handling branch of PubMedTool, avoid
returning a nil error when decoded lacks a usable "_ERROR" value: use
decoded["_ERROR"] when present and non-empty, otherwise fall back to
err.Error(). Preserve the partial response while ensuring the returned error
always contains the upstream failure; update the logic around the len(decoded)
check accordingly.
🪄 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: 45c11e92-a78a-40f7-8ebd-d0dd3f845f65

📥 Commits

Reviewing files that changed from the base of the PR and between 2a83ad6 and 81ddfb3.

📒 Files selected for processing (7)
  • internal/agent/component/fixture_stubs.go
  • internal/agent/component/pubmed_component_test.go
  • internal/agent/component/universe_a_wrappers.go
  • internal/agent/component/verify_p1_test.go
  • internal/agent/tool/pubmed.go
  • internal/agent/tool/pubmed_test.go
  • internal/agent/tool/registry.go

Comment on lines +1728 to +1737
if err != nil {
if len(decoded) > 0 {
return map[string]any{
"formalized_content": "",
"json": results,
"_ERROR": decoded["_ERROR"],
}, nil
}
return nil, fmt.Errorf("canvas: PubMed: %w", err)
}

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.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Error can be swallowed when _ERROR is absent from decoded output.

When err != nil and len(decoded) > 0 but the decoded envelope lacks a usable _ERROR field, the code returns decoded["_ERROR"] (which is nil when the key is absent) and a nil error. The upstream error is lost. While the current PubMedTool always sets _ERROR on error, this path silently drops errors from any invoker that returns partial JSON without _ERROR.

🛡️ Proposed fix: fall back to err.Error() when _ERROR is absent
 	if err != nil {
 		if len(decoded) > 0 {
+			errMsg, _ := decoded["_ERROR"].(string)
+			if strings.TrimSpace(errMsg) == "" {
+				errMsg = err.Error()
+			}
 			return map[string]any{
 				"formalized_content": "",
 				"json":               results,
-				"_ERROR":             decoded["_ERROR"],
+				"_ERROR":             errMsg,
 			}, nil
 		}
 		return nil, fmt.Errorf("canvas: PubMed: %w", err)
 	}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if err != nil {
if len(decoded) > 0 {
return map[string]any{
"formalized_content": "",
"json": results,
"_ERROR": decoded["_ERROR"],
}, nil
}
return nil, fmt.Errorf("canvas: PubMed: %w", err)
}
if err != nil {
if len(decoded) > 0 {
errMsg, _ := decoded["_ERROR"].(string)
if strings.TrimSpace(errMsg) == "" {
errMsg = err.Error()
}
return map[string]any{
"formalized_content": "",
"json": results,
"_ERROR": errMsg,
}, nil
}
return nil, fmt.Errorf("canvas: PubMed: %w", err)
}
🤖 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 1728 - 1737, In
the error-handling branch of PubMedTool, avoid returning a nil error when
decoded lacks a usable "_ERROR" value: use decoded["_ERROR"] when present and
non-empty, otherwise fall back to err.Error(). Preserve the partial response
while ensuring the returned error always contains the upstream failure; update
the logic around the len(decoded) check accordingly.

@Hz-186
Hz-186 marked this pull request as draft July 10, 2026 10:26
@Hz-186
Hz-186 marked this pull request as ready for review July 10, 2026 10:26
@yuzhichang yuzhichang changed the title fix(go-agent): merge upstream main updates fix(go-agent): Added PubMed component support Jul 11, 2026
@yuzhichang
yuzhichang merged commit 156a11c into infiniflow:main Jul 11, 2026
4 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 size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants