File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change 1
1
from typing import Optional
2
2
import itertools
3
+ from difflib import get_close_matches
3
4
import inquirer
4
- from agentstack import conf
5
+ from agentstack import conf , log
5
6
from agentstack .utils import term_color , is_snake_case
6
7
from agentstack import generation
7
8
from agentstack import repo
8
- from agentstack ._tools import get_all_tools
9
+ from agentstack ._tools import get_all_tools , get_all_tool_names
9
10
from agentstack .agents import get_all_agents
10
11
from pathlib import Path
11
12
import sys
@@ -63,6 +64,16 @@ def add_tool(tool_name: Optional[str], agents=Optional[list[str]]):
63
64
"""
64
65
conf .assert_project ()
65
66
67
+ all_tool_names = get_all_tool_names ()
68
+ if tool_name and not tool_name in all_tool_names :
69
+ # tool was provided, but not found. make a suggestion.
70
+ suggestions = get_close_matches (tool_name , all_tool_names , n = 1 )
71
+ message = f"Tool '{ tool_name } ' not found."
72
+ if suggestions :
73
+ message += f"\n Did you mean '{ suggestions [0 ]} '?"
74
+ log .error (message )
75
+ return
76
+
66
77
if not tool_name :
67
78
# Get all available tools including custom ones
68
79
available_tools = [t for t in get_all_tools () if t is not None ]
You can’t perform that action at this time.
0 commit comments