Skip to content

fix(go-agent): add BGPT component and input form - #16684

Merged
yuzhichang merged 5 commits into
infiniflow:mainfrom
Harry-Hz-Zhang:fix/agent-BGPT-component
Jul 7, 2026
Merged

yuzhichang merged 5 commits into
infiniflow:mainfrom
Harry-Hz-Zhang:fix/agent-BGPT-component

Conversation

@Harry-Hz-Zhang

Copy link
Copy Markdown
Contributor

Summary

Adds the missing input form metadata for the Go BGPT canvas component.

Root Cause

The standalone BGPT component was registered in Go, but it did not implement GetInputForm(). During component trial run, the backend asks the component for its input_form. Since BGPT had none, the API returned:

component has no input_form: BGPT:<node_id>

Python BGPT already exposes the query input form, so the Go component needed the same contract.

Change

Added GetInputForm() to the Go BGPT component with a single query line input.
Added test coverage to ensure BGPT exposes the input form.

Validation

Backend:
bash build.sh --test -run TestBGPT ./internal/agent/component

image image

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

coderabbitai Bot commented Jul 7, 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: 6c6e8b42-9ccc-4f46-bfd6-b9ce1821c093

📥 Commits

Reviewing files that changed from the base of the PR and between 412551d and 83ef3fe.

📒 Files selected for processing (2)
  • internal/agent/component/bgpt_component_test.go
  • internal/agent/component/universe_a_wrappers.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • internal/agent/component/bgpt_component_test.go
  • internal/agent/component/universe_a_wrappers.go

📝 Walkthrough

Walkthrough

Adds a new BGPT canvas component wrapper that adapts inputs, invokes the underlying tool, renders normalized results, registers the component, and verifies the behavior with unit tests.

Changes

BGPT Component Integration

Layer / File(s) Summary
BGPT component implementation
internal/agent/component/universe_a_wrappers.go
Adds the BGPT canvas component contract, input normalization, tool invocation, envelope parsing, error handling, and result rendering helpers.
Component registration and tests
internal/agent/component/fixture_stubs.go, internal/agent/component/bgpt_component_test.go
Registers "BGPT" in the factory and adds tests for registration plus invocation adaptation with a fake invoker.

Estimated code review effort: 2 (Simple) | ~15 minutes

Poem

A rabbit hops in tidy code,
BGPT finds its canvas road,
Inputs trimmed, results refined,
Tests keep every path aligned,
Hoppity-hoppity, all is bright 🐰

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: adding the BGPT component and its input form.
Description check ✅ Passed The description includes the summary, root cause, change details, and validation, matching the template's intent.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 (2)
internal/agent/component/universe_a_wrappers.go (1)

223-238: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low value

Missing URL field in rendered output.

bgptResult carries a url field (see internal/agent/tool/bgpt.go), but renderBGPTResults never emits it, dropping paper source links from formalized_content.

♻️ Proposed addition
 			fmt.Sprintf("DOI: %s", bgptField("doi")),
+			fmt.Sprintf("URL: %s", bgptField("url")),
 			fmt.Sprintf("Abstract: %s", bgptField("abstract")),
🤖 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 223 - 238, The
renderBGPTResults formatter in universe_a_wrappers.go is omitting the existing
url value from bgptResult, so paper source links are lost in formalized_content.
Update the lines slice built in renderBGPTResults to include the URL field
alongside the other bgptField entries, using the same formatting pattern as
Title, DOI, and Abstract so the rendered output preserves source links.
internal/agent/component/bgpt_component_test.go (1)

55-96: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add test coverage for empty-query and error-envelope branches.

Current tests only cover the success path. Invoke's empty-query short-circuit and the _ERROR handling branch (universe_a_wrappers.go Line 133-135, 152-161) are untested.

🤖 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/bgpt_component_test.go` around lines 55 - 96, Add
test coverage in TestBGPT_InvokeAdaptsCanvasInputsAndOutputs for the missing
Invoke branches: the empty-query short-circuit and the _ERROR envelope handling
in BGPTComponent.Invoke. Create focused cases using the existing
newBGPTComponentWithInvoker and fakeBGPTInvoker helpers to verify an
empty/whitespace query returns the expected early response without invoking the
backend, and that a returned _ERROR payload is mapped to the intended error path
instead of success output. Ensure the assertions target Invoke, fakeBGPTInvoker,
and the output keys used by the adapter.
🤖 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/bgpt_component_test.go`:
- Around line 55-96: Add test coverage in
TestBGPT_InvokeAdaptsCanvasInputsAndOutputs for the missing Invoke branches: the
empty-query short-circuit and the _ERROR envelope handling in
BGPTComponent.Invoke. Create focused cases using the existing
newBGPTComponentWithInvoker and fakeBGPTInvoker helpers to verify an
empty/whitespace query returns the expected early response without invoking the
backend, and that a returned _ERROR payload is mapped to the intended error path
instead of success output. Ensure the assertions target Invoke, fakeBGPTInvoker,
and the output keys used by the adapter.

In `@internal/agent/component/universe_a_wrappers.go`:
- Around line 223-238: The renderBGPTResults formatter in universe_a_wrappers.go
is omitting the existing url value from bgptResult, so paper source links are
lost in formalized_content. Update the lines slice built in renderBGPTResults to
include the URL field alongside the other bgptField entries, using the same
formatting pattern as Title, DOI, and Abstract so the rendered output preserves
source links.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 878900ab-ce55-4f89-8242-010818c5b514

📥 Commits

Reviewing files that changed from the base of the PR and between ab5958f and 412551d.

📒 Files selected for processing (3)
  • internal/agent/component/bgpt_component_test.go
  • internal/agent/component/fixture_stubs.go
  • internal/agent/component/universe_a_wrappers.go

@yuzhichang
yuzhichang merged commit d03a360 into infiniflow:main Jul 7, 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 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