Repository navigation
Tool RAG: lexical projection of the bound tool catalog (off by default) - #204
Merged
Merged
Conversation
When ARTEX_TOOL_RAG is enabled, AugmentTools keeps the core tools plus the top-k (ARTEX_TOOL_RAG_TOPK, default 12) BM25-ranked bound tools for the worker intent / planner goal. Runs after ToolResolve, so it only removes; falls back to the full list on empty query, catalog under 20, or scorer error.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
When an agent's bound tool list is large (custom tools, host tools), inject only the subset relevant to the current intent/round instead of every schema. This is a projection of the already-bound list: it only removes tools, never adds one, never edits a description or schema, never reads the database or touches the UI. Bindings (the
toolstable viaToolResolve) stay the source of truth.Shipped OFF by default. Nothing changes until
ARTEX_TOOL_RAGis set. This is a deliberate choice so behaviour does not move before it is measured; the owner decides whether to flip it.Design
agent/assembly.go,AugmentTools, right afterToolResolve(binding + enabled filters) and beforefindingWorkflowTools, so the finding guidance is computed on the projected list and never mentions a hidden tool.WithToolQuery). Worker: the intent summary (nodeSummary(intent); the worker has no goal in scope). Planner:plannerToolQuery(goal, triggers)= goal + the short texts the round's triggers already carry (no store lookups). Main agent and chat set no query, so they always get the full list.type ToolScorer func(query string, tools []actool.CoreTool) ([]float64, error). The default isbm25Score, Okapi BM25 (k1=1.2, b=0.75) over the tool name, description and parameter names. Tokens are lowercased and split on non-alphanumerics, and IDF is computed over the candidate set. It is pure: no network, no embeddings, no external calls.record_fact, insert_assets, report_finding, list_findings, graph_overview, node_detail, add_intent, steer_work, ask_operator, prove_goal, goal_met, list_assets.Read/Write/Edit/MultiEdit/LS/Glob/Grep/Bash/Sleep), the interactiveshell_*tools and theSkillmeta-tool. Removing them would break the worker (Bash, Read, Write and Skill are how it does its work).ARTEX_TOOL_RAG(1/true/on/yesenables; default off),ARTEX_TOOL_RAG_TOPK(non-core tools kept; default 12).[tool-rag]line per assembly, with either the selected tool names or the fallback reason.Tests (
agent/toolrag_test.go, pure: no database, no network)ToolResolve(unbound or disabled) is never selected, even when it is the best lexical match. This one runs throughAugmentToolswith a stub resolver.actool.DefaultTools(),Skilland one deferred name, with a query that matches something else. Bash, the other SDK tools, Skill and the deferred tool all stay; only the top-1 candidate is added.Expected effect today: none
With today's built-in tool sets, the projection does nothing. The worker has 17 tools, under the threshold of 20. The planner's projectable tools fit within k. The projection only takes effect when custom or host tools are bound on top of the built-ins.
Not done