Skip to content

feat(agent): add Querit search tool - #5

Merged
ethan7zhanghx merged 4 commits into
feat/querit-search-toolfrom
feat/querit-go
Jul 28, 2026
Merged

ethan7zhanghx merged 4 commits into
feat/querit-search-toolfrom
feat/querit-go

Conversation

@zhaoxinzeng

@zhaoxinzeng zhaoxinzeng commented Jul 28, 2026 •

Copy link
Copy Markdown

Summary

Add Querit web search support to the Go Agent runtime and expose it as the QueritSearch Canvas component, aligned with the existing Python/frontend contract.

Behavior

  • Registers querit, querit_search, and queritsearch aliases.
  • Reads credentials from node configuration, falling back to QUERIT_API_KEY; model-emitted runtime arguments cannot override credentials.
  • Supports query, count, chunks_per_doc, site filters, time_range, country filters, and language filters.
  • Accepts dN, wN, mN, yN, and YYYY-MM-DDtoYYYY-MM-DD time ranges.
  • Declares all list arguments as arrays of strings in the model-facing schema.
  • Preserves complete JSON responses and large numeric fields for Canvas output.
  • Rejects malformed or multi-value/trailing JSON responses as recoverable soft errors.
  • Rejects explicit null response containers while allowing omitted results or result fields.
  • Writes sanitized, bounded search references into Canvas retrieval state.
  • Retries HTTP 429 responses up to three attempts and redacts active API keys from failures.

Validation

  • Querit Go tool tests passed with Go 1.26.5 and CGO_ENABLED=0 using the repository's no-CGO compatibility path.
  • Focused credential-boundary, malformed-response, schema, and response-shape tests passed.
  • TestToolBackedComponentQueritIntegration and TestParseToolEnvelopeLosslessRejectsTrailingContent passed.
  • gofmt passed for all changed Go files.
  • git diff --check passed.
  • The repository build.sh --test native-link path could not run on the local Apple Silicon host because the required x86/Linux native archives are unavailable; this is an environment limitation rather than a test failure.

Scope

This PR adds only the Go runtime and Canvas adapter for the already implemented Querit integration. It does not change the Python/frontend parameter contract or other search tools.

@ethan7zhanghx ethan7zhanghx left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review result: REQUEST CHANGES. The current head (d7cbadf5a13c2df4989fb89603991d4d914d3575) is not merge-ready.

Required changes:

  1. The new component test does not compile. ToolBackedComponent.Invoke requires (ctx, db, inputs), but the calls at internal/agent/component/tool_component_test.go:499 and :506 omit the db argument. Pass nil as the second argument.

  2. Align time_range with the already merged Querit contract. The frontend and Python implementation accept dN, wN, mN, yN, and YYYY-MM-DDtoYYYY-MM-DD; the Go implementation currently accepts only dN/mN and comma/.. date separators. It also adds calendar/order validation that the shared contract does not define. Values accepted and persisted by the UI, such as w1, y1, and 2026-01-01to2026-01-31, currently fail at runtime.

  3. Preserve large numeric fields in the complete Canvas JSON output. parseToolEnvelope decodes into map[string]any with json.Unmarshal, so a real Querit search_id such as 11099848653006015581 becomes a float64 and changes to 11099848653006016512. Use json.Decoder.UseNumber() or an equivalent lossless representation, and add a full ToolBackedComponent regression test with a numeric search_id.

  4. Complete the non-string query validation. Numeric query values are rejected, but {"query": null} and a missing query decode to an empty Go string and are treated as successful empty searches. The established Python behavior only treats an actual empty string as a no-op; null or missing/non-string values must return _ERROR without a network request.

  5. Validate the Querit response shape. The Go path checks only that the top level is a JSON object. A non-object results or non-array results.result is silently converted into zero references. Match the Python behavior and return a soft _ERROR for malformed response shapes so upstream contract changes are not reported as successful empty searches.

  6. Keep Canvas output/reference behavior aligned with the existing implementation. An empty query currently returns {"results":{"result":[]}} instead of json: {}. Reference construction should also skip empty snippets, remove inline base64 image payloads, and cap each snippet at 10,000 characters, as the existing Python/Tavily paths do.

  7. Align explicit chunks_per_doc: null handling. The Python contract and its regression test omit chunksPerDoc in this case; the Go implementation currently converts null to zero and returns a validation error.

Verification performed:

  • gofmt on all changed Go files: passed.
  • git diff --check: passed.
  • Targeted Go component tests: compilation failed at the two Invoke calls above.
  • The tool package reached native linking but could not complete locally because this checkout does not contain internal/binding/cpp/cmake-build-release/librag_tokenizer_c_api.a; this is a local environment limitation, not evidence that the package tests pass.
  • GitHub currently reports no CI checks for this PR.

Please also replace the placeholder PR description with the implemented behavior, contract mapping, and exact validation evidence before requesting another review.

@zhaoxinzeng

zhaoxinzeng commented Jul 28, 2026 via email

Copy link
Copy Markdown
Author

@ethan7zhanghx

Copy link
Copy Markdown

Follow-up after reviewing the latest head (b4ca1403db5b3a12a256908c535b33069a42201e) and the stacked PRs:

  • The time_range contract is now correctly aligned with the frontend/Python contract, and the new coverage for dN/wN/mN/yN/YYYY-MM-DDtoYYYY-MM-DD is appropriate. Item 2 in my review is resolved.
  • Items 1 and 3–7 remain unresolved at the latest head. In particular, the two ToolBackedComponent.Invoke calls still do not compile.

One additional required security fix was found during the cross-PR review: queritErrorJSON inserts err.Error() verbatim and does not redact the active node or environment API key. The current tests only use error messages that do not contain a credential, so they do not prove redaction. A transport error containing text such as Bearer <active-key> would currently expose that key through _ERROR. Please apply explicit redaction equivalent to the Python implementation and add regression tests for both node-level and QUERIT_API_KEY credentials.

The PR description is still the placeholder template and GitHub still reports no CI checks.

@ethan7zhanghx
ethan7zhanghx merged commit f200755 into feat/querit-search-tool Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants