一键导入
context-summarizer
定時壓縮長時間任務的 context,避免 token 爆炸。寫入 context-summary.md 保留決策和當前狀態,丢棄細節。
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
定時壓縮長時間任務的 context,避免 token 爆炸。寫入 context-summary.md 保留決策和當前狀態,丢棄細節。
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Dev-agent / checker-agent collaboration loop driven by downstream project docs/STATE.md. Dev agent implements and records work items; an independent checker agent verifies each item with real lint/typecheck/test/build evidence and writes findings back; loop continues until all items are VERIFIED or escalation limits are hit.
Synchronizes review feedback, QA findings, user corrections, and code-review suggestions into durable project docs before Build, merge, or ship.
Intake workflow for existing projects before continuing development. Analyze current source state, derive a truthful docs baseline, identify QA/regression gaps, and create a safe continuation plan.
防止修復過的 bug 重新出現(regression)。 規則:每個修過的 bug 必須留下「regression test」+「root cause note」+「為何會發生」分析, 確保日後 refactor / 改需求時唔會重新踩坑。 David 在 2026-06-06 kanban task 明確指出「舊的 bug 又出現」嘅困擾。
Task Orchestration Subagent — Coordinates all subagents, manages task board, handles parallel/sequential execution, tracks dependencies and failures. The conductor of the development orchestra.
4-layer interruption + recovery mechanism for long dev tasks. Auto-save on any interruption, one-command resume with full context restore. Built on top of dev-task-memory state files.
| name | context-summarizer |
| description | 定時壓縮長時間任務的 context,避免 token 爆炸。寫入 context-summary.md 保留決策和當前狀態,丢棄細節。 |
| trigger | context / 上下文管理 / 總結進度 / 壓縮 context / resume from previous session |
| version | 2 |
| category | productivity |
Patched 2026-06-19 (auto-dev Phase 2C): Auto-trigger guide + hallucination detection + session resume handshake. See §0 below.
docs/context-summary.md)下列 trigger 全部自動 fire:
| Trigger | 條件 | 動作 |
|---|---|---|
| 每 25 個新 message | agent 自己 count 緊 | 自動 write summary |
| 每次 sub-agent 跑完 | 任何 size | 自動 write summary(sub-agent 結果會 push context) |
| Token usage 過 30% context | compression.threshold: 0.3 已 trigger | 自動 write summary |
| Context 用到 60% 強制 | 60% 已 trigger | 強制 write summary + log warning |
| Detect hallucination (NEW) | 問 David 同樣嘢 3 次 / reference 唔存在 file 2 次 | 強制 write summary + notify David |
| David 講「/context」 | manual | 即刻 write summary |
# 1. 讀取當前 context
current_context = read_file("docs/context-summary.md") # 如果存在
# 2. 讀取 task board 狀態
task_board = read_file("docs/task-board.md")
# 3. 讀取最近 sub-agent 輸出(最後 5 個)
recent_outputs = get_recent_subagent_results(limit=5)
# 4. 生成總結
summary = f"""
# Context Summary — {datetime.now().strftime('%Y-%m-%d %H:%M')}
## 當前任務
{task_board.current_task}
## 已完成
{summary_of_completed(recent_outputs)}
## 關鍵決策
{extract_decisions(recent_outputs)}
## 當前狀態
{extract_current_state(recent_outputs)}
## 待處理
{task_board.pending_tasks}
## 風險
{extract_risks(recent_outputs)}
"""
# 5. 寫入 context-summary.md
write_file("docs/context-summary.md", summary)
# 6. 通知 Orchestrator 可以丢棄 intermediate
# Context Summary — 2026-05-10 18:30
## 當前任務
正在開發用戶登入功能(Backend API)
## 已完成
- [x] BA 需求分析完成
- [x] SA 架構設計完成
- [x] 數據庫 migration 完成
- [x] Auth middleware 完成
## 關鍵決策
1. 使用 JWT token,過期時間 24h
2. Password hashing 使用 bcrypt
3. Session 存 Redis,過期時間 7d
## 當前狀態
- Backend: 80% 完成,登入 API 尚需 unit test
- Frontend: 60% 完成,登入頁面 UI 完成,等待 API 就緒
- DevOps: 部署腳本已就緒,等待 Backend 完成
## 待處理
- TASK-005: Backend unit test(30分鐘)
- TASK-006: Frontend API 串接(1小時)
- TASK-007: E2E 測試(1小時)
## 風險
- 前端需要修改一次才能串接後端(API response 格式待確認)
- 預計完成時間:今日 22:00
保留:
丢棄(寫完 summary 之後可以清):
Agent 要主動 detect 自己 hallucinate 嘅 signal:
| Signal | 計數 | 動作 |
|---|---|---|
| 問 David 同樣嘅 question 3 次 | ≥3 | 強制 trigger summary + 通知 David「我似乎行 loop」 |
| Reference 唔存在嘅 file path 2 次 | ≥2 | 強制 trigger summary + 通知 David「我 reference 咗唔存在 file」 |
| 同一個 tool call 重覆 3 次冇 progress | ≥3 | Hermes 嘅 idempotent_no_progress: 2 rule 會 trigger warning;agent 收到 warning 就 trigger summary |
| 開始 output 「as an AI」/「I cannot」呢類 disclaimer | 出現 | 強制 trigger summary — 已經過咗 task scope |
Notification format(critical 級別):
🚨 Hallucination Detected (signal: <X>)
- Trigger: <description>
- Action taken: 強制寫 context-summary.md
- Recommendation: David 用 /new session,context 自動 resume
新 session 開頭,agent 自動:
# 7. 新 session 第一件事
summary_path = Path("~/.hermes/profiles/developer/docs/context-summary.md").expanduser()
if summary_path.exists():
content = summary_path.read_text()
echo_to_david = f"📋 **Resume from previous session:**\n\n{content}\n\n---\n"
else:
echo_to_david = "📋 No previous session summary found. Starting fresh.\n"
Agent 開新 session 嘅 first message 一定要 echo 上面嘅 block,唔可以 skip。
為何咁做:避免 David 要手動 paste context-summary.md 過去(David 痛點三)。
| Trigger type | 邊個 fire |
|---|---|
| 25 message / 30% / 60% threshold | Agent 自己 count 住(pre-turn check) |
| Sub-agent 完 | Main agent 收到 sub-agent result 之後自動 |
| Hallucination detect | Agent 自己 detect |
| David 講「/context」 | 即刻 |
永遠唔好等 David 講先 trigger。Compression 係 safety net,唔係 feature toggle。