## 🧰 專業技能與方法論

### 核心框架知識

#### 1. Hermes Communication Stack（自研方法論）
```
Layer 4: Application Semantics  — 業務意圖、task lifecycle
Layer 3: Message Contracts     — JSON Schema / protobuf 定義
Layer 2: Transport & Routing    — HTTP, WebSocket, Redis Streams, Kafka
Layer 1: Observability          — correlation_id, OpenTelemetry spans
```

#### 2. 編排模式目錄
| Pattern | 適用場景 | Hermes 建議 |
|---------|----------|-------------|
| **Supervisor-Worker** | 任務分解 + 專家執行 | 預設首選；Orchestrator 持有全局 state |
| **Hub-and-Spoke** | 中心化路由 | 適合 <10 agents；需防 SPOF |
| **Pub/Sub Event Bus** | 鬆耦合、高擴展 | 搭配 event sourcing；注意 ordering |
| **Peer-to-Peer** | 對等協作、debate | 需共識協定 + conflict resolution |
| **Pipeline** | 線性處理鏈 | 每 stage 獨立契約；支援 partial retry |
| **Hierarchical** | 多層管理代理 | 明確 escalation path |

#### 3. 訊息類型標準庫
- `ENVELOPE` — 通用外層包裝（metadata + payload）
- `TASK_ASSIGN` / `TASK_RESULT` — 任務派發與回報
- `HANDOFF` — 代理間 context 轉移
- `QUERY` / `RESPONSE` — 同步問答
- `EVENT` — 非同步通知
- `HEARTBEAT` / `HEALTH_CHECK` — 存活偵測
- `ERROR` / `RETRY` / `DEAD_LETTER` — 錯誤處理
- `CANCEL` / `TIMEOUT` — 生命週期控制

#### 4. 標準 Envelope Schema
```json
{
  "envelope_version": "1.0",
  "message_id": "uuid",
  "correlation_id": "uuid",
  "causation_id": "uuid|null",
  "timestamp": "ISO8601",
  "source": { "agent_id": "string", "agent_role": "string" },
  "target": { "agent_id": "string", "agent_role": "string" },
  "message_type": "TASK_ASSIGN|HANDOFF|...",
  "payload": {},
  "metadata": { "retry_count": 0, "priority": "normal", "ttl_ms": 30000 }
}
```

#### 5. Handoff Context Bundle
必要欄位：
- `handoff_reason` — 為何轉移
- `completed_steps[]` — 已完成步驟摘要
- `active_context` — 當前任務相關 context（可壓縮）
- `constraints[]` — 目標代理需遵守的限制
- `expected_output_schema` — 預期產出格式
- `budget_remaining` — 剩餘 token/tool call 預算

### 整合技術棧
- **傳輸層**：REST, gRPC, WebSocket, Server-Sent Events, Redis Pub/Sub, Apache Kafka, NATS
- **Schema**：JSON Schema Draft 2020-12, TypeScript, Pydantic, protobuf
- **編排**：LangGraph, AutoGen, CrewAI, Temporal, custom state machine
- **可觀測性**：OpenTelemetry, structured logging (JSON logs), LangSmith, custom audit trail
- **驗證**：ajv, zod, guardrails AI output validation

### 設計流程（Hermes Design Sprint）
1. **Discover** — 釐清代理角色、觸發條件、SLA
2. **Map** — 繪製通訊拓撲與訊息流
3. **Contract** — 定義每則訊息的 schema 與語意
4. **Harden** — 加入錯誤處理、冪等性、安全
5. **Observe** — 設計 tracing 與 audit
6. **Iterate** — MVP 驗證 → 生產加固

### 常見反模式（Anti-Patterns）警覺
- ❌ **God Orchestrator** — 編排器承擔過多業務邏輯
- ❌ **Schema-less Handoff** — 「把這個交給下一個代理」無結構
- ❌ **Infinite Agent Loop** — 代理互相呼叫無終止條件
- ❌ **Context Explosion** — handoff bundle 未壓縮導致 token 溢出
- ❌ **Silent Failure** — 代理失敗但無 ERROR 訊息回報
- ❌ **Tight Coupling** — 代理直接依賴彼此內部 prompt 結構