Add support for enabling all toolsets with 'all' or '*' alias in README and toolset resolution logic
This commit is contained in:
@@ -76,6 +76,9 @@ python run_agent.py --enabled_toolsets=research --query "Find latest AI papers"
|
|||||||
# Combine multiple toolsets
|
# Combine multiple toolsets
|
||||||
python run_agent.py --enabled_toolsets=web,vision --query "Analyze this website"
|
python run_agent.py --enabled_toolsets=web,vision --query "Analyze this website"
|
||||||
|
|
||||||
|
# Enable all toolsets explicitly (same as omitting the flag)
|
||||||
|
python run_agent.py --enabled_toolsets=all --query "Do web research and run commands if helpful"
|
||||||
|
|
||||||
# Safe mode (no terminal access)
|
# Safe mode (no terminal access)
|
||||||
python run_agent.py --enabled_toolsets=safe --query "Help without running commands"
|
python run_agent.py --enabled_toolsets=safe --query "Help without running commands"
|
||||||
|
|
||||||
@@ -137,7 +140,7 @@ agent = AIAgent(enabled_toolsets=["my_tools"])
|
|||||||
- `--api_key`: API key for authentication
|
- `--api_key`: API key for authentication
|
||||||
- `--base_url`: API endpoint URL
|
- `--base_url`: API endpoint URL
|
||||||
- `--max_turns`: Maximum number of tool-calling iterations
|
- `--max_turns`: Maximum number of tool-calling iterations
|
||||||
- `--enabled_toolsets`: Comma-separated list of toolsets to enable
|
- `--enabled_toolsets`: Comma-separated list of toolsets to enable. Use `all` (or `*`) to enable everything. If omitted, all toolsets are enabled by default.
|
||||||
- `--disabled_toolsets`: Comma-separated list of toolsets to disable
|
- `--disabled_toolsets`: Comma-separated list of toolsets to disable
|
||||||
- `--list_tools`: List all available toolsets and tools
|
- `--list_tools`: List all available toolsets and tools
|
||||||
- `--save_trajectories`: Save conversation trajectories to JSONL files
|
- `--save_trajectories`: Save conversation trajectories to JSONL files
|
||||||
|
|||||||
13
toolsets.py
13
toolsets.py
@@ -110,6 +110,16 @@ def resolve_toolset(name: str, visited: Set[str] = None) -> List[str]:
|
|||||||
if visited is None:
|
if visited is None:
|
||||||
visited = set()
|
visited = set()
|
||||||
|
|
||||||
|
# Special aliases that represent all tools across every toolset
|
||||||
|
# This ensures future toolsets are automatically included without changes.
|
||||||
|
if name in {"all", "*"}:
|
||||||
|
all_tools: Set[str] = set()
|
||||||
|
for toolset_name in get_toolset_names():
|
||||||
|
# Use a fresh visited set per branch to avoid cross-branch contamination
|
||||||
|
resolved = resolve_toolset(toolset_name, visited.copy())
|
||||||
|
all_tools.update(resolved)
|
||||||
|
return list(all_tools)
|
||||||
|
|
||||||
# Check for cycles
|
# Check for cycles
|
||||||
if name in visited:
|
if name in visited:
|
||||||
print(f"⚠️ Circular dependency detected in toolset '{name}'")
|
print(f"⚠️ Circular dependency detected in toolset '{name}'")
|
||||||
@@ -184,6 +194,9 @@ def validate_toolset(name: str) -> bool:
|
|||||||
Returns:
|
Returns:
|
||||||
bool: True if valid, False otherwise
|
bool: True if valid, False otherwise
|
||||||
"""
|
"""
|
||||||
|
# Accept special alias names for convenience
|
||||||
|
if name in {"all", "*"}:
|
||||||
|
return True
|
||||||
return name in TOOLSETS
|
return name in TOOLSETS
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user