Repository navigation
feat(agent): add Querit Contents tool - #18156
Conversation
📝 WalkthroughWalkthroughThe PR adds a Querit Contents tool for fetching webpage content. It adds request validation, retries, response validation, Go registration, component wiring, tests, and web canvas configuration. ChangesQuerit Contents
Estimated code review effort: 4 (Complex) | ~60 minutes Possibly related PRs
Suggested labels: Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant Canvas
participant QueritContentsTool
participant QueritAPI
Canvas->>QueritContentsTool: submit URLs and crawl options
QueritContentsTool->>QueritContentsTool: validate and merge parameters
QueritContentsTool->>QueritAPI: POST authenticated contents request
QueritAPI-->>QueritContentsTool: JSON response
QueritContentsTool-->>Canvas: return JSON output or structured error
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: 3
🧹 Nitpick comments (2)
web/src/pages/agent/form/querit-contents-form/index.tsx (2)
121-124: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove the inline switch handler.
Line 123 uses an inline JSX event handler. Pass a named handler instead. If the field handler accepts the boolean value, use
onCheckedChange={field.onChange}.As per coding guidelines: “Avoid inline JSX event handlers such as onClick={() => ...} and onChange={(e) => ...}; extract named handlers and reference them by name.”
🤖 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-contents-form/index.tsx` around lines 121 - 124, Update the Switch usage in the form field to reference a named handler instead of defining an inline JSX callback; since field.onChange accepts the boolean value, pass it directly through onCheckedChange={field.onChange}.Source: Coding guidelines
13-13: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse
useTranslationin this component.Line 13 imports
useTranslate. Replace it withuseTranslationfromreact-i18nextand preserve theflownamespace.As per coding guidelines: “Prefer useTranslation from react-i18next over project-wrapped utilities such as useTranslate.”
🤖 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-contents-form/index.tsx` at line 13, Replace the useTranslate import and usage in the querit contents form component with useTranslation from react-i18next, retaining the existing flow namespace configuration and translation 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.
Inline comments:
In `@agent/tools/querit.py`:
- Around line 262-288: Increase the timeout applied to _invoke so it covers the
configured request timeout for all retries plus the retry backoff, including the
maximum supported crawl_timeout. Preserve _request’s per-attempt timeout
calculation and add a test that verifies a timed-out first request is retried
successfully before the component timeout expires.
In `@web/src/pages/agent/form/querit-contents-form/index.tsx`:
- Line 106: Update the numeric Input for crawl_timeout in the form field render
to use a named change handler that passes event.target.valueAsNumber to
field.onChange, preserving the integer type when useWatchFormChange persists
form values.
- Around line 34-44: Update FormSchema’s urls validation to normalize
comma-separated input like _normalize_contents_urls, then require between one
and ten absolute HTTP/HTTPS URLs containing a host, matching
_validate_contents_inputs instead of only checking string length.
---
Nitpick comments:
In `@web/src/pages/agent/form/querit-contents-form/index.tsx`:
- Around line 121-124: Update the Switch usage in the form field to reference a
named handler instead of defining an inline JSX callback; since field.onChange
accepts the boolean value, pass it directly through
onCheckedChange={field.onChange}.
- Line 13: Replace the useTranslate import and usage in the querit contents form
component with useTranslation from react-i18next, retaining the existing flow
namespace configuration and translation behavior.
🪄 Autofix
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: 15010c5a-a2df-4910-88ba-622c9d5b7255
📒 Files selected for processing (26)
agent/tools/querit.pyinternal/agent/component/tool_component.gointernal/agent/component/tool_component_test.gointernal/agent/tool/querit.gointernal/agent/tool/querit_contents.gointernal/agent/tool/querit_contents_test.gointernal/agent/tool/registry.gointernal/agent/tool/registry_test.gotest/unit_test/agent/tools/test_querit_contents_unit.pyweb/src/components/operator-icon.tsxweb/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-contents-form/index.tsxweb/src/pages/agent/form/tool-form/constant.tsxweb/src/pages/agent/hooks/use-add-node.tsweb/src/pages/agent/hooks/use-agent-tool-initial-values.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/utils/clear-sensitive-fields.test.tsweb/src/pages/agent/utils/clear-sensitive-fields.ts
| @timeout(int(os.environ.get("COMPONENT_EXEC_TIMEOUT", "70"))) | ||
| def _invoke(self, **kwargs): | ||
| if self.check_if_canceled("QueritContents processing"): | ||
| return | ||
|
|
||
| values = {name: kwargs[name] if name in kwargs else getattr(self._param, name) for name in ("urls", "format", "crawl_timeout", "extras_meta")} | ||
| values["urls"] = _normalize_contents_urls(values["urls"]) | ||
|
|
||
| node_api_key = (self._param.api_key or "").strip() | ||
| api_key = node_api_key or (os.environ.get("QUERIT_API_KEY") or "").strip() | ||
| if not api_key: | ||
| return self._fail("Querit API key is required. Configure api_key or set QUERIT_API_KEY.") | ||
|
|
||
| try: | ||
| _validate_contents_inputs(**values) | ||
| response_data = self._request(_build_contents_payload(**values), api_key) | ||
| _validate_contents_response(response_data) | ||
| self.set_output("json", response_data) | ||
| return self.output("json") | ||
| except _QueritCanceled: | ||
| return | ||
| except (requests.RequestException, RuntimeError, TypeError, ValueError) as error: | ||
| return self._fail(_safe_error_message(error, api_key)) | ||
|
|
||
| def _request(self, payload: dict[str, Any], api_key: str) -> Any: | ||
| request_timeout = max(DEFAULT_TIMEOUT, payload["crawlTimeout"] + 5) | ||
| return _post_querit(self, QUERIT_CONTENTS_URL, payload, api_key, "QueritContents", request_timeout) |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift
Allow the retry budget before the component timeout expires.
Line 262 sets a 70-second default component timeout. Lines 286-288 allow a 65-second request for crawl_timeout=60. After one timed-out attempt, a retry has at most five seconds to complete. This prevents the advertised retry flow from working for the maximum valid crawl timeout.
Set the component timeout to cover all allowed attempts and backoff time. Alternatively, reduce the per-attempt timeout and document the resulting limit. Add a test where the first request times out and the next request succeeds.
🤖 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 262 - 288, Increase the timeout applied
to _invoke so it covers the configured request timeout for all retries plus the
retry backoff, including the maximum supported crawl_timeout. Preserve
_request’s per-attempt timeout calculation and add a test that verifies a
timed-out first request is retried successfully before the component timeout
expires.
| const FormSchema = z.object({ | ||
| api_key: z.string(), | ||
| urls: z.string().min(1), | ||
| format: z.enum([ | ||
| QueritContentFormat.Text, | ||
| QueritContentFormat.Markdown, | ||
| QueritContentFormat.Html, | ||
| ]), | ||
| crawl_timeout: z.coerce.number().int().min(1).max(60), | ||
| extras_meta: z.boolean(), | ||
| }); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
ast-grep outline agent/tools/querit.py --items all
sed -n '1,260p' agent/tools/querit.py
rg -n -C 4 --glob '*.py' --glob '*.go' --glob '*.ts' --glob '*.tsx' \
'QueritContents|crawl_timeout|extras_meta|urls|https?://' \
agent internal test webRepository: infiniflow/ragflow
Length of output: 50375
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- candidate Querit files ---'
fd -i 'querit|querit-contents-form' . | head -80
printf '%s\n' '--- backend symbols and URL parsing ---'
rg -n -C 5 --glob '*.py' --glob '*.go' \
'QueritContent|QueritContents|crawl_timeout|extras_meta|url.*split|split.*url|urlparse|HttpUrl|https?://' \
agent common api ragflow test 2>/dev/null | head -500
printf '%s\n' '--- frontend form ---'
FORM=$(fd -i -t f 'index.tsx' web/src/pages/agent/form | rg 'querit-contents-form')
cat -n "$FORM" | sed -n '1,220p'Repository: infiniflow/ragflow
Length of output: 39399
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- backend Querit implementations ---'
for f in agent/tools/querit.py internal/agent/tool/querit_contents.go internal/agent/tool/querit_contents_test.go test/unit_test/agent/tools/test_querit_contents_unit.py; do
if [ -f "$f" ]; then
printf '\n### %s (%s lines)\n' "$f" "$(wc -l < "$f")"
cat -n "$f" | sed -n '1,280p'
fi
done
printf '%s\n' '--- frontend form ---'
cat -n web/src/pages/agent/form/querit-contents-form/index.tsx | sed -n '1,240p'
printf '%s\n' '--- related frontend initialization and API types ---'
rg -n -C 5 --glob '*.{ts,tsx}' \
'QueritContents|QueritContentFormat|crawl_timeout|extras_meta|querit_contents' \
web/src | head -300Repository: infiniflow/ragflow
Length of output: 50374
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- Python normalization and validation ---'
sed -n '280,430p' agent/tools/querit.py
printf '%s\n' '--- frontend values, serialization, and submission path ---'
for f in \
web/src/pages/agent/constant.ts \
web/src/pages/agent/hooks/use-watch-form-change.ts \
web/src/pages/agent/hooks/use-form-values.ts \
web/src/pages/agent/hooks/querit-agent-initial-values.ts \
web/src/pages/agent/form/querit-contents-form/index.tsx; do
if [ -f "$f" ]; then
printf '\n### %s\n' "$f"
cat -n "$f" | sed -n '1,260p'
fi
done
printf '%s\n' '--- exact frontend references ---'
rg -n -C 8 --glob '*.{ts,tsx}' \
'initialQueritContentsValues|useWatchFormChange|QueritContents|urls' web/src/pages/agent \
| head -450Repository: infiniflow/ragflow
Length of output: 49946
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- URL variable and PromptEditor behavior ---'
rg -n -C 6 --glob '*.{ts,tsx,py,go}' \
'PromptEditor|QueryVariable|replace.*variable|variable.*replace|sys\.|urls.*split|split.*urls|urlparse\(' \
web/src agent internal common | head -500
printf '%s\n' '--- comparable URL schemas ---'
rg -n -C 5 --glob '*.{ts,tsx}' \
'z\.(string|array).*url|z\.string\(\)\.url|absolute HTTP|URL|urls:' \
web/src/pages/agent | head -300
printf '%s\n' '--- targeted backend validation probe ---'
python3 - <<'PY'
from urllib.parse import urlparse
def normalize(value):
if isinstance(value, str):
return [part.strip() for part in value.split(",") if part.strip()]
return value
def backend_accepts(value):
urls = normalize(value)
if not isinstance(urls, list) or not 1 <= len(urls) <= 10:
return False
if any(not isinstance(url, str) or not url.strip() for url in urls):
return False
return all(urlparse(url).scheme in {"http", "https"} and bool(urlparse(url).netloc) for url in urls)
cases = {
"": False,
"not a url": False,
"ftp://example.com": False,
"example.com": False,
"https://one.example, https://two.example": True,
",".join(f"https://{i}.example" for i in range(11)): False,
"https://example.com": True,
}
for value, expected in cases.items():
actual = backend_accepts(value)
print(f"{actual!s:5} expected={expected!s:5} value={value!r}")
assert actual == expected
PYRepository: infiniflow/ragflow
Length of output: 49602
Validate the URL contract in FormSchema.
z.string().min(1) accepts invalid schemes and more than ten URLs. Match _normalize_contents_urls and _validate_contents_inputs: normalize comma-separated values, then require one to ten absolute HTTP/HTTPS URLs with a host.
🤖 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-contents-form/index.tsx` around lines 34 -
44, Update FormSchema’s urls validation to normalize comma-separated input like
_normalize_contents_urls, then require between one and ten absolute HTTP/HTTPS
URLs containing a host, matching _validate_contents_inputs instead of only
checking string length.
| {t('queritContentsTimeout')} | ||
| </FormLabel> | ||
| <FormControl> | ||
| <Input type="number" min={1} max={60} step={1} {...field} /> |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
ast-grep outline web/src/pages/agent/hooks/use-watch-form-change.ts --items all
sed -n '1,240p' web/src/pages/agent/hooks/use-watch-form-change.ts
rg -n -C 4 --glob '*.go' --glob '*.py' --glob '*.ts' --glob '*.tsx' \
'crawl_timeout|QueritContents' internal agent test webRepository: infiniflow/ragflow
Length of output: 50374
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- QueritContentsForm ---'
sed -n '1,180p' web/src/pages/agent/form/querit-contents-form/index.tsx
printf '%s\n' '--- useWatchFormChange consumers ---'
rg -n -C 5 'useWatchFormChange|updateNodeForm|replaceNodeForm' web/src/pages/agent \
-g '*.{ts,tsx}'
printf '%s\n' '--- React Hook Form and resolver versions ---'
rg -n -C 2 '"react-hook-form"|"`@hookform/resolvers`"|"zod"' \
package.json web/package.json pnpm-lock.yaml yarn.lock package-lock.json 2>/dev/null || true
printf '%s\n' '--- form value and node serialization helpers ---'
rg -n -C 6 'function useFormValues|export.*useFormValues|updateNodeForm|replaceNodeForm|nodeForm' \
web/src/pages/agent/hooks web/src/pages/agent/store web/src/pages/agent -g '*.{ts,tsx}' \
| head -n 400Repository: infiniflow/ragflow
Length of output: 50375
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- package manifests ---'
git ls-files '*package.json' '*lock*' | head -n 80
for file in $(git ls-files '*package.json' | head -n 20); do
if rg -q '"react-hook-form"|"`@hookform/resolvers`"' "$file"; then
printf '%s\n' "--- $file ---"
rg -n -C 2 '"react-hook-form"|"`@hookform/resolvers`"|"zod"' "$file"
fi
done
printf '%s\n' '--- graph store update methods ---'
sed -n '500,560p' web/src/pages/agent/store.ts
printf '%s\n' '--- graph save paths mentioning nodes/forms ---'
rg -n -C 5 'save.*graph|graph.*save|data\.form|JSON\.stringify|nodes' \
web/src/pages/agent -g '*.{ts,tsx}' \
| rg -n -C 3 'save|form|nodes|JSON' | head -n 350
printf '%s\n' '--- backend timeout type checks ---'
rg -n -C 4 'crawl_timeout|crawlTimeout' agent internal -g '*.{py,go}' | head -n 260Repository: infiniflow/ragflow
Length of output: 31536
🏁 Script executed:
#!/bin/bash
set -u
printf '%s\n' '--- save hook ---'
save_file=$(git ls-files 'web/src/pages/agent/hooks/use-save-graph.ts' | head -n 1)
if [ -n "$save_file" ]; then
sed -n '1,260p' "$save_file"
else
printf '%s\n' 'save hook not found'
fi
printf '%s\n' '--- backend Querit contents implementation ---'
for file in $(git ls-files 'agent/tools/querit.py' 'internal/agent/tool/querit_contents.go'); do
printf '%s\n' "--- $file ---"
if [ "$file" = 'agent/tools/querit.py' ]; then
sed -n '245,290p' "$file"
sed -n '357,385p' "$file"
else
sed -n '30,55p' "$file"
sed -n '128,205p' "$file"
fi
done
printf '%s\n' '--- numeric input registrations ---'
rg -n -C 3 'type="number"|valueAsNumber|crawl_timeout' web/src/pages/agent \
-g '*.{ts,tsx}' | head -n 240Repository: infiniflow/ragflow
Length of output: 20396
Preserve the numeric type for crawl_timeout.
useWatchFormChange stores raw form.getValues(), and z.coerce.number() does not normalize that value before persistence. Pass a named change handler that calls field.onChange(event.target.valueAsNumber) so the backend receives an integer.
🤖 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-contents-form/index.tsx` at line 106, Update
the numeric Input for crawl_timeout in the form field render to use a named
change handler that passes event.target.valueAsNumber to field.onChange,
preserving the integer type when useWatchFormChange persists form values.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #18156 +/- ##
=======================================
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 Contents as a built-in page content tool for RAGFlow Agents and Canvas workflows.
Querit Contents crawls one or more known URLs and returns their page content and optional metadata. It complements the existing Querit Search tool: Search discovers relevant pages, while Contents retrieves pages already selected by an Agent or workflow.
This integration supports two usage modes:
QueritContentsnode in Canvas workflows.What changed
Supported parameters
urlsformattext,markdown, orhtml. Defaults tomarkdown.crawl_timeout1to60seconds. Defaults to10.extras_metafalse.Authentication
The API key can be configured on the Querit Contents 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
POST https://api.querit.ai/v1/contentswith Bearer authentication.urls,format,crawlTimeout, andextrasMetarequest payload.successandfailedstatuses when only part of a batch can be crawled.Scope
This PR adds the Querit Contents Agent Tool and Canvas component. It does not change Chat Web Search provider selection, reasoning-mode scheduling or gating, managed credentials, custom provider endpoints, or credential hosting.
Testing
15 passed.2 suites passed,15 tests passed.text/markdown/html, metadata enabled/disabled, mixed success/404 status, and the documented 10-URL limit.git diff --checkpassed.Screenshots
Canvas tool menu
Canvas node configuration
Canvas content result
Multi-URL content result
Querit Contents successfully crawls the Querit Contents documentation and the RAGFlow Quickstart documentation in one request.