Skip to content

Commit 6852a57

Browse files
committed
[FEAT][Agent][Sub agents] [Enable your agents to create and assign tasks to sub agents] [Improvement][CLI][Improve the CLI with less params and fix swarms chat feature] [New tutorials on sub agents and cli guide]
1 parent 50e9d0e commit 6852a57

File tree

14 files changed

+1413
-186
lines changed

14 files changed

+1413
-186
lines changed
Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
# Autonomous Looper Tools Configuration
2+
3+
The `selected_tools` parameter allows you to configure which tools are available to the agent when using the autonomous looper mode (`max_loops="auto"`).
4+
5+
## Overview
6+
7+
When an agent is set to `max_loops="auto"`, it enters autonomous loop mode where it can:
8+
1. Create a plan by breaking down tasks into subtasks
9+
2. Execute each subtask using available tools
10+
3. Generate a comprehensive summary when complete
11+
12+
The `selected_tools` parameter gives you fine-grained control over which tools the agent can use during this autonomous execution. By default, all tools are enabled (`selected_tools="all"`).
13+
14+
## Available Tools
15+
16+
| Tool Name | Description |
17+
|-----------|-------------|
18+
| `create_plan` | Create a detailed plan for completing a task |
19+
| `think` | Analyze current situation and decide next actions |
20+
| `subtask_done` | Mark a subtask as completed and move to the next task |
21+
| `complete_task` | Mark the main task as complete with comprehensive summary |
22+
| `respond_to_user` | Send messages or responses to the user |
23+
| `create_file` | Create a new file with specified content |
24+
| `update_file` | Update an existing file (replace or append) |
25+
| `read_file` | Read the contents of a file |
26+
| `list_directory` | List files and directories in a path |
27+
| `delete_file` | Delete a file (use with caution) |
28+
29+
## Usage
30+
31+
### Default Behavior (All Tools Available)
32+
33+
```python
34+
from swarms import Agent
35+
36+
agent = Agent(
37+
agent_name="Full-Access-Agent",
38+
model_name="anthropic/claude-sonnet-4-5",
39+
max_loops="auto",
40+
selected_tools="all", # Default - all tools available
41+
)
42+
```
43+
44+
### Restricted Tools
45+
46+
```python
47+
agent = Agent(
48+
agent_name="Planning-Only-Agent",
49+
model_name="anthropic/claude-sonnet-4-5",
50+
max_loops="auto",
51+
selected_tools=[
52+
"create_plan",
53+
"think",
54+
"subtask_done",
55+
"complete_task",
56+
"respond_to_user",
57+
],
58+
)
59+
```
60+
61+
### File Operations Enabled
62+
63+
```python
64+
agent = Agent(
65+
agent_name="File-Operations-Agent",
66+
model_name="anthropic/claude-sonnet-4-5",
67+
max_loops="auto",
68+
selected_tools=[
69+
"create_plan",
70+
"think",
71+
"subtask_done",
72+
"complete_task",
73+
"respond_to_user",
74+
"create_file",
75+
"update_file",
76+
"read_file",
77+
"list_directory",
78+
],
79+
)
80+
```
81+
82+
### Minimal Configuration
83+
84+
```python
85+
agent = Agent(
86+
agent_name="Minimal-Agent",
87+
model_name="anthropic/claude-sonnet-4-5",
88+
max_loops="auto",
89+
selected_tools=[
90+
"create_plan",
91+
"subtask_done",
92+
"complete_task",
93+
],
94+
)
95+
```
96+
97+
## Use Cases
98+
99+
### Research Agent (No File Operations)
100+
For agents focused on research and analysis without needing to create or modify files:
101+
102+
```python
103+
research_agent = Agent(
104+
agent_name="Research-Agent",
105+
max_loops="auto",
106+
selected_tools=[
107+
"create_plan",
108+
"think",
109+
"subtask_done",
110+
"complete_task",
111+
"respond_to_user",
112+
],
113+
)
114+
```
115+
116+
### Code Generation Agent (With File Operations)
117+
For agents that need to create and modify code files:
118+
119+
```python
120+
code_agent = Agent(
121+
agent_name="Code-Generator",
122+
max_loops="auto",
123+
selected_tools=[
124+
"create_plan",
125+
"think",
126+
"subtask_done",
127+
"complete_task",
128+
"respond_to_user",
129+
"create_file",
130+
"update_file",
131+
"read_file",
132+
"list_directory",
133+
],
134+
)
135+
```
136+
137+
### Data Analysis Agent (Read-Only Files)
138+
For agents that need to read files but shouldn't modify them:
139+
140+
```python
141+
analysis_agent = Agent(
142+
agent_name="Data-Analyst",
143+
max_loops="auto",
144+
selected_tools=[
145+
"create_plan",
146+
"think",
147+
"subtask_done",
148+
"complete_task",
149+
"respond_to_user",
150+
"read_file",
151+
"list_directory",
152+
],
153+
)
154+
```
155+
156+
## Best Practices
157+
158+
1. **Start Restrictive**: Begin with a minimal set of tools and add more as needed
159+
2. **Security**: Avoid giving file deletion capabilities unless absolutely necessary
160+
3. **Task Alignment**: Choose tools that align with the agent's primary purpose
161+
4. **Testing**: Test your agent with the tool configuration before production use
162+
163+
## Notes
164+
165+
- `selected_tools` defaults to `"all"`, which enables all tools
166+
- When set to a list, the agent will only have access to the tools you specify
167+
- Tool handlers are automatically filtered based on your configuration
168+
- Invalid tool names are ignored (only valid tool names from the list above are used)
169+
170+
## See Also
171+
172+
- [Autonomous Loop Documentation](./autonomous_loop.md)
173+
- [Agent Configuration Guide](./agent_configuration.md)
174+
- [Tool System Overview](./tools.md)
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# Swarms Chat Command Usage
2+
3+
The `swarms chat` command provides an interactive chat agent with optimized defaults for conversational interactions. The agent runs with `max_loops="auto"` for continuous interaction, similar to Claude Code.
4+
5+
## Features
6+
7+
- **Interactive Mode**: Automatically enabled for continuous conversation
8+
- **Auto Loops**: Runs with `max_loops="auto"` for autonomous operation
9+
- **Dynamic Context Window**: Automatically adjusts context window (100,000 tokens)
10+
- **Dynamic Temperature**: Adapts temperature based on conversation
11+
- **Optional Initial Task**: Start with a task or begin with a prompt
12+
13+
## Basic Usage
14+
15+
### Start Chat Without Initial Task
16+
```bash
17+
swarms chat
18+
```
19+
20+
The agent will prompt you for input when started.
21+
22+
### Start Chat With Initial Task
23+
```bash
24+
swarms chat --task "Hello, how can you help me today?"
25+
```
26+
27+
The agent will process the initial task and then continue in interactive mode.
28+
29+
## Advanced Usage
30+
31+
### Custom Agent Name
32+
```bash
33+
swarms chat --name "MyAssistant" --task "Let's discuss Python programming"
34+
```
35+
36+
### Custom System Prompt
37+
```bash
38+
swarms chat --system-prompt "You are an expert Python developer" --task "Help me debug this code"
39+
```
40+
41+
### Full Customization
42+
```bash
43+
swarms chat \
44+
--name "CodeReviewer" \
45+
--description "An expert code reviewer specializing in Python" \
46+
--system-prompt "You are a senior Python developer with expertise in code review and best practices" \
47+
--task "Review my implementation of a binary search algorithm"
48+
```
49+
50+
## Using Python Module Directly
51+
52+
You can also run the chat command directly with Python:
53+
54+
```bash
55+
python3.12 -m swarms.cli.main chat --task "Hello"
56+
```
57+
58+
## How It Works
59+
60+
1. The chat agent initializes with optimized settings:
61+
- `interactive=True` - Enables continuous interaction
62+
- `max_loops="auto"` - Autonomous loop execution
63+
- `dynamic_context_window=True` - Adaptive context management
64+
- `dynamic_temperature_enabled=True` - Adaptive response generation
65+
- `context_length=100000` - Large context window
66+
67+
2. If you provide a `--task`, the agent processes it first
68+
3. After processing, the agent continues to prompt for input
69+
4. You can continue the conversation interactively
70+
5. Exit by typing 'exit', 'quit', or pressing Ctrl+C
71+
72+
## Examples
73+
74+
### Quick Question
75+
```bash
76+
swarms chat --task "What are the best practices for Python async programming?"
77+
```
78+
79+
### Extended Conversation
80+
```bash
81+
swarms chat --name "TutorBot" --system-prompt "You are a patient programming tutor"
82+
```
83+
Then continue with follow-up questions interactively.
84+
85+
### Code Review Session
86+
```bash
87+
swarms chat \
88+
--name "CodeReviewer" \
89+
--system-prompt "You are an expert code reviewer. Provide detailed feedback with suggestions." \
90+
--task "I'll share some code for review"
91+
```
92+
93+
## Tips
94+
95+
- Use `--system-prompt` to customize the agent's behavior and expertise
96+
- Provide a `--task` to start with context before interactive mode
97+
- The agent remembers conversation history within the session
98+
- All standard agent parameters are available for customization
99+
100+
## Troubleshooting
101+
102+
If you encounter the error `auto_chat_agent() got an unexpected keyword argument 'interactive'`, ensure you're using the latest version of Swarms where this has been fixed.
103+
104+
```bash
105+
# Update to latest version
106+
swarms auto-upgrade
107+
```

docs/mkdocs.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,20 +367,23 @@ nav:
367367
- Heavy Swarm CLI: "swarms/cli/cli_heavy_swarm_guide.md"
368368
- CLI Multi-Agent Commands: "examples/cli_multi_agent_quickstart.md"
369369
- CLI Examples: "swarms/cli/cli_examples.md"
370+
- Chat Command Usage: "examples/chat_command_usage.md"
370371

371372
- Agent Examples:
372373
- Overview: "examples/basic_examples_overview.md"
373374
- Basic Agent: "swarms/examples/basic_agent.md"
374375
- Agent Skills: "swarms/examples/agent_skills_overview.md"
375376
- Autonomous Agent: "swarms/examples/autonomous_agent_tutorial.md"
376377
- Agent Handoff: "swarms/examples/agent_handoff_tutorial.md"
378+
- Sub-Agent Delegation: "swarms/examples/sub_agent_tutorial.md"
377379
- Autosave: "swarms/examples/autosave_tutorial.md"
378380
- Tool Usage:
379381
- Agents with Vision and Tool Usage: "swarms/examples/vision_tools.md"
380-
- Agents with Callable Tools: "swarms/examples/agent_with_tools.md"
381-
- Agent with Structured Outputs: "swarms/examples/agent_structured_outputs.md"
382+
- Callable Tools: "swarms/examples/agent_with_tools.md"
383+
- Structured Outputs: "swarms/examples/agent_structured_outputs.md"
382384
- Pydantic Structured Outputs Tutorial: "swarms/examples/pydantic_structured_outputs_tutorial.md"
383385
- Message Transforms for Context Management: "swarms/structs/transforms.md"
386+
- Selecting PreConfigured Tools: "examples/autonomous_looper_tools.md"
384387
- Vision:
385388
- Agents with Vision: "swarms/examples/vision_processing.md"
386389
- Agent with Multiple Images: "swarms/examples/multiple_images.md"

0 commit comments

Comments
 (0)