allowed agent calling within an agent
This commit is contained in:
@@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
description: Fetch and transform weather data for Karachi
|
||||||
|
model: haiku
|
||||||
|
---
|
||||||
|
|
||||||
|
# Weather Karachi Command
|
||||||
|
|
||||||
|
Fetch the current temperature for Karachi, Pakistan and apply transformations.
|
||||||
|
|
||||||
|
## Workflow
|
||||||
|
|
||||||
|
1. Use the weather-fetcher agent to retrieve the current temperature from wttr.in API
|
||||||
|
2. Use the weather-transformer agent to read transformation rules from input/input.md and apply them to the temperature
|
||||||
|
3. Write the results to output/output.md
|
||||||
|
|
||||||
|
Launch the agents sequentially (not in parallel) and provide a clear summary showing:
|
||||||
|
- Original temperature
|
||||||
|
- Transformation applied
|
||||||
|
- Final result
|
||||||
@@ -1,20 +1,10 @@
|
|||||||
---
|
---
|
||||||
description: Fetch and transform weather data for a city
|
description: Fetch and transform weather data for Karachi
|
||||||
argument-hint: <city-name>
|
|
||||||
model: haiku
|
model: haiku
|
||||||
---
|
---
|
||||||
|
|
||||||
# Weather Command
|
# Weather Command
|
||||||
|
|
||||||
Fetch the current temperature for ${1:-Karachi}, Pakistan and apply transformations.
|
Execute the weather-karachi command to fetch and transform temperature data.
|
||||||
|
|
||||||
## Workflow
|
Use the SlashCommand tool to execute `/weather-karachi`.
|
||||||
|
|
||||||
1. Use the weather-fetcher agent to retrieve the current temperature from wttr.in API
|
|
||||||
2. Use the weather-transformer agent to read transformation rules from input/input.md and apply them to the temperature
|
|
||||||
3. Write the results to output/output.md
|
|
||||||
|
|
||||||
Launch the agents sequentially (not in parallel) and provide a clear summary showing:
|
|
||||||
- Original temperature
|
|
||||||
- Transformation applied
|
|
||||||
- Final result
|
|
||||||
|
|||||||
+1
-1
@@ -101,7 +101,7 @@ After updating the orchestrator agent definition, test it by invoking the orches
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Via slash command
|
# Via slash command
|
||||||
/weather
|
/weather-karachi
|
||||||
|
|
||||||
# Or directly via Task tool
|
# Or directly via Task tool
|
||||||
Task(subagent_type="weather-orchestrator", description="Run weather workflow", prompt="Orchestrate the complete weather workflow", model="haiku")
|
Task(subagent_type="weather-orchestrator", description="Run weather workflow", prompt="Orchestrate the complete weather workflow", model="haiku")
|
||||||
|
|||||||
+3
-3
@@ -20,7 +20,7 @@ see the table in @PROMPTS.md of Agent Invocation and Command Invocation and cros
|
|||||||
| From | How | Example |
|
| From | How | Example |
|
||||||
|----------------------|------------------------|-------------------------------------|
|
|----------------------|------------------------|-------------------------------------|
|
||||||
| Claude CLI | Prompt | use the weather command to fetch the weather |
|
| Claude CLI | Prompt | use the weather command to fetch the weather |
|
||||||
| Claude CLI | /command-name | /weather |
|
| Claude CLI | /command-name | /weather-karachi |
|
||||||
| /agents/Agents.md | SlashCommand tool | SlashCommand(command="/weather Karachi") |
|
| /agents/Agents.md | SlashCommand tool | SlashCommand(command="/weather-karachi") |
|
||||||
| Another /command | SlashCommand tool | SlashCommand(command="/weather Karachi") |
|
| Another /command | SlashCommand tool | SlashCommand(command="/weather-karachi") |
|
||||||
|
|
||||||
|
|||||||
+167
@@ -0,0 +1,167 @@
|
|||||||
|
# Weather Karachi System Flow
|
||||||
|
|
||||||
|
This document describes the complete flow of the weather data fetching and transformation system.
|
||||||
|
|
||||||
|
## System Overview
|
||||||
|
|
||||||
|
The weather system consists of slash commands and specialized agents that work together to fetch and transform temperature data for Karachi, Pakistan.
|
||||||
|
|
||||||
|
## Flow Diagram
|
||||||
|
|
||||||
|
```
|
||||||
|
┌─────────────────────────────────────────────────────────────────┐
|
||||||
|
│ User Interaction │
|
||||||
|
└─────────────────────────────────────────────────────────────────┘
|
||||||
|
│
|
||||||
|
▼
|
||||||
|
┌──────────────────┐
|
||||||
|
│ /weather │
|
||||||
|
│ Command │
|
||||||
|
└──────────────────┘
|
||||||
|
│
|
||||||
|
│ calls
|
||||||
|
▼
|
||||||
|
┌──────────────────┐
|
||||||
|
│ /weather-karachi │
|
||||||
|
│ Command │
|
||||||
|
└──────────────────┘
|
||||||
|
│
|
||||||
|
│ Step 1 (Sequential)
|
||||||
|
▼
|
||||||
|
┌────────────────────────┐
|
||||||
|
│ weather-fetcher │
|
||||||
|
│ Agent │
|
||||||
|
│ (subagent_type) │
|
||||||
|
└────────────────────────┘
|
||||||
|
│
|
||||||
|
▼
|
||||||
|
┌────────────────────────┐
|
||||||
|
│ wttr.in API │
|
||||||
|
│ Fetch Temperature │
|
||||||
|
│ for Karachi │
|
||||||
|
└────────────────────────┘
|
||||||
|
│
|
||||||
|
│ Returns: 26°C
|
||||||
|
▼
|
||||||
|
│
|
||||||
|
│ Step 2 (Sequential)
|
||||||
|
▼
|
||||||
|
┌─────────────────────────┐
|
||||||
|
│ weather-transformer │
|
||||||
|
│ Agent │
|
||||||
|
│ (subagent_type) │
|
||||||
|
└─────────────────────────┘
|
||||||
|
│
|
||||||
|
▼
|
||||||
|
┌─────────────────────────┐
|
||||||
|
│ input/input.md │
|
||||||
|
│ Read Transform Rules │
|
||||||
|
└─────────────────────────┘
|
||||||
|
│
|
||||||
|
│ Reads: "add +10"
|
||||||
|
▼
|
||||||
|
┌────────────────────────┐
|
||||||
|
│ Apply Transform │
|
||||||
|
│ 26 + 10 = 36°C │
|
||||||
|
└────────────────────────┘
|
||||||
|
│
|
||||||
|
▼
|
||||||
|
┌────────────────────────┐
|
||||||
|
│ output/output.md │
|
||||||
|
│ Write Results │
|
||||||
|
└────────────────────────┘
|
||||||
|
│
|
||||||
|
▼
|
||||||
|
┌────────────────────────┐
|
||||||
|
│ Display Summary │
|
||||||
|
│ to User │
|
||||||
|
└────────────────────────┘
|
||||||
|
```
|
||||||
|
|
||||||
|
## Component Details
|
||||||
|
|
||||||
|
### 1. Slash Commands
|
||||||
|
|
||||||
|
#### `/weather`
|
||||||
|
- **Location**: `.claude/commands/weather.md`
|
||||||
|
- **Purpose**: Entry point for weather operations
|
||||||
|
- **Action**: Calls `/weather-karachi` command
|
||||||
|
- **Model**: haiku
|
||||||
|
|
||||||
|
#### `/weather-karachi`
|
||||||
|
- **Location**: `.claude/commands/weather-karachi.md`
|
||||||
|
- **Purpose**: Orchestrates the weather fetching and transformation workflow
|
||||||
|
- **Action**: Launches two specialized agents sequentially
|
||||||
|
- **Model**: haiku
|
||||||
|
|
||||||
|
### 2. Specialized Agents
|
||||||
|
|
||||||
|
#### `weather-fetcher`
|
||||||
|
- **Location**: `.claude/agents/weather-fetcher.md`
|
||||||
|
- **Purpose**: Fetch real-time temperature data
|
||||||
|
- **Data Source**: wttr.in API for Karachi, Pakistan
|
||||||
|
- **Output**: Temperature in Celsius (numeric value)
|
||||||
|
- **Tools Available**: WebFetch
|
||||||
|
|
||||||
|
#### `weather-transformer`
|
||||||
|
- **Location**: `.claude/agents/weather-transformer.md`
|
||||||
|
- **Purpose**: Apply mathematical transformations to temperature data
|
||||||
|
- **Input Source**: `input/input.md` (transformation rules)
|
||||||
|
- **Output Destination**: `output/output.md` (formatted results)
|
||||||
|
- **Tools Available**: Read, Write
|
||||||
|
|
||||||
|
### 3. Data Files
|
||||||
|
|
||||||
|
#### `input/input.md`
|
||||||
|
- **Purpose**: Stores transformation rules
|
||||||
|
- **Format**: Natural language instructions (e.g., "add +10 in the result")
|
||||||
|
- **Access**: Read by weather-transformer agent
|
||||||
|
|
||||||
|
#### `output/output.md`
|
||||||
|
- **Purpose**: Stores formatted transformation results
|
||||||
|
- **Format**: Structured markdown with sections:
|
||||||
|
- Original Temperature
|
||||||
|
- Transformation Applied
|
||||||
|
- Final Result
|
||||||
|
- Calculation Details
|
||||||
|
|
||||||
|
## Execution Flow
|
||||||
|
|
||||||
|
1. **User Invocation**: User runs `/weather` command
|
||||||
|
2. **Command Delegation**: `/weather` delegates to `/weather-karachi`
|
||||||
|
3. **Sequential Agent Execution**:
|
||||||
|
- **Step 1**: `weather-fetcher` agent fetches current temperature from wttr.in
|
||||||
|
- **Step 2**: `weather-transformer` agent:
|
||||||
|
- Reads transformation rules from `input/input.md`
|
||||||
|
- Applies rules to the fetched temperature
|
||||||
|
- Formats and writes results to `output/output.md`
|
||||||
|
4. **Result Display**: Summary shown to user with:
|
||||||
|
- Original temperature
|
||||||
|
- Transformation rule applied
|
||||||
|
- Final transformed result
|
||||||
|
|
||||||
|
## Example Execution
|
||||||
|
|
||||||
|
```
|
||||||
|
Input: /weather
|
||||||
|
├─ Calls: /weather-karachi
|
||||||
|
│ ├─ Agent: weather-fetcher
|
||||||
|
│ │ └─ Result: 26°C
|
||||||
|
│ ├─ Agent: weather-transformer
|
||||||
|
│ │ ├─ Reads: input/input.md ("add +10")
|
||||||
|
│ │ ├─ Calculates: 26 + 10 = 36°C
|
||||||
|
│ │ └─ Writes: output/output.md
|
||||||
|
│ └─ Output:
|
||||||
|
│ ├─ Original: 26°C
|
||||||
|
│ ├─ Transform: Add +10
|
||||||
|
│ └─ Result: 36°C
|
||||||
|
```
|
||||||
|
|
||||||
|
## Key Design Principles
|
||||||
|
|
||||||
|
1. **Separation of Concerns**: Each component has a single, clear responsibility
|
||||||
|
2. **Sequential Execution**: Agents run in order to ensure data dependencies are met
|
||||||
|
3. **Specialized Agents**: Task-specific agents with minimal tool access
|
||||||
|
4. **Command Chaining**: Simple commands can delegate to more complex workflows
|
||||||
|
5. **Configurable Transformations**: Rules stored externally in input files
|
||||||
|
6. **Structured Output**: Results formatted consistently in output files
|
||||||
+4
-4
@@ -1,13 +1,13 @@
|
|||||||
# Weather Transformation Results
|
# Weather Transformation Results
|
||||||
|
|
||||||
**Original Temperature:** 50°C
|
**Original Temperature:** 26°C
|
||||||
|
|
||||||
**Transformation Applied:** Add +10 to the result
|
**Transformation Applied:** Add +10 to the result
|
||||||
|
|
||||||
**Final Result:** 60°C
|
**Final Result:** 36°C
|
||||||
|
|
||||||
## Calculation Details
|
## Calculation Details
|
||||||
|
|
||||||
- Starting value: 50°C
|
- Starting value: 26°C
|
||||||
- Operation: +10
|
- Operation: +10
|
||||||
- Result: 50 + 10 = 60°C
|
- Result: 26 + 10 = 36°C
|
||||||
|
|||||||
Reference in New Issue
Block a user