Skip to content

Trim the lookup request: drop duplicated skill and schema text - #3717

Merged
malibio merged 2 commits into
mainfrom
issue-3704-lookup-prefill
Oct 11, 2026
Merged

malibio merged 2 commits into
mainfrom
issue-3704-lookup-prefill

Conversation

@malibio

@malibio malibio commented Oct 11, 2026 •

Copy link
Copy Markdown
Collaborator

What

A lookup turn's first request is the cost that is left on the local model: its prefill is almost all of the turn's model time. This trims what that request carries where the same thing was already said twice.

  • The Research & Search reference no longer restates search_semantic's parameter descriptions (the schema carries them) or search_nodes' own one-line summary.
  • run_query copied search_nodes' filter item, so the long explanations of type, value, path went out twice in one request. Its copy keeps the structure and the rules a model breaks most, each text standing alone because the surface can offer run_query without search_nodes.

Measured (local gemma-4-e4b, lookup turns, first request)

before after
prompt tokens 6.77K 6.41K (-5.3%)
system prompt 11.5K bytes 10.3K
tool schemas 16.6K bytes 16.1K
time to first token, median 10.3s (n=6) 10.2s (n=21, range 9.3-12.2s)

The token cut is deterministic. The time difference is within noise: 5% fewer tokens predicts about half a second, and run-to-run spread is wider than that. Claim the token figure, not a latency one.

The seven lookup scenarios of the grounding eval pass 3 of 3 (21 of 21). None of them calls run_query with filters, so they show no regression from the seed trim and say nothing about the shortened filter text; that text was kept self-sufficient instead, and a registration test pins that every filter field has a description.

This is a small cut by design: both edits remove duplicated text only. The first request is still ~6.4K tokens; going further means dropping capability (search_semantic's rarely used parameters, or tools from the lookup surface), which needs its own decision.

refs #3704

🤖 Generated with Claude Code

https://claude.ai/code/session_01Y6xprEu6D5YSLfMUWqZsoj

@malibio

malibio commented Oct 11, 2026

Copy link
Copy Markdown
Collaborator Author

Code Review Summary

Net positive and small. Both edits remove text that really is duplicated in the same request, no code path changes, and nothing in the repo asserts the removed text (the only consumer is the stage2_lookup_block.golden, regenerated in this PR; stage2_tool_surface.golden does not pin run_query's filter descriptions). The PTY/CLI skill package reads seeds/rules/skill-md/research-search-reference.md, a separate file this PR does not touch, so external agents are unaffected. The agent-only rules/agent/ copy is the one trimmed. Findings below are minor; none block.

Findings

Critical Issues

None.

Suggested Improvements

  • [Improvement] tools.rs def_run_query, value description. The long form in search_nodes carries the sentence "Filters only narrow WHICH nodes are returned; every matching node comes back with all of its properties, so never filter just to read a property." That sentence exists because of a recorded failure (the value: null "give me signed_date" shape that ended a turn in an internal error). The shortened copy keeps "Never null; use exists", which stops the null shape, but drops the cause. On the surfaces at skill_pipeline.rs:815 and :836, run_query is offered without search_nodes, so this is the only filter text the model sees there. Mitigation is decent: run_query's own filters description says it "narrows this one run", and the null rule remains. Consider restoring one clause ("filters only narrow; every node comes back with all properties") if those skills show any filter-misuse in evals. Also the type union still allows number/boolean, but the text now says only "string ... array"; fine, just noting.
  • [Improvement] path description lost the relationship vocabulary. Original listed child_of (parent), has_child, mentions, mentioned_by, and "a schema-declared relationship or its reverseName works too". The short form gives only ["child_of"]. For the no-search_nodes surfaces, a model asked to narrow a saved query by "children of X" now has to guess has_child. The node_id example ("selects the children of X") also went. If you want to keep the saving, retain the four names in one short clause (about 30 tokens).
  • [Improvement] Lost hints with no schema twin (minor). Check against def_search_semantic: every PARAMETER GUIDANCE bullet is covered by the schema (collection, node_types, threshold incl. 0.1-0.2, include_archived, exclude_collections, include_edges, graph_boost, property_filters). Two judgments did not carry over verbatim: "prefer node_types over property_filters for type filtering" (the node_types description does say "Use for type filtering", so it is mostly covered), and include_edges "saves a separate get_related_nodes call" (schema says "Reduces round-trips"). graph_boost's "useful when the user wants the most referenced/central node" is also reduced to the formula. None of this looks load-bearing; it is the kind of thing the eval would not catch either way.
  • [Improvement] Overclaim risk in the PR text. The token drop (6.77K to 6.33K, 6.5%) is deterministic and credible, and the byte breakdown (system -1.2K, tools -0.9K) adds up plausibly. The 10.3s to 9.9s first-token figure is a 3.9% change on a median with no spread or sample count stated; that is within normal run-to-run noise for a local 4B model and is roughly what 6.5% less prefill predicts, so report it as consistent with the token cut, not as an independent measurement. The "21/21" figure shows no regression on the seven lookup scenarios; it cannot show the shortened run_query text is sufficient, because those scenarios mostly route through search_nodes/search_semantic. Say which of the 21 runs exercised run_query with filters, or say none did. The assign-to-person failure noted as a known 4B limit is fine, but the PR notes it passed once by chance in baseline, so it carries no signal either way.

Nitpicks

  • Nit: tools.rs: the loop filter_item["properties"][key]["description"] = ... indexes without checking. The existing comment already admits a moved search_nodes schema degrades silently, and serde_json IndexMut will create the missing keys as null-then-object, producing a property with only a description and no type. A registration-test assertion that each of type, property, value, path, node_id still carries type/enum in run_query's item would turn that into a loud failure.
  • Nit: the comment says run_query's filters are "the rare call"; that is a claim about usage, worth one line of evidence or softening to "optional".

Verdict

APPROVE (comment-only, since self-approval is blocked). Merge is the user's call. Suggested follow-up inside this PR if cheap: restore the path relationship names and the "filters only narrow" clause for the run_query-without-search_nodes surfaces.

@malibio malibio left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Verdict: APPROVE with minor improvements; no blockers. Full review in the comment above (run_query path/filters text on the surfaces without search_nodes; measurements consistent but not independent evidence for run_query sufficiency).

@malibio

malibio commented Oct 11, 2026

Copy link
Copy Markdown
Collaborator Author

Address-review summary

Review verdict was APPROVE with minor improvements. Addressed all four points.

Addressed

  • run_query without search_nodes (Important). skill_pipeline.rs offers run_query on surfaces with no search_nodes, so the shortened filter text has to stand alone. Restored, in one clause each: that a filter only narrows and never selects a field (the earlier value: null failure), the relationship names for path (child_of, has_child, mentions, mentioned_by, schema names), and the "children of X" example for node_id.
  • Registration test. run_query_is_registered_seeded_and_offered now asserts that type, property, value, path, node_id and negate each carry a non-empty description, so a moved search_nodes schema fails the test instead of leaving a field described by nothing.
  • Unevidenced comment. The claim that a saved query's extra filter is "the rare call" is gone from the comment; it now says why the texts stand alone.
  • Measurements. Re-measured on the final tree: prompt tokens 6.77K -> 6.41K (-5.3%); the first-token time (10.3s -> 10.2s median, range 9.3-12.2s over 21 requests) is within noise and the PR body no longer presents it as an improvement. It also says plainly that the 21 scenario runs do not exercise run_query filters.

Not changed

  • Nothing skipped.

bun run test:changed and bun run quality:fix pass on the pushed tree.

Re-Review Decision

Decision: NO RE-REVIEW NEEDED

Rationale: Three description strings restored, one test assertion added, one comment reworded, and the PR text corrected; no logic changed.

malibio and others added 2 commits October 11, 2026 15:42
…rten run_query's copy of the filter schema (refs #3704)

The Research & Search reference restated search_semantic's parameter
descriptions and search_nodes' own summary; run_query sent search_nodes'
long filter explanations a second time in the same request. On the local
model a lookup turn's first request goes from 6.77K to 6.33K prompt tokens
(system 11.5K to 10.3K bytes, tools 16.6K to 15.7K) and its median time to
first token from 10.3s to 9.9s. The seven lookup scenarios pass 3 of 3.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y6xprEu6D5YSLfMUWqZsoj
@malibio
malibio force-pushed the issue-3704-lookup-prefill branch from ee19481 to 2d2b513 Compare October 11, 2026 13:43
@malibio
malibio merged commit b0f8756 into main Oct 11, 2026
@malibio
malibio deleted the issue-3704-lookup-prefill branch October 11, 2026 13:43
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.

1 participant