Skip to content

fix(go-agent): Align Go WenCai and SearXNG agent components with python - #16854

Merged
yuzhichang merged 2 commits into
infiniflow:mainfrom
Hz-186:fix/agent-wencai-SearXNG
Jul 13, 2026
Merged

fix(go-agent): Align Go WenCai and SearXNG agent components with python#16854
yuzhichang merged 2 commits into
infiniflow:mainfrom
Hz-186:fix/agent-wencai-SearXNG

Conversation

@Hz-186

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

Copy link
Copy Markdown
Contributor

Summary

  • Align Go WenCai and SearXNG behavior, schemas, and node parameters with Python.
  • Add the WenCai and SearXNG Canvas components and register their tool factories.
  • Match Python's current WenCai behavior by returning an empty report while its upstream request is disabled.
  • Add SearXNG request validation, SSRF-safe DNS pinning, raw result preservation, and reference rendering.
  • Support context cancellation, error envelopes, and lock-safe retrieval references.

Tests

Passed:

  • bash build.sh --test ./internal/agent/tool/...
  • bash build.sh --test ./internal/agent/component/...
  • bash build.sh --test ./internal/agent/runtime/...
  • bash build.sh --test ./internal/agent/...
  • cd web && npm run type-check
image image

@dosubot dosubot Bot added size:XL This PR changes 500-999 lines, ignoring generated files. 💞 feature Feature request, pull request that fullfill a new feature. labels Jul 13, 2026
@Hz-186 Hz-186 added 🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration labels Jul 13, 2026
@coderabbitai

coderabbitai Bot commented Jul 13, 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: ed0310f0-8345-4944-91ff-c12ffbbc70c8

📥 Commits

Reviewing files that changed from the base of the PR and between 7442200 and b710cef.

📒 Files selected for processing (5)
  • internal/agent/component/searxng.go
  • internal/agent/component/searxng_test.go
  • internal/agent/runtime/state.go
  • internal/agent/runtime/state_test.go
  • internal/agent/tool/registry.go
🚧 Files skipped from review as they are similar to previous changes (3)
  • internal/agent/tool/registry.go
  • internal/agent/component/searxng.go
  • internal/agent/component/searxng_test.go

📝 Walkthrough

Walkthrough

Adds configurable SearXNG and WenCai tools, component wrappers, retrieval-state handling, registry validation, and tests covering metadata, invocation, errors, workflow wiring, request behavior, and parameter validation.

Changes

Tool and component integration

Layer / File(s) Summary
Registry configuration
internal/agent/tool/registry.go
SearXNG and WenCai receive validated node-level configuration through dedicated builders and strict integer parsing.
SearXNG tool execution
internal/agent/tool/searxng.go, internal/agent/tool/searxng_test.go
SearXNG builds fixed search requests, uses pinned hosts and request timeouts, truncates results, preserves upstream fields, and returns structured errors.
SearXNG component and retrieval state
internal/agent/component/searxng.go, internal/agent/component/searxng_test.go, internal/agent/runtime/state.go, internal/agent/runtime/state_test.go
SearXNG renders hashed references within a token budget, preserves raw JSON, and stores deduplicated chunks and document aggregates in canvas state.
WenCai tool contract
internal/agent/tool/wencai.go, internal/agent/tool/wencai_test.go
WenCai stores defaults, exposes the Python-aligned schema, merges runtime parameters, returns an empty report envelope, and handles malformed input or cancellation.
WenCai component wrapper
internal/agent/component/wencai.go, internal/agent/component/wencai_test.go
WenCai exposes query/report metadata, skips blank queries, invokes the tool, and preserves tool-level errors.

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

Sequence Diagram(s)

sequenceDiagram
  participant SearXNGComponent
  participant SearXNGTool
  participant HTTPHelper
  participant SearXNGServer
  participant CanvasState
  SearXNGComponent->>SearXNGTool: Invoke with query and configuration
  SearXNGTool->>HTTPHelper: Send pinned search request
  HTTPHelper->>SearXNGServer: Request JSON search results
  SearXNGServer-->>HTTPHelper: Return result payload
  HTTPHelper-->>SearXNGTool: Return decoded results
  SearXNGTool-->>SearXNGComponent: Return results envelope
  SearXNGComponent->>CanvasState: Add retrieval chunks and document aggregates
Loading

Possibly related PRs

Suggested labels: 🧪 test, go

Poem

I’m a rabbit with references bright,
SearXNG hops through the searchlight.
WenCai brings reports in a tidy array,
Errors stay wrapped instead of astray.
Chunks bloom where canvas paths run—
Tests thump their paws: well done!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 2.70% 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 clearly summarizes the main change: aligning Go WenCai and SearXNG agent components with Python.
Description check ✅ Passed The description includes the required Summary section and gives enough context about the PR goals and tests.
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/tool/wencai.go (1)

116-127: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Merged params are computed then discarded.

params is merged from defaults + runtime args and then thrown away via _ = params, so mergeWencaiParams is effectively dead in the production path (only the JSON parse for the malformed-args error is actually exercised). This matches the "upstream disabled" intent, but if you don't plan to re-enable soon, the merge and the _ = params sink are removable; the parse alone covers the malformed-JSON contract.

As per coding guidelines: "Prefer deletion over compatibility shims... Remove dead tests, commented-out code, stale documentation, and 'move later' notes."

🤖 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/wencai.go` around lines 116 - 127, Remove the unused
parameter-merging path from the wencai handler, including the runtime parameter
variable, mergeWencaiParams call, and `_ = params` sink. Preserve the argsJSON
JSON unmarshalling so malformed arguments still return the existing parse error
response, while retaining the current empty report behavior.

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.

Nitpick comments:
In `@internal/agent/tool/wencai.go`:
- Around line 116-127: Remove the unused parameter-merging path from the wencai
handler, including the runtime parameter variable, mergeWencaiParams call, and
`_ = params` sink. Preserve the argsJSON JSON unmarshalling so malformed
arguments still return the existing parse error response, while retaining the
current empty report behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f6f39140-a2e4-47dc-af1e-8817859624fd

📥 Commits

Reviewing files that changed from the base of the PR and between 547bc86 and 7442200.

📒 Files selected for processing (10)
  • internal/agent/component/searxng.go
  • internal/agent/component/searxng_test.go
  • internal/agent/component/wencai.go
  • internal/agent/component/wencai_test.go
  • internal/agent/runtime/state.go
  • internal/agent/tool/registry.go
  • internal/agent/tool/searxng.go
  • internal/agent/tool/searxng_test.go
  • internal/agent/tool/wencai.go
  • internal/agent/tool/wencai_test.go

@yuzhichang

Copy link
Copy Markdown
Member

LGTM

@yuzhichang
yuzhichang merged commit d03b09b into infiniflow:main Jul 13, 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 💞 feature Feature request, pull request that fullfill a new feature. size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants