Module 6: Sub-AgentsLesson 5 of 7

Build: Executor Agent

Build: Executor Agent

Now let's create an executor — an agent that does things.

The Executor's Job

  • Receives a task to complete
  • Breaks it into steps
  • Executes each step
  • Reports results
  • Handles errors

Step 1: Define the Task Template

## Execution Task **Goal:** [What needs to be accomplished] **Steps:** (if known) 1. [Step 1] 2. [Step 2] 3. [Step 3] **Success Criteria:** - [How to know it's done] - [What the output should look like] **Constraints:** - [What NOT to do] - [Resource limits] - [Time limits] **On Failure:** - [What to do if something fails] - [Whether to retry] - [How to report]

Step 2: Example Execution Tasks

File Organization

sessions_spawn({ task: ` Goal: Organize the downloads folder Steps: 1. List all files in ~/Downloads 2. Create folders: Documents, Images, Code, Other 3. Move files to appropriate folders based on extension 4. Report what was moved Success Criteria: - No files left in root of Downloads - Files in correct categories - Summary of actions taken Constraints: - Don't delete anything - Ask before moving anything over 100MB `, model: "sonnet" });

Code Deployment

sessions_spawn({ task: ` Goal: Deploy latest changes to production Steps: 1. Run tests 2. Build the project 3. Deploy to Cloudflare Pages 4. Verify deployment Success Criteria: - Tests pass - Build succeeds - Site is live and working On Failure: - If tests fail: Report which tests and stop - If build fails: Report error and stop - If deploy fails: Report and attempt rollback `, model: "sonnet" });

Step 3: Error Handling

Good executors handle errors gracefully:

## On Error 1. **Stop** — Don't continue blindly 2. **Report** — What failed and why 3. **Suggest** — Possible fixes 4. **Wait** — For further instructions (unless auto-retry specified)

Exercise: Your First Execution Task

Think of a task you want automated:

  • File operations
  • Git workflow
  • Build/deploy
  • Data processing

Write it using the template, spawn it, evaluate results.

Validation

Your executor is working when:

  • Task spawns successfully
  • Steps are executed in order
  • Errors are caught and reported
  • Success criteria are verified
  • Final report is delivered