Repository navigation
Collapse execute_query into search_nodes as one agent query tool (closes #1640) - #1687
Conversation
#1640) E4B scored 10/12 on aichat-matrix; Scenario 5 ("List all my invoices") called execute_query instead of the expected search_nodes. Root cause was an ambiguous tool BOUNDARY, not a bad description: execute_query was a near-superset of search_nodes (it listed by type, filtered by title/content, filtered by property, and returned properties), so no prompt prose gave the model a clean rule for "list all X". Fix: make search_nodes the single agent query tool. It now covers title/keyword lookup, list-all-of-type, and typed property filtering (filters + sorting), and always returns node properties. execute_query / Tool::ExecuteQuery are deleted. Internally search_nodes routes by capability — title/type listing via the title index (NodeService::query_nodes), property filters via QueryService SQL json_extract (query_ops::execute_query) — so property queries keep the correct SQL path. Backend query_ops::execute_query, the daemon gRPC ExecuteQueryRequest, and the CLI query command are unchanged (separate layer). Skills, tool-strategy guidance, and test fixtures updated to the single tool. Verified: aichat-matrix against gemma-4-e4b-q4km is now 11/12 — Scenario 5 calls search_nodes, no regression on the other passing scenarios. Scenario 6 (the read-then-write turn that stops after the search) is the sole remaining failure and is moved to #1637, which now owns both query decomposition and read-then-write turn completion; it is not prompt-fixable and out of scope here. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Pragmatic Code Review — PR #1687Verdict: REQUEST CHANGES (one small but real functional bug; everything else is a nit). The architecture is sound and the tool-collapse is the right call — a single change away from mergeable. SummaryCollapsing the two overlapping query tools into one Findings[Critical/Blocker] Default-limit mismatch silently truncates "list all X"
When the model omits Pick one and make all three agree:
Given this is a listing tool now, 50 is the better default — but either way the contract and the code must match. (Principle: least astonishment / self-consistent API contract.) [Improvement] Two stale in-repo references to the removed agent toolThe PR says docs were updated in
Both are in hand-written sections (not the [Nit]
|
| # | Criterion (updated #1640) | Status |
|---|---|---|
| 1 | Root cause identified for Scenario 5 | ✅ Ambiguous tool boundary, documented |
| 2 | Root cause identified for Scenario 6 → moved to #1637 | ✅ Documented, #1637 owns it |
| 3 | Tool-collapse + skills/guidance/descriptions updated | ✅ (2 stale doc strings missed — improvement) |
| 4 | aichat-matrix vs E4B: Sc.5 passes, no regression, gap documented | ✅ 11/12 reported |
| 5 | quality:fix clean; tests pass | ✅ Reported; cargo check confirmed clean |
Recommendation: REQUEST CHANGES — fix the limit default (blocker), ideally sweep the two stale doc references while in there. Both are one-line changes; no re-architecture needed.
malibio
left a comment
There was a problem hiding this comment.
Review posted as a summary comment. NET: REQUEST CHANGES in spirit — one blocker (default search limit is 10 in code via DEFAULT_SEARCH_LIMIT but the schema/param doc advertise 50, silently truncating the 'list all X' flow this PR targets) plus two stale in-repo doc references to the removed 'execute_query' agent tool (cli/src/commands/query.rs:6, skill/SKILL.md:225). Architecture and the tool-collapse are sound; both fixes are one-liners. (Cannot use --request-changes on your own PR, hence a comment review.)
…doc refs
- Bump DEFAULT_SEARCH_LIMIT 10 → 50 so the tool honors its own schema contract
("default 50") and matches the server/CLI default. A bare "list all X" was
silently capped at 10 with no has_more signal — the exact flow this PR fixes.
DEFAULT_SEARCH_LIMIT has no other caller.
- Reword two in-repo doc strings that still called execute_query "the local
agent's tool" (it's now backend-only): cli/src/commands/query.rs and the
hand-written CLI section of skill/SKILL.md now point at QueryService / the
search_nodes property-filter path. SKILL.md --check still passes.
Skipped the 🟢 nit (query+filters routes the keyword to content, not title):
QueryService has no title-filter path, the degradation is intentional and
commented, and adding one is #1638/QueryService scope, not this PR's.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Review addressed (commit 30c0de6)✅ 🔴 Default-limit mismatch — bumped ✅ 🟡 Stale
⏭️ 🟢 Nit (query+filters → content, not title) — skipped intentionally. QueryService has no title-filter path; the degradation is deliberate and commented. Adding a title filter to QueryService is #1638/QueryService scope, not this PR's. Tests: agent lib (incl. tools) pass; SKILL.md sync check passes; pre-push gate (test:all + build + e2e) green. Re-Review DecisionNO RE-REVIEW NEEDED — all changes are one-line, low-risk (a constant value + two doc-comment rewords). No logic paths changed beyond the default value the schema already advertised; the skipped nit is documented. |
What & why
E4B scored 10/12 on
aichat-matrix.ts. Scenario 5 ("List all my invoices") calledexecute_queryinstead of the expectedsearch_nodes. The root cause was an ambiguous tool boundary, not a bad description:execute_querywas a near-superset ofsearch_nodes— it listed by type, filtered by title/content, filtered by property, and returned properties — so no amount of "prefersearch_nodes" prose gave the model a clean rule for "list all X".Change
Collapse the two agent query tools into one —
search_nodes:filters+sorting), and always returns nodeproperties.execute_query/Tool::ExecuteQueryare deleted (13 tools now, was 14).NodeService::query_nodes, the only path that filters by title); property filters →QueryServiceSQLjson_extract(query_ops::execute_query), so property queries keep the correct SQL path (not the slow in-memory one).query_ops::execute_query, the daemon gRPCExecuteQueryRequest, and the CLIquerycommand.Skills, tool-strategy guidance, and test fixtures updated to the single tool. Docs updated in nodespace-docs (data-layer.md Query System, prompt-skill-system.md whitelist, ADR-056 consequence).
Verification —
aichat-matrix.tsvsgemma-4-e4b-q4km: 11/12 (was 10/12)(none)(none)create_schemasearch_skills,search_nodes,create_nodesearch_nodes(wasexecute_query— the fix)search_nodes(stops beforeupdate_node)search_nodescreate_schemacreate_schemasearch_skills,create_nodesearch_skills,create_nodesearch_nodesScenario 5 is fixed; no regression on the other passing scenarios.
Scenario 6 is the sole remaining failure — by design, moved to #1637.
Expected sequence [search_nodes,update_node]... got: search_nodes: the model finds the node but stops before the write. This is not prompt-fixable (proven in #1637 via prompt-dump analysis) and needs query decomposition + read-then-write turn completion, both of which #1637 now owns. E4B reaches 12/12 once #1637 lands.Unit tests: agent 285, core-ops 40, nlp-chat 84, frontend 4104, aichat-matrix 21 — all pass.
quality:fixclean.Closes #1640.