โก Layer 4: Execution Layer
November 28, 2025 ยท View on GitHub
๐ Home โบ ๐ง Implementation โบ ๐๏ธ Architecture โบ โก Layer 4: Execution
โ ๐ Delegation Layer โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ ๐พ State Layer โ
โก Layer 4: Execution Layer
Where actual work happens - code execution, file operations, API calls.
Purpose
The Execution Layer performs the actual work. It contains all the tools and subagents that carry out tasks delegated by the ๐ Main Agent.
Components
| Component | Emoji | Function | Spawned By |
|---|---|---|---|
| Subagents | ๐ฆ | Autonomous task execution | Task tool (๐ชบ spawn) |
| Built-in Tools | ๐ง | Core operations (Read, Write, Bash...) | ๐ Main Agent / ๐ฆ Subagents |
| MCP Tools | ๐ | External services (Context7, Perplexity...) | ๐ Main Agent / ๐ฆ Subagents |
| User Interaction | ๐โโ๏ธ | Human-in-the-loop (โ AskUser, ๐ Todo) | ๐ Main Agent / ๐ฆ Subagents |
๐ฆ Subagent Lifecycle
%%{init: {'theme': 'base', 'themeVariables': {'lineColor': '#64748b'}}}%%
stateDiagram-v2
[*] --> Spawned: ๐ชบ Task tool called
Spawned --> Executing: Receives prompt
Executing --> Working: Uses ๐ง ๐ ๐โโ๏ธ tools
Working --> Working: Iterates
Working --> Completed: โ
Task done
Completed --> [*]: Returns result
note right of Working
๐ฆ Cannot spawn
other subagents
end note
Tool Categories
mindmap
root(("โก Execution"))
๐ง Built-in Tools
๐ง๐ Read file
Read
๐ง๐ Search content
Grep
๐ง๐๏ธ Search files
Glob
๐งโ๏ธ Write ops
Write
Edit
๐ง๐ Shell ops
Bash
๐ง๐ Web ops
WebFetch
WebSearch
๐ External MCP
Context7
Perplexity
Firecrawl
Custom MCPs
๐โโ๏ธ User Interaction
โ AskUserQuestion
๐ TodoWrite
๐ชบ Task spawn
Spawns ๐ฆ Subagents
๐ง Built-in Tools Reference
| Tool | Emoji | Operation |
|---|---|---|
Read | ๐ง๐ | Read file contents |
Write | ๐งโ๏ธ | Create/overwrite files |
Edit | ๐งโ๏ธ | Modify existing files |
Glob | ๐ง๐๏ธ | Search files by pattern |
Grep | ๐ง๐ | Search content in files |
Bash | ๐ง๐ | Execute shell commands |
WebFetch | ๐ง๐ | Fetch URL content |
WebSearch | ๐ง๐ | Search the web |
๐ MCP Tools (External)
| Tool | Purpose |
|---|---|
| Context7 | Up-to-date library documentation |
| Perplexity | AI-powered web search |
| Firecrawl | Web scraping and crawling |
| Custom MCPs | Project-specific integrations |
๐โโ๏ธ User Interaction Tools
| Tool | Emoji | Purpose |
|---|---|---|
AskUserQuestion | โ | Request clarification |
TodoWrite | ๐ | Track task progress |
๐ Parallel Execution
%%{init: {'theme': 'base', 'themeVariables': {'lineColor': '#64748b'}}}%%
flowchart TB
classDef main fill:#8b5cf6,stroke:#7c3aed,stroke-width:2px,color:#ffffff
classDef subagent fill:#ec4899,stroke:#db2777,stroke-width:2px,color:#ffffff
classDef state fill:#10b981,stroke:#059669,stroke-width:2px,color:#ffffff
MA["๐ Main Agent"]:::main
MA -->|๐ชบ Task| SA1["๐ฆ Subagent 1"]:::subagent
MA -->|๐ชบ Task| SA2["๐ฆ Subagent 2"]:::subagent
MA -->|๐ชบ Task| SA3["๐ฆ Subagent 3"]:::subagent
SA1 --> R1[Result 1]
SA2 --> R2[Result 2]
SA3 --> R3[Result 3]
R1 --> MERGE["โ
Merge Results"]:::state
R2 --> MERGE
R3 --> MERGE
MERGE --> MA
Parallel Execution Rules
- Independence: Tasks must not depend on each other
- No Cross-Communication: ๐ฆ Subagents cannot communicate directly
- Single Orchestrator: Only ๐ Main Agent coordinates
- Result Aggregation: All results flow back to ๐ Main Agent
Critical Rule
๐ฆ Subagents CANNOT spawn other ๐ฆ Subagents.
All delegation must flow through the ๐ Main Agent.
โ Wrong Pattern
๐ Main Agent โ ๐ฆ Subagent 1 โ ๐ฆ Subagent 2 โ INVALID
โ Correct Pattern
๐ Main Agent โ ๐ฆ Subagent 1
โ ๐ฆ Subagent 2
โ ๐ฆ Subagent 3
Layer Position
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ LAYER 3: DELEGATION LAYER โ
โ ๐ฆด Slash Commands, ๐ Skills - workflow definition โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โก LAYER 4: EXECUTION LAYER โโโโ YOU ARE HERE โ
โ ๐ฆ Subagents, ๐ง Built-in, ๐ External, ๐โโ๏ธ User โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐พ LAYER 5: STATE LAYER โ
โ Memory, Files, Context - persistence โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ Delegation Layer โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ ๐พ State Layer โ