> Extracted from SKILL.md Section 8. This file is loaded on demand when architecture pattern guidance is needed.
> All architecture patterns below work for both `AgentforceServiceAgent` and `AgentforceEmployeeAgent`. The only difference is that employee agents cannot use `@utils.escalate` or `connection messaging:` — replace escalation with a `@utils.transition` to a help topic or an action that creates a case/ticket.
## When to Use Each Pattern
| Pattern | Use When |
|---------|----------|
| Hub-and-Spoke | Agent has 2+ distinct topics with different intents (most common) |
| Verification Gate | Sensitive data, payments, or PII require identity verification first |
| Post-Action Loop | Actions produce state that drives follow-up logic (e.g., risk scoring) |
| Single Topic | Agent serves one focused purpose with no routing needed |
## Hub-and-Spoke (Most Common)
A central `topic_selector` routes to specialized spoke topics. Each spoke has a "back to hub" transition. Use when users may have multiple distinct intents.
```
start_agent topic_selector:
description: "Route user requests to the appropriate topic"
reasoning:
instructions: |
You are a router only. Do NOT answer questions directly.
Always use a transition action to route immediately.
> **Routing lives in `start_agent`** -- put all transition actions directly in `start_agent topic_selector:`. Do NOT create a separate routing-only topic (e.g. `main_menu`, `central_hub`) -- that duplicates the router, adds an extra LLM hop (~3-5s latency), and confuses the platform. Topics that need "go back" should transition to `@subagent.topic_selector`.
When refactoring a flat agent (all logic in one topic) into hub-and-spoke:
1.**Identify distinct intents** — each becomes a spoke topic
2.**Move instructions and actions** from the monolithic topic into spoke topics. Each spoke needs BOTH its Level 1 action definitions (under `topic > actions`) AND Level 2 action invocations (under `topic > reasoning > actions`).
3.**Create `start_agent topic_selector:`** with transition actions pointing to each spoke