> Architecture of the 8-Stage Agent Pipeline and Prompt Modes

# How It Works

## 8-Stage Agent Pipeline

Every interaction flows through `internal/pipeline/`:

1. **Context:** Resolve workspace context files and tenant identity (`store.WithTenantID(ctx)`).
2. **History:** Fetch session history with token-budget boundaries.
3. **Prompt:** Render system prompt using the active Prompt Mode (Full, Task, Minimal, None).
4. **Think:** Execute reasoning turn with provider adapter (supports Extended Thinking).
5. **Act:** Execute approved tool calls (filesystem, exec, web, memory, subagents, MCP).
6. **Observe:** Collect tool execution results and append to history.
7. **Memory:** Auto-extract semantic insights into pgvector working/episodic memory.
8. **Summarize:** Perform session compaction if token threshold is exceeded.

## 4-Mode Prompt System

* **Full:** Complete system persona and capabilities (`SOUL.md`, `IDENTITY.md`).
* **Task:** Lean task-oriented instructions for autonomous background jobs.
* **Minimal:** Ultra-low token footprint for high-volume webhook handlers.
* **None:** Pure raw prompt pass-through.
