Skip to content

A self-organizing Obsidian vault that gives AI coding agents persistent memory.

feat: a changed Stop report reaches the agent, which decides whether to act (#257)

Brenno Ferrari9f113c784a9b
diff --git a/.claude/scripts/lib/hook-io.ts b/.claude/scripts/lib/hook-io.ts
index 72527df..3928fc5 100644
--- a/.claude/scripts/lib/hook-io.ts
+++ b/.claude/scripts/lib/hook-io.ts
@@ -88,9 +88,63 @@ export function writeHookOutput(
* "must not print any plain text to stdout other than the final JSON",
* and Claude Code routes non-exempt plain stdout to the debug log where
* nobody reads it. So there is no text path worth keeping.
+ *
+ * To reach the model as well, a Stop hook uses `writeStopBlock` instead.
*/
export function writeSystemMessage(message: string): void {
- process.stdout.write(JSON.stringify({ systemMessage: message }));
+ const overhead = JSON.stringify({ systemMessage: "" }).length - 2;
+ process.stdout.write(JSON.stringify({ systemMessage: fitEncoded(message, HOOK_OUTPUT_MAX_CHARS - overhead) }));
+}
+
+/**
+ * Claude Code turns hook output over 10,000 characters into a short preview
+ * (verified 2026-10-02, #254), so a report past it would reach the agent as
+ * its first couple of KB. Writers hold the whole stdout under this, with
+ * margin, measured after JSON escaping.
+ */
+export const HOOK_OUTPUT_MAX_CHARS = 9_500;
+
+const CUT_MARKER = "\n… (truncated to fit the hook output cap)";
+
+/**
+ * `text`, cut with a marker so that its JSON-encoded form is at most `max`
+ * characters. Escaping (`\n`, `\\`, quotes) is counted, which a cut on the
+ * raw length would miss. It never splits an emoji: JSON.stringify escapes a
+ * lone surrogate to six characters, so a cut inside a pair always costs more
+ * than keeping the whole pair, and the search keeps the longest prefix that
+ * fits.
+ */
+export function fitEncoded(text: string, max: number): string {
+ if (JSON.stringify(text).length <= max) return text;
+ let lo = 0;
+ let hi = text.length;
+ while (lo < hi) {
+ const mid = Math.ceil((lo + hi) / 2);
+ if (JSON.stringify(text.slice(0, mid) + CUT_MARKER).length <= max) lo = mid;
+ else hi = mid - 1;
+ }
+ return text.slice(0, lo) + CUT_MARKER;
+}
+
+/**
+ * A Stop that hands `reason` to the agent now and gives it another turn,
+ * while showing the user `message` (#256).
+ *
+ * `decision: "block"` is the only Stop output that reaches the model; every
+ * other field is for the user. It also gives the agent a turn nobody typed,
+ * so stop-checklist uses it only when its findings change, and relies on
+ * `stop_hook_active` to keep the forced turn's own Stop from blocking again.
+ * Claude Code honours it on Stop, and labels it "Stop hook error occurred" in
+ * its UI even on success; Codex documents the same field. Gemini runs the
+ * checklist on SessionEnd and never gets it.
+ */
+export function writeStopBlock(reason: string, message: string): void {
+ // Both copies share one output cap: the user's gets at most a third, the
+ // agent's whatever is left.
+ const shown = fitEncoded(message, Math.floor(HOOK_OUTPUT_MAX_CHARS / 3));
+ const overhead = JSON.stringify({ decision: "block", reason: "", systemMessage: shown }).length - 2;
+ const handed = fitEncoded(reason, HOOK_OUTPUT_MAX_CHARS - overhead);
+ process.stdout.write(JSON.stringify({ decision: "block", reason: handed, systemMessage: shown }));
}
/**
diff --git a/.claude/scripts/stop-checklist.ts b/.claude/scripts/stop-checklist.ts
index 82ff338..016d601 100644
--- a/.claude/scripts/stop-checklist.ts
+++ b/.claude/scripts/stop-checklist.ts
@@ -20,10 +20,22 @@
* as advisory and does not surface its systemMessage. Moving the report
* there would turn "every turn" into "never".
*
+ * Who reads it: a Stop hook's systemMessage reaches the user and never the
+ * agent, so the drift the agent is best placed to fix never reached it
+ * (#256). On a Stop whose findings changed, the hook also returns
+ * `decision: "block"` with the report as the reason, the one Stop output
+ * that reaches the model: the agent gets a turn to act on it, ask the user,
+ * or say in one line that nothing needs doing. The forced turn's own Stop
+ * arrives with stop_hook_active and exits early, so it cannot loop.
+ * SessionEnd and a Stop without a session_id never block: SessionEnd has no
+ * turn to give, and without a session_id nothing stops a block repeating.
+ *
* Output is JSON on every agent, never plain text. Codex rejects plain Stop
* stdout, Gemini's SessionEnd contract requires a final JSON object, and
- * Claude Code otherwise files non-exempt stdout in the debug log. The report
- * uses the one user-facing field all three agents share, `systemMessage`.
+ * Claude Code otherwise files non-exempt stdout in the debug log. The user
+ * gets the report in `systemMessage`, the one user-facing field all three
+ * agents share; the agent gets it as a Stop block's `reason` (above). Both
+ * are held under Claude Code's hook output cap (lib/hook-io.ts).
* The documented event name is the only branch — no agent sniffing and no
* agent-specific argument.
*/
@@ -34,6 +46,7 @@ import { fileURLToPath } from "node:url";
import {
readStdinJson,
writeSilentHookOutput,
+ writeStopBlock,
writeSystemMessage,
} from "./lib/hook-io.ts";
import { triggerDebouncedRefresh } from "./lib/qmd-refresh.ts";
@@ -70,7 +83,8 @@ type HookInput = {
};
const input = await readStdinJson<HookInput>();
-// Re-entry by a secondary agent: say nothing and spawn no second refresh,
+// Re-entry (the Stop after a turn this hook forced, or a secondary agent's):
+// say nothing, which is what keeps a block from looping, spawn no second refresh,
// but still emit the empty envelope rather than zero bytes — see
// writeSilentHookOutput for why "sometimes silent, sometimes JSON" is the
// weaker contract.
@@ -130,14 +144,18 @@ const VOLATILE_FIELDS = new Set(["sizeKb", "ageDays", "oldestDays"]);
// drift that was fixed and then came back. A missing session_id fails open
// to reporting.
const sessionId = input?.session_id;
+const isStop = input?.hook_event_name === "Stop";
+const hasSession = typeof sessionId === "string" && sessionId !== "";
const show =
- input?.hook_event_name !== "Stop" ||
- typeof sessionId !== "string" ||
- !sessionId ||
- claimChanged(STATE_PATH, sessionId, reportKey({ checklist, report }, VOLATILE_FIELDS));
+ !isStop || !hasSession || claimChanged(STATE_PATH, sessionId, reportKey({ checklist, report }, VOLATILE_FIELDS));
+
+/** Framing for the agent: it decides what the report calls for. */
+const AGENT_PREFACE =
+ "Stop hook report: your response just ended, and these findings are new or changed since the last report this session; the user was shown the same report. Decide what it calls for: act on what bears on the current work, ask the user when something needs their call, or reply in one line that nothing needs doing now. Never move or delete notes without asking, and do not recite the report back.";
-if (show) writeSystemMessage(message);
-else writeSilentHookOutput();
+if (!show) writeSilentHookOutput();
+else if (isStop && hasSession) writeStopBlock(`${AGENT_PREFACE}\n\n${message}`, message);
+else writeSystemMessage(message);
triggerDebouncedRefresh({
sentinelPath: SENTINEL_PATH,
diff --git a/.claude/scripts/tests/hook-io.test.ts b/.claude/scripts/tests/hook-io.test.ts
index 058bd11..c891356 100644
--- a/.claude/scripts/tests/hook-io.test.ts
+++ b/.claude/scripts/tests/hook-io.test.ts
@@ -7,7 +7,7 @@
import { test, describe, afterEach } from "node:test";
import assert from "node:assert/strict";
-import { debug, warn } from "../lib/hook-io.ts";
+import { debug, fitEncoded, HOOK_OUTPUT_MAX_CHARS, warn, writeStopBlock, writeSystemMessage } from "../lib/hook-io.ts";
/**
* Replace process.stderr.write with a capturer that records calls and returns
@@ -83,3 +83,71 @@ describe("debug", () => {
);
});
});
+
+/** Half of a surrogate pair with its other half missing. */
+const LONE_SURROGATE = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/;
+
+describe("fitEncoded — held under the hook output cap", () => {
+ test("text that fits is returned unchanged", () => {
+ assert.equal(fitEncoded("short", 100), "short");
+ });
+
+ test("counts JSON escaping, which a cut on raw length would miss", () => {
+ // 3,000 backslashes encode to 6,000 characters.
+ const text = "\\".repeat(3_000);
+ const fitted = fitEncoded(text, 4_000);
+ assert.ok(JSON.stringify(fitted).length <= 4_000, `got ${JSON.stringify(fitted).length}`);
+ assert.match(fitted, /… \(truncated to fit the hook output cap\)$/);
+ });
+
+ test("never leaves half of an astral emoji", () => {
+ // Each 🚨 is two UTF-16 units, so a cut on raw length would split one
+ // at every odd cap. Counting the encoded length is what prevents it.
+ for (let max = 200; max < 206; max++) {
+ const fitted = fitEncoded("🚨".repeat(500), max);
+ assert.doesNotMatch(fitted, LONE_SURROGATE, `max ${max} left a lone surrogate`);
+ }
+ });
+});
+
+/** What `write` printed to stdout. */
+function captureStdout(write: () => void): string {
+ const chunks: string[] = [];
+ const original = process.stdout.write.bind(process.stdout);
+ process.stdout.write = ((chunk: string) => {
+ chunks.push(chunk);
+ return true;
+ }) as typeof process.stdout.write;
+ try {
+ write();
+ } finally {
+ process.stdout.write = original;
+ }
+ return chunks.join("");
+}
+
+// "x" encodes to one character, so the cut can land exactly on the cap:
+// these tests assert the exact length, which catches an off-by-one either way.
+describe("writeStopBlock — the whole output fits", () => {
+ test("a huge report and message fill the cap exactly, both marked as cut", () => {
+ const out = captureStdout(() => writeStopBlock("x".repeat(20_000), "x".repeat(20_000)));
+ assert.equal(out.length, HOOK_OUTPUT_MAX_CHARS);
+ const parsed = JSON.parse(out) as { decision: string; reason: string; systemMessage: string };
+ assert.equal(parsed.decision, "block");
+ assert.match(parsed.reason, /truncated to fit the hook output cap\)$/);
+ assert.match(parsed.systemMessage, /truncated to fit the hook output cap\)$/);
+ assert.ok(parsed.reason.length > parsed.systemMessage.length, "the agent's copy gets the larger share");
+ });
+});
+
+describe("writeSystemMessage — the output fits", () => {
+ test("a huge message fills the cap exactly, marked as cut", () => {
+ const out = captureStdout(() => writeSystemMessage("x".repeat(20_000)));
+ assert.equal(out.length, HOOK_OUTPUT_MAX_CHARS);
+ assert.match((JSON.parse(out) as { systemMessage: string }).systemMessage, /truncated to fit the hook output cap\)$/);
+ });
+
+ test("a short message is written unchanged", () => {
+ assert.equal(captureStdout(() => writeSystemMessage("hello")), '{"systemMessage":"hello"}');
+ });
+});
diff --git a/.claude/scripts/tests/stop-checklist.test.ts b/.claude/scripts/tests/stop-checklist.test.ts
index 8d046f0..f3c14fd 100644
--- a/.claude/scripts/tests/stop-checklist.test.ts
+++ b/.claude/scripts/tests/stop-checklist.test.ts
@@ -211,6 +211,57 @@ describe("stop-checklist", () => {
assert.deepEqual(envelopeOf(second.stdout), {});
});
+ test("a changed Stop report reaches the agent: decision block with the report as the reason (#256)", () => {
+ // A Stop systemMessage never reaches the model. decision "block" is the
+ // one Stop output that does, with a turn to act, ask, or say nothing
+ // needs doing; the user still sees the report.
+ const root = vault("block", "Done.md");
+ const envelope = envelopeOf(run(stop("s-block"), { vault: root }).stdout);
+ assert.equal(envelope["decision"], "block");
+ const reason = String(envelope["reason"]);
+ assert.match(reason, /^Stop hook report: .*ask the user when something needs their call/);
+ assert.ok(reason.endsWith(`\n\n${String(envelope["systemMessage"])}`), "the reason carries the report the user sees");
+ assert.match(reason, /work\/active\/Done\.md/);
+ });
+
+ test("an unchanged Stop sends the agent nothing", () => {
+ const root = vault("block-quiet", "Done.md");
+ const state = freshState();
+ run(stop("s-block-quiet"), { vault: root, state });
+ assert.deepEqual(envelopeOf(run(stop("s-block-quiet"), { vault: root, state }).stdout), {});
+ });
+
+ test("the forced turn's own Stop does not block again", () => {
+ // Fresh state, so the change check would block: only the
+ // stop_hook_active exit keeps the forced turn's Stop silent.
+ const root = vault("block-reentry", "Done.md");
+ const reentry = run({ session_id: "s-block-reentry", hook_event_name: "Stop", stop_hook_active: true }, { vault: root });
+ assert.deepEqual(envelopeOf(reentry.stdout), {});
+ });
+
+ test("a report too big for the hook output cap still fits, cut with a marker", () => {
+ // Completed notes left in work/active/ are listed uncapped; four hundred
+ // long names make a report several times the cap.
+ const names = Array.from({ length: 400 }, (_, i) => `A completed note with a deliberately long descriptive title ${i}.md`);
+ const root = vault("block-huge", ...names);
+ const { stdout } = run(stop("s-block-huge"), { vault: root });
+ assert.ok(stdout.length <= 9_500, `stdout is ${stdout.length} chars`);
+ const envelope = envelopeOf(stdout);
+ assert.equal(envelope["decision"], "block");
+ assert.match(String(envelope["reason"]), /truncated to fit the hook output cap\)$/);
+ });
+
+ test("SessionEnd and a Stop without a session_id never block", () => {
+ // SessionEnd has no turn to give, and without a session_id nothing
+ // stops a block from repeating every turn.
+ const root = vault("block-never", "Done.md");
+ for (const payload of [stop(), { session_id: "s-end", hook_event_name: "SessionEnd" }]) {
+ const envelope = envelopeOf(run(payload, { vault: root }).stdout);
+ assert.equal(envelope["decision"], undefined);
+ assert.match(String(envelope["systemMessage"]), /work\/active\/Done\.md/);
+ }
+ });
+
test("a new session reports again even when nothing changed", () => {
const root = vault("new-session", "Done.md");
const state = freshState();
diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md
index d35df48..b4df02e 100644
--- a/ARCHITECTURE.md
+++ b/ARCHITECTURE.md
@@ -195,6 +195,7 @@ sequenceDiagram
Agent->>Hooks: Stop
Hooks->>QMD: debounced refresh (detached)
Hooks-->>User: checklist + hygiene, first time this session or when changed
+ Hooks-->>Agent: same report as a block reason, one turn to act, ask, or pass
end
```
@@ -205,6 +206,7 @@ A few specific design choices are worth calling out:
- **QMD refresh is shared, debounced, and detached.** Three hook entries fire the same refresh helper — `PostToolUse` (after `.md` writes), `PreCompact` (before transcript backup; writes tend to cluster before compaction), and `Stop` (after a response) — sharing one sentinel file so a burst of events produces at most one worker per debounce window. The actual indexing runs in `.claude/scripts/qmd-refresh-run.ts` as a detached, stdio-silent worker (`qmd update` → `qmd embed` → tail-chase `qmd update`), so the parent hook returns in milliseconds and nothing flows to the agent's context.
- **`PreCompact` also backs up the transcript.** In addition to kicking the QMD refresh, it copies the current session transcript out to `thinking/session-logs/` so long conversations remain recoverable after compaction.
- **`Stop` reports once, not every turn.** Claude and Codex fire it whenever the agent finishes a response, not when the session ends (#252). It triggers the shared refresh every time, but shows the checklist and hygiene findings only the first time a session sees that exact report, and again when the findings change; otherwise it returns the empty JSON envelope. A warning that repeats unchanged is one users learn to ignore (#155). The dedupe reuses the classifier's per-session state shape (#107): one self-pruning file, failing open to "show" on a missing `session_id` or unreadable state.
+- **A changed `Stop` report reaches the agent too (#256).** A `systemMessage` is shown to the user and never added to the model's context, so the drift the agent is best placed to fix never reached it. When the findings change, `Stop` also returns `decision: "block"` with the report as the reason, the one `Stop` output that reaches the model. The agent gets a turn to act on it, ask the user, or say in one line that nothing needs doing. The forced turn's own `Stop` arrives with `stop_hook_active` and exits early, so it cannot loop. `SessionEnd` has no turn to give, and a `Stop` without a `session_id` has nothing to stop a block repeating, so neither blocks.
- **Why not `SessionEnd`.** It looks like the natural home for an end-of-session checklist, but Claude Code discards a SessionEnd hook's `systemMessage`, and Codex documents SessionEnd as advisory and does not surface its `systemMessage`. Wired there, the checklist would reach nobody on two of the three agents. Gemini does display it during shutdown, so Gemini keeps its SessionEnd wiring. The acting path is `/om-wrap-up`, which runs the hygiene pass while tools are still live.
---
@@ -874,7 +876,7 @@ Step 2 is not documentation garnish. Measured: with the server wired and no repo
The same scripts serve three agents. Each agent has its own config file mapping equivalent lifecycle events to the shared scripts. The checklist runs on `Stop` for Claude Code and Codex (per response, deduped) and on `SessionEnd` for Gemini (at shutdown). The script branches on the documented event name, never on an agent-specific payload field.
-Session-boundary output is JSON-or-nothing on all three agents. `stop-checklist.ts` emits `{"systemMessage": ...}` when it reports and `{}` when a Stop has nothing new to say. `systemMessage` is intentionally a user warning rather than model context: it tells the user what to ask for, but it cannot make the agent act. That is why `om-wrap-up` owns the acting path and the hook owns only the report.
+Session-boundary output is JSON-or-nothing on all three agents. `stop-checklist.ts` emits `{}` when a Stop has nothing new to say. When it reports, the user gets the report in `systemMessage`, the one user-facing field all three agents share. On a Stop whose findings changed, the agent also gets it as a block `reason`, the one Stop output that reaches the model, with a turn to act, ask, or say nothing needs doing. SessionEnd (Gemini) has no turn to give, so there the report is `systemMessage` only. `om-wrap-up` still owns the deliberate acting pass at the end of a session.
```mermaid
flowchart TB
diff --git a/CLAUDE.md b/CLAUDE.md
index beb4cdf..e5ee195 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -444,7 +444,7 @@ Five lifecycle hooks in `.claude/settings.json`:
| UserPromptSubmit | Every message | Classifies content (decision, incident, win, 1:1, architecture, person, project update) and injects routing hints |
| PostToolUse | After writing `.md` | Validates frontmatter + wikilinks, blocks misplaced memory files, flags notes crossing the 25KB organization threshold (split, don't trim) and write-time topic clusters |
| PreCompact | Before context compaction | Backs up session transcript to `thinking/session-logs/` |
-| Stop | After every response | Checklist + concrete vault-hygiene drift findings (same scan as SessionStart), shown once per session and again only when the findings change; hands drift to `om-tidy`. Also triggers the debounced QMD refresh. For thorough review, use `/om-wrap-up` instead. |
+| Stop | After every response | Checklist + concrete vault-hygiene drift findings (same scan as SessionStart), shown once per session and again only when the findings change; hands drift to `om-tidy`. A Stop `systemMessage` reaches only the user, so a changed report also returns `decision: "block"` with the report as the reason: the agent receives it at once and decides whether to act, ask the user, or say in one line that nothing needs doing. The forced turn's own Stop exits early (`stop_hook_active`), and SessionEnd or a Stop without a session id never blocks. Claude Code labels a Stop block "Stop hook error occurred" even when the hook succeeded. Also triggers the debounced QMD refresh. For thorough review, use `/om-wrap-up` instead. |
## Write-Correctness Laws
diff --git a/README.ja.md b/README.ja.md
index 288d9ce..4704dc1 100644
--- a/README.ja.md
+++ b/README.ja.md
@@ -198,7 +198,7 @@ QMDは**3つの小さなモデルをローカルで**実行します。設定す
| 💬 UserPromptSubmit | 全メッセージ | コンテンツを分類(意思決定、インシデント、実績、1on1、アーキテクチャ、人物、プロジェクト更新)してルーティングヒントを注入 |
| ✍️ PostToolUse | `.md`書き込み後 | フロントマター+ウィキリンクの検証、誤配置メモリファイルのブロック、肥大ノート(削るのではなく分割)と書き込み時トピッククラスタのフラグ |
| 💾 PreCompact | コンテキスト圧縮前 | セッション記録を`thinking/session-logs/`にバックアップ |
-| 🏁 Stop | 各応答の終了時 | チェックリスト+具体的なドリフト検出(SessionStartと同じ衛生スキャン)。セッションごとに1回、内容が変わった時のみ再表示。対応は`om-tidy`へ |
+| 🏁 Stop | 各応答の終了時 | チェックリスト+具体的なドリフト検出(SessionStartと同じ衛生スキャン)。セッションごとに1回、内容が変わった時のみ再表示。エージェントにも届き、対応するかはエージェントが判断。対応は`om-tidy`へ |
> [!TIP]
> ただ話すだけ。フックがルーティングを処理します。
diff --git a/README.ko.md b/README.ko.md
index a17db2b..b187559 100644
--- a/README.ko.md
+++ b/README.ko.md
@@ -198,7 +198,7 @@ QMD는 **세 개의 작은 모델을 로컬에서** 실행하므로, 설정할 A
| 💬 UserPromptSubmit | 매 메시지마다 | 콘텐츠 분류(의사결정, 인시던트, 성과, 1:1, 아키텍처, 인물, 프로젝트 업데이트) 및 라우팅 힌트 주입 |
| ✍️ PostToolUse | `.md` 작성 후 | 프론트매터+위키링크 검증, 잘못 배치된 메모리 파일 차단, 비대 노트(줄이지 말고 분할)와 작성 시점 토픽 클러스터 플래그 |
| 💾 PreCompact | 컨텍스트 압축 전 | 세션 트랜스크립트를 `thinking/session-logs/`에 백업 |
-| 🏁 Stop | 각 응답 종료 시 | 체크리스트+구체적인 드리프트 발견 (SessionStart와 동일한 위생 스캔). 세션당 한 번, 내용이 바뀔 때만 다시 표시. 조치는 `om-tidy`로 |
+| 🏁 Stop | 각 응답 종료 시 | 체크리스트+구체적인 드리프트 발견 (SessionStart와 동일한 위생 스캔). 세션당 한 번, 내용이 바뀔 때만 다시 표시. 에이전트에게도 전달되며 조치 여부는 에이전트가 판단. 조치는 `om-tidy`로 |
> [!TIP]
> 그냥 이야기하세요. 훅이 라우팅을 처리합니다.
diff --git a/README.md b/README.md
index 6db70c5..45d5ae2 100644
--- a/README.md
+++ b/README.md
@@ -205,7 +205,7 @@ Five lifecycle hooks handle routing automatically:
| 💬 UserPromptSubmit | Every message | Classifies content (decision, incident, win, 1:1, architecture, person, project update) and injects routing hints |
| ✍️ PostToolUse | After writing `.md` | Validates frontmatter + wikilinks, blocks misplaced memory files, flags oversized notes (split, don't trim) and write-time topic clusters |
| 💾 PreCompact | Before context compaction | Backs up session transcript to `thinking/session-logs/` |
-| 🏁 Stop | After every response | Checklist + concrete drift findings (same hygiene scan as SessionStart), shown once per session and again only when they change; hands drift to `om-tidy` |
+| 🏁 Stop | After every response | Checklist + concrete drift findings (same hygiene scan as SessionStart), shown once per session and again only when they change, to you and to the agent, which decides whether to act; hands drift to `om-tidy` |
> [!TIP]
> You just talk. The hooks handle the routing.
diff --git a/README.zh-CN.md b/README.zh-CN.md
index f507d70..40992cc 100644
--- a/README.zh-CN.md
+++ b/README.zh-CN.md
@@ -198,7 +198,7 @@ QMD **在本地运行三个小模型**,因此不需要配置 API 密钥,没
| 💬 UserPromptSubmit | 每条消息 | 对内容分类(决策、事件、成就、1:1、架构、人员、项目更新)并注入路由提示 |
| ✍️ PostToolUse | 写入 `.md` 后 | 验证 frontmatter+wikilinks,拦截误放的记忆文件,标记过大笔记(拆分而非删减)与写入时的主题集群 |
| 💾 PreCompact | 上下文压缩前 | 将会话记录备份到 `thinking/session-logs/` |
-| 🏁 Stop | 每次响应结束后 | 检查清单+具体漂移发现(与 SessionStart 相同的卫生扫描),每个会话显示一次,仅在内容变化时再次显示;处理交给 `om-tidy` |
+| 🏁 Stop | 每次响应结束后 | 检查清单+具体漂移发现(与 SessionStart 相同的卫生扫描),每个会话显示一次,仅在内容变化时再次显示;同时发送给智能体,由其判断是否处理;处理交给 `om-tidy` |
> [!TIP]
> 你只需要正常对话。钩子会处理路由。
diff --git a/brain/Skills.md b/brain/Skills.md
index ca7dd41..bd06b2b 100644
--- a/brain/Skills.md
+++ b/brain/Skills.md
@@ -106,7 +106,7 @@ Subagents run in isolated context windows via `.claude/agents/`. They don't poll
| UserPromptSubmit | Every message | Classify content (decision, incident, 1:1, win, architecture, person, project update) and inject routing hints |
| PostToolUse | After writing `.md` | Validates frontmatter, checks for wikilinks |
| PreCompact | Before context compaction | Back up session transcript to `thinking/session-logs/` |
-| Stop | After every response | Checklist + hygiene findings, once per session and again when they change; ask the agent to run `om-tidy` to act |
+| Stop | After every response | Checklist + hygiene findings, once per session and again when they change, to the user and to the agent (which decides whether to act); ask the agent to run `om-tidy` to act |
## Semantic Search (QMD)