You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After both land, ChatAgent will have ~27 tools simultaneously registered. Per issue #688, ~12K tokens of the 32K context (~37%) will be consumed by tool descriptions alone.
The concrete collision
scratchpad.query_data(sql) (from #495) and memory.recall(query) (from #606) answer different questions but are both terminal "query" steps. Without disambiguation the LLM will pick the wrong one when the query is ambiguous:
User query
Right tool
Why
"What did I spend on groceries in March?"
query_data
Structured data from session pipeline
"What did I learn about FTS5 last week?"
recall
Semantic concept across history
"How many research papers mention transformer attention?"
Ambiguous
Depends on where the data is stored
Why this needs to be fixed as part of #688, not in #495 or #606
Both source PRs are in review/merge-ready state; interrupting them to bolt on dynamic loading delays two shipments
The fix is structural, not behavioral — it belongs in a dedicated refactor PR
Introduce a ToolLoader abstraction that gates tool visibility at prompt-generation time, not at registration time. The module-level _TOOL_REGISTRY remains the source of truth for all registered tools; the loader picks which subset appears in the LLM prompt each turn.
Context
Two PRs currently in flight add a combined 8 new tools to ChatAgent and bring the total tool count into "too many for reliable selection" territory:
browse_directory,tree,file_info,find_files,read_file,bookmark), 5 scratchpad (create_table,insert_data,query_data,list_tables,drop_table), 3 browser (fetch_page,search_web,download_file).remember,recall,update_memory,forget,search_past_conversations.After both land, ChatAgent will have ~27 tools simultaneously registered. Per issue #688, ~12K tokens of the 32K context (~37%) will be consumed by tool descriptions alone.
The concrete collision
scratchpad.query_data(sql)(from #495) andmemory.recall(query)(from #606) answer different questions but are both terminal "query" steps. Without disambiguation the LLM will pick the wrong one when the query is ambiguous:query_datarecallWhy this needs to be fixed as part of #688, not in #495 or #606
tool_historytable,_execute_toolwrapper,get_memory_system_promptinjection point)Proposed resolution (implements #688 Phase 1)
Introduce a
ToolLoaderabstraction that gates tool visibility at prompt-generation time, not at registration time. The module-level_TOOL_REGISTRYremains the source of truth for all registered tools; the loader picks which subset appears in the LLM prompt each turn.Bundles for the current tool set (27 tools):
coreread_file(RAG-side),list_files,run_shell_commandragquery_documents,query_specific_file,index_document,list_indexed_documents,search_indexed_chunks,index_directoryfilesystembrowse_directory,tree,file_info,find_files,read_file(FS-side),bookmarkscratchpadcreate_tablein session, or keyword matchcreate_table,insert_data,query_data,list_tables,drop_tablebrowserfetch_page,search_web,download_filememoryrememberin session, or keyword matchremember,recall,update_memory,forget,search_past_conversationsmcp_<server>Tool routing decision order:
core)activate_bundle(name)(phase 2)Acceptance criteria
scratchpad.query_datapicks it (notrecall), and vice versaDependencies
MemoryStore+tool_history+_execute_toolsubstrate)Out of scope
References
/cc @kovtcharov-amd @itomek-amd