Repository navigation
feat(agent): add Querit search tool - #17548
Conversation
Establish the compile-safe Querit operator contract, shared defaults, minimal frontend registrations, and English/Chinese copy for parallel implementation.
Adds the standalone Querit Canvas form, validated field serialization, node rehydration, and guarded persistence for invalid or blank values.
feat(agent): add Querit Agent tool UI
* feat(agent): add Querit search tool * fix(agent): align Querit time range contract * fix(agent): address Querit Go review feedback * fix(agent): align Querit Go runtime boundaries --------- Co-authored-by: zengzhaoxin <[email protected]> Co-authored-by: EthanZhang <[email protected]>
* fix(agent): harden Querit integration boundaries * fix(agent): align Querit language guidance * fix(agent): scope Querit Canvas export redaction
This reverts commit 29dfd29.
…upstream-ready # Conflicts: # web/src/pages/agent/hooks/use-export-json.ts
This reverts commit c4ac6f5.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (13)
🚧 Files skipped from review as they are similar to previous changes (13)
📝 WalkthroughWalkthroughQuerit web search is added across Python and Go runtimes, Canvas component registration, request validation and retries, lossless JSON handling, reference extraction, registry aliases, and the web interface with forms, persistence, localization, icons, and sensitive-field removal. ChangesQuerit search implementation
Estimated code review effort: 5 (Critical) | ~120 minutes 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: 7
🧹 Nitpick comments (6)
internal/agent/component/tool_component.go (1)
106-117: 🩺 Stability & Availability | 🔵 Trivial | 💤 Low value
nullpayload returns a nil map rather than_raw.
json.Decoder.Decodeonnullsucceeds and leavesoutnil, so the envelope passes the_rawcheck and flows intoBuildComponentOutputsas a nil map. Reads are safe, but the failure surfaces as an empty result instead ofcanvas: ...: invalid tool result. A nil check would make it explicit.🛡️ Proposed guard
if err := decoder.Decode(&struct{}{}); err != io.EOF { return map[string]any{"_raw": jsonStr} } + if out == nil { + return map[string]any{"_raw": jsonStr} + } return out🤖 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/tool_component.go` around lines 106 - 117, Update parseToolEnvelopeLossless to detect a nil out map after decoding, including JSON null, and return the existing _raw fallback in that case so invalid payloads reach BuildComponentOutputs as an invalid tool result.internal/agent/tool/registry.go (1)
553-553: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueUse
queritToolNameinstead of repeating the literal.The constant already exists in
internal/agent/tool/querit.go; using it keeps the error strings in sync if the canonical name changes.Also applies to: 560-560, 567-567, 584-584, 589-589
🤖 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/registry.go` at line 553, Replace the repeated "querit_search" literals in the error messages within the tool parameter validation logic with the existing queritToolName constant from querit.go, including the noted occurrences, so all messages stay synchronized with the canonical tool name.agent/tools/querit.py (1)
210-212: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low valueConsider honoring
Retry-Afterand draining the body on retryable statuses.For 429/503 the upstream commonly returns
Retry-After; the fixeddelay_after_errorignores it. Also, the response body is neither read nor closed beforecontinue, so the connection can't be returned to the pool cleanly.♻️ Sketch
if response.status_code in QUERIT_RETRYABLE_STATUS_CODES and attempt + 1 < QUERIT_MAX_ATTEMPTS: + response.close() + logger.warning("Querit returned %s; retrying (attempt %s).", response.status_code, attempt + 1) self._wait_before_retry() continue🤖 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 `@agent/tools/querit.py` around lines 210 - 212, Update the retry branch in the request method around QUERIT_RETRYABLE_STATUS_CODES to consume and close the response before continuing, and use its Retry-After header when present to determine the wait duration, falling back to the existing delay_after_error otherwise.internal/agent/tool/querit.go (1)
277-280: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low valueResponse is decoded twice on the Canvas path.
decodeQueritResponsefully decodesrawonly for validation, then the string is re-decoded byparseToolEnvelopeLosslessininternal/agent/component/tool_component.go. For large search payloads that doubles parse cost/allocations. Acceptable if you prefer keeping the raw string contract, but worth noting.🤖 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/querit.go` around lines 277 - 280, Update the Canvas response flow around decodeQueritResponse to reuse its decoded result when constructing the tool envelope, instead of returning raw and causing parseToolEnvelopeLossless to decode it again. Preserve the existing queritErrorJSON handling for decode failures and the response behavior for valid payloads.web/src/pages/agent/form/querit-form/dynamic-list.tsx (1)
56-68: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winExtract the click handlers.
Lines 61 and 68 use inline JSX handlers. Move them to named handlers before passing them to the buttons.
Proposed change
+ const handleRemove = (index: number) => () => remove(index); + const handleAppend = () => append({ value: '' }); + return ( ... - onClick={() => remove(index)} + onClick={handleRemove(index)} ... - <BlockButton type="button" onClick={() => append({ value: '' })}> + <BlockButton type="button" onClick={handleAppend}>As per coding guidelines, “Avoid inline JSX event handlers such as
onClick={() => ...}.”🤖 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 `@web/src/pages/agent/form/querit-form/dynamic-list.tsx` around lines 56 - 68, Replace the inline onClick callbacks in the remove Button and BlockButton within the dynamic list rendering with named handler functions declared before the JSX, preserving the existing remove(index) and append({ value: '' }) behavior. Pass the handlers to each button, using the item index where required.Source: Coding guidelines
web/src/pages/agent/form/querit-form/utils.ts (1)
19-21: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a message to the
time_rangerefine for clearer form feedback.Without a custom message,
FormMessagewill surface Zod's generic default error text when a user types an invalidtime_range(e.g. "last week"), rather than a hint like "expected d7, w2, m1, y1, or a YYYY-MM-DDtoYYYY-MM-DD range".♻️ Suggested fix
time_range: z .string() - .refine((value) => value === '' || QueritTimeRangePattern.test(value)), + .refine((value) => value === '' || QueritTimeRangePattern.test(value), { + message: 'Expected d7, w2, m1, y1, or YYYY-MM-DDtoYYYY-MM-DD', + }),🤖 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 `@web/src/pages/agent/form/querit-form/utils.ts` around lines 19 - 21, Update the time_range Zod refinement to provide a custom validation message when QueritTimeRangePattern rejects a non-empty value. Preserve the existing allowance for an empty string and use the requested hint describing valid d7, w2, m1, y1, or YYYY-MM-DDtoYYYY-MM-DD formats.
🤖 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/tool_component_test.go`:
- Around line 479-506: Replace the plain serverCalls counter in the QueritSearch
test with an atomic.Int32, increment it atomically inside the httptest handler,
and atomically load it when validating the empty-query result. Update the
assertion and failure message to use the loaded value while preserving the
expectation that no server request occurs.
In `@internal/agent/tool/querit.go`:
- Around line 214-229: Update InvokableRun so query validation occurs after
mergeQueritParams combines q.defaults, runtimeParams, and provided values,
allowing q.defaults.Query to satisfy an omitted node-level query. Reject only
when the merged query is absent, null, or not a string, while preserving the
existing empty-query response behavior.
In `@test/unit_test/agent/tools/test_querit_unit.py`:
- Line 521: Update the test secret assignment in the relevant test function to
explicitly suppress Ruff S105 for this intentional fixture value, preserving the
existing "secret-test-key" behavior.
In `@web/src/pages/agent/constant/index.tsx`:
- Around line 575-596: The json output definition in initialQueritValues uses
the wrong case for its type token. Update outputs.json.type from 'Object' to the
canonical lowercase 'object', preserving the remaining query defaults and output
structure.
In `@web/src/pages/agent/form/querit-form/use-watch-change.ts`:
- Around line 6-20: The useWatchFormChange effect currently persists normalized
values on the initial render, potentially marking unchanged forms as modified.
Add an initialization/change guard within useWatchFormChange so updateNodeForm
runs only after the watched form values have changed or become dirty, while
preserving persistence for subsequent edits.
In `@web/src/pages/agent/form/querit-form/utils.ts`:
- Around line 12-24: Update the query field in QueritFormSchema to reject empty
strings at schema validation, ensuring validateQueritFormValuesForPersistence
cannot save a node without a query. Keep the existing string validation and
other schema fields unchanged.
In `@web/src/pages/agent/log-sheet/tool-name.ts`:
- Around line 3-5: Update getToolOperatorName to handle missing, null, or empty
toolName values before calling replaceAll, preserving the existing safe fallback
returned by the formatter. Keep normalization unchanged for valid names, and add
a regression test covering an empty or missing tool_name input.
---
Nitpick comments:
In `@agent/tools/querit.py`:
- Around line 210-212: Update the retry branch in the request method around
QUERIT_RETRYABLE_STATUS_CODES to consume and close the response before
continuing, and use its Retry-After header when present to determine the wait
duration, falling back to the existing delay_after_error otherwise.
In `@internal/agent/component/tool_component.go`:
- Around line 106-117: Update parseToolEnvelopeLossless to detect a nil out map
after decoding, including JSON null, and return the existing _raw fallback in
that case so invalid payloads reach BuildComponentOutputs as an invalid tool
result.
In `@internal/agent/tool/querit.go`:
- Around line 277-280: Update the Canvas response flow around
decodeQueritResponse to reuse its decoded result when constructing the tool
envelope, instead of returning raw and causing parseToolEnvelopeLossless to
decode it again. Preserve the existing queritErrorJSON handling for decode
failures and the response behavior for valid payloads.
In `@internal/agent/tool/registry.go`:
- Line 553: Replace the repeated "querit_search" literals in the error messages
within the tool parameter validation logic with the existing queritToolName
constant from querit.go, including the noted occurrences, so all messages stay
synchronized with the canonical tool name.
In `@web/src/pages/agent/form/querit-form/dynamic-list.tsx`:
- Around line 56-68: Replace the inline onClick callbacks in the remove Button
and BlockButton within the dynamic list rendering with named handler functions
declared before the JSX, preserving the existing remove(index) and append({
value: '' }) behavior. Pass the handlers to each button, using the item index
where required.
In `@web/src/pages/agent/form/querit-form/utils.ts`:
- Around line 19-21: Update the time_range Zod refinement to provide a custom
validation message when QueritTimeRangePattern rejects a non-empty value.
Preserve the existing allowance for an empty string and use the requested hint
describing valid d7, w2, m1, y1, or YYYY-MM-DDtoYYYY-MM-DD formats.
🪄 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 Plus
Run ID: 180ffe39-a642-4ae3-b444-e3a345a44682
⛔ Files ignored due to path filters (1)
web/src/assets/querit.pngis excluded by!**/*.png
📒 Files selected for processing (44)
agent/tools/querit.pyinternal/agent/component/tool_component.gointernal/agent/component/tool_component_test.gointernal/agent/tool/querit.gointernal/agent/tool/querit_test.gointernal/agent/tool/registry.gointernal/agent/tool/registry_test.gointernal/agent/tool/tool2component.gointernal/common/environments.gotest/unit_test/agent/tools/test_querit_unit.pytools/gen-component-parity/main.goweb/src/constants/agent.tsxweb/src/locales/en.tsweb/src/locales/zh.tsweb/src/pages/agent/canvas/node/dropdown/accordion-operators.tsxweb/src/pages/agent/constant/index.tsxweb/src/pages/agent/form-sheet/form-config-map.tsxweb/src/pages/agent/form/agent-form/tool-popover/tool-command.tsxweb/src/pages/agent/form/querit-form/dynamic-list.tsxweb/src/pages/agent/form/querit-form/index.tsxweb/src/pages/agent/form/querit-form/use-values.tsweb/src/pages/agent/form/querit-form/use-watch-change.test.tsxweb/src/pages/agent/form/querit-form/use-watch-change.tsweb/src/pages/agent/form/querit-form/utils.test.tsweb/src/pages/agent/form/querit-form/utils.tsweb/src/pages/agent/form/tool-form/constant.tsxweb/src/pages/agent/form/tool-form/querit-form/index.tsxweb/src/pages/agent/form/tool-form/querit-form/use-watch-change.test.tsxweb/src/pages/agent/form/tool-form/querit-form/use-watch-change.tsweb/src/pages/agent/form/tool-form/querit-form/utils.test.tsweb/src/pages/agent/form/tool-form/querit-form/utils.tsweb/src/pages/agent/hooks/clear-sensitive-fields.tsweb/src/pages/agent/hooks/querit-agent-initial-values.tsweb/src/pages/agent/hooks/use-add-node.tsweb/src/pages/agent/hooks/use-agent-tool-initial-values.test.tsweb/src/pages/agent/hooks/use-agent-tool-initial-values.tsweb/src/pages/agent/hooks/use-export-json.test.tsweb/src/pages/agent/hooks/use-export-json.tsweb/src/pages/agent/log-sheet/tool-name.test.tsweb/src/pages/agent/log-sheet/tool-name.tsweb/src/pages/agent/log-sheet/tool-timeline-item.tsxweb/src/pages/agent/log-sheet/workflow-timeline.tsxweb/src/pages/agent/operator-icon.tsxweb/src/pages/agent/webhook-sheet/timeline.tsx
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #17548 +/- ##
=======================================
Coverage 90.65% 90.65%
=======================================
Files 10 10
Lines 717 717
Branches 118 118
=======================================
Hits 650 650
Misses 39 39
Partials 28 28 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
Add Querit as a built-in web search tool for RAGFlow Agents and Canvas workflows.
Querit provides real-time web search through the Querit Search API. This integration supports two usage modes:
QueritSearchnode in Canvas workflows.What changed
Supported parameters
querycount10.chunks_per_doc1to3. Defaults to3.site_includesite_excludetime_rangedN,wN,mN,yN, orYYYY-MM-DDtoYYYY-MM-DD.country_includelanguage_includeAuthentication
The API key can be configured on the Querit node or through the
QUERIT_API_KEYenvironment variable. A node-level key takes precedence.Querit API keys can be created at https://www.querit.ai/en/dashboard/api-keys.
Request behavior
filterspayload.429, and retryable5xxresponses up to three attempts.Testing
31 passed.7 suites passed,43 tests passed.Screenshots
Canvas node configuration
Canvas search result
Agent tool configuration
Agent search result