perf(plugins): cache tool index in PluginRegistry for O(1) find_tool
load_all() now builds a _tools: dict[str, Tool] index at startup. get_all_tools() returns list(_tools.values()) and find_tool() is a direct dict.get() instead of rebuilding the full tool list from every plugin on every tool call during a session. Updated test helper to populate _tools alongside _plugins to match the actual load_all() behaviour. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -20,6 +20,7 @@ def _make_registry_with_tools(*tools: Tool) -> PluginRegistry:
|
||||
fake_plugin.system_prompt_addition.return_value = ""
|
||||
fake_plugin.daemon_tasks.return_value = []
|
||||
registry._plugins = {"mock_plugin": fake_plugin}
|
||||
registry._tools = {tool.name: tool for tool in tools}
|
||||
return registry
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user