Skip to content

feat(tools): add opt-in literal keyword discovery - #6659

Merged
WillemJiang merged 1 commit into
bytedance:mainfrom
ZJPex:feat3-tool-search-keywords-dev
Oct 11, 2026
Merged

WillemJiang merged 1 commit into
bytedance:mainfrom
ZJPex:feat3-tool-search-keywords-dev

Conversation

@ZJPex

@ZJPex ZJPex commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

Related to #6658

Why

Deferred discovery treats notebook jupyter as a regex, so it misses jupyter_notebook despite both terms being present. Its tool description also incorrectly labels a bare phrase as keyword search.

What changed

Add keywords: for case-insensitive literal substring matching across names and descriptions in any term order. Rank by distinct term coverage, then name hits, with stable catalog ties and a five-tool cap. Process at most 256 characters after the prefix and 16 unique whitespace-separated terms; punctuation remains literal.

Bare regex queries, +required, exact uncapped select:, and schema promotion remain unchanged. Align the English tool description, README, and tools AGENTS guidance, and add regression tests.

Surface area

  • Frontend UI — page / component / setting / interaction under frontend/
  • Backend API — endpoint / SSE event / request-response shape under backend/app
  • Agents / LangGraph — agent node, graph wiring, langgraph.json, or prompt change
    • Prompt-layer self-check: only static query grammar and examples are added to the tool description; no user-influenceable values are interpolated into framework-owned system text.
  • Sandbox — docker/ or sandboxed execution
  • Skills — change under skills/
  • Dependencies — new/upgraded entry in backend/pyproject.toml or frontend/package.json (say what it buys us)
  • Default behavior change — changes existing behavior without the user opting in (default model, default setting, data shape)
  • Docs / tests / CI only — no runtime behavior change

Screenshots / Recording

Not applicable; no UI changes.

Validation

On Windows with Python 3.12 and PYTHONPATH=.:

  • uv run --no-sync ruff check . and uv run --no-sync ruff format --check . in backend/: passed.
  • uv run --no-sync pytest tests/test_deferred_keyword_search.py tests/test_deferred_catalog.py tests/test_deferred_setup.py tests/test_tool_search.py tests/test_deferred_filter_middleware.py tests/test_thread_state_promoted.py -q with a temporary cache directory: 57 passed.
  • python scripts/check_agent_guidance.py --base-ref origin/main --head-ref HEAD: 0 errors, 0 warnings.
  • Four offline pytest shards using the make test arguments all finished with exit code 1: 28,217 passed, 96 failed, 1,070 skipped, and 5 errors in total. Failures span existing channel, extension, shell, sandbox, file-reading, and web-extraction tests; no deferred-search test is listed among the failures. Observed errors include missing files (WinError 2), provider initialization failures (WinError 10106), and environment variables exceeding 32,767 characters. This is not a passing local full-suite result.
  • python -m pytest tests/blocking_io -q --tb=short: 240 passed, 2 failed, 4 skipped. Failures: factory heartbeat assertion in test_agent_factory_construction.py and memory timeout in test_dynamic_context_middleware.py.
  • Fork CI for 50cf8456: all eight runs across the implementation and CI branches completed successfully. On the CI branch, backend unit tests executed and passed all four shards and default-install collection; blocking IO, lint and agent guidance, frontend unit tests, and both replay layers executed and passed. These Linux CI results are separate from the failing Windows full-suite results above.

AI assistance

Tool(s) used: Codex.

How you used it: Inspected the catalog and repository guidance, implemented the query mode and regression tests, synchronized documentation, and ran validation.

  • I've read and understand every line of this change and take responsibility for it — it's not unreviewed AI output.

@github-actions github-actions Bot added area:backend Gateway / runtime / core backend under backend/ area:docs Documentation and Markdown only risk:medium Medium risk: regular code changes size/M PR changes 100-300 lines labels Oct 11, 2026
@WillemJiang
WillemJiang requested a balanced review from Copilot October 11, 2026 02:57

Copilot AI 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.

🟢 Approval recommended

The implementation matches the stated contract and includes focused regression coverage.

0 open findings

What changed in this PR

Adds opt-in literal keyword discovery for deferred MCP tools while preserving existing regex and exact-selection behavior.

Changes:

  • Implements bounded, case-insensitive keyword ranking.
  • Adds regression coverage for ranking, limits, Unicode, and promotion.
  • Synchronizes user and contributor documentation.
File Description
README.md Documents keyword query semantics.
backend/​tests/​test_deferred_keyword_search.py Covers keyword discovery behavior.
backend/​packages/​harness/​deerflow/​tools/​builtins/​tool_search.py Implements literal keyword ranking.
backend/​packages/​harness/​deerflow/​tools/​AGENTS.md Records the query contract.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@WillemJiang WillemJiang added this to the 2.2.0 milestone Oct 11, 2026
@WillemJiang
WillemJiang merged commit 128dafd into bytedance:main Oct 11, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:backend Gateway / runtime / core backend under backend/ area:docs Documentation and Markdown only risk:medium Medium risk: regular code changes size/M PR changes 100-300 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants