Upstream feature: Claude Code hooks (session briefing and abandoned-approach guard) #22

Closed
opened 2026-11-02 10:38:36 +00:00 by tim · 2 comments
Owner

Seen in upstream v7.0.3 (2026-10-21, Rust rewrite, still current in v7.0.5): https://code.squarecows.com/ric/omnimem/releases

What upstream does: omnimem hook provides Claude Code hooks that (1) put a project briefing into each session automatically and (2) block a tool call that repeats an abandoned approach (the graveyard check runs before the tool call, not only when the model remembers to call warn_if_abandoned).

Why it may fit: today both depend on the model following CLAUDE.md instructions (briefing at session start, warn_if_abandoned before an approach). Hooks make them deterministic. The Python server already has the data (briefing, abandoned_approaches fast path); this would be a small client-side script or CLI entry point that calls the MCP tools and prints hook JSON.

Rough size: small to medium. A hook script (SessionStart briefing, PreToolUse abandoned check) plus docs in claude_config/ and tests with the existing fakes. Open question: what the PreToolUse matcher keys on, since a tool call is not an "approach" text.

Upstream version looked at: v7.0.5. Next run starts from there.

Close this issue if you do not want it. Comment ok to approve it for implementation.

Seen in upstream **v7.0.3** (2026-10-21, Rust rewrite, still current in v7.0.5): https://code.squarecows.com/ric/omnimem/releases **What upstream does:** `omnimem hook` provides Claude Code hooks that (1) put a project briefing into each session automatically and (2) block a tool call that repeats an abandoned approach (the graveyard check runs before the tool call, not only when the model remembers to call `warn_if_abandoned`). **Why it may fit:** today both depend on the model following CLAUDE.md instructions (`briefing` at session start, `warn_if_abandoned` before an approach). Hooks make them deterministic. The Python server already has the data (`briefing`, `abandoned_approaches` fast path); this would be a small client-side script or CLI entry point that calls the MCP tools and prints hook JSON. **Rough size:** small to medium. A hook script (SessionStart briefing, PreToolUse abandoned check) plus docs in `claude_config/` and tests with the existing fakes. Open question: what the PreToolUse matcher keys on, since a tool call is not an "approach" text. Upstream version looked at: v7.0.5. Next run starts from there. Close this issue if you do not want it. Comment `ok` to approve it for implementation.
Author
Owner

Ok.

Ok.
tim closed this issue 2026-11-03 07:50:32 +00:00
Author
Owner

Shipped as v6.11.1 (PRs #30, #32; release PRs #31, #33). Use 6.11.1, not 6.11.0: the v6.11.0 tag build failed in its test stage (the test image did not copy claude_config/), so that tag has no images and no release; 6.11.1 carries the same code plus the fix.

What it is: claude_config/hooks/omnimem_hook.py, one stdlib-only file talking to the server over MCP.

  • SessionStart injects a read-only briefing, dead ends first. PreToolUse denies a mutating tool call that puts an abandoned approach in place, with the reason and what worked instead.
  • Answer to the open question about the matcher: it keys on the text the call would put in place (new_string, content, a mutating Bash command), never old_string, as a whole abandoned name on word boundaries, ignoring case and separators. Reads are never blocked; ls vendor/kestrel-rs passes, cargo add kestrel-rs does not.
  • Server side, additive: warn_if_abandoned(query, project?, proposal?) and briefing(read_only=True).

Decisions to look at:

  1. Each dead end is denied once per session; repeating the call goes through, so a stale record cannot deadlock the agent. Upstream denies every time.
  2. The hooks need the server on MCP_TRANSPORT=http. The deprecated SSE transport is not supported (the script says so on stderr and does nothing). The shipped default is still sse.
  3. Auth is the existing MCP_AUTH_TOKEN bearer via OMNIMEM_TOKEN; never sent over cleartext http to a non-loopback host.
  4. Not included: upstream's session-end hook (writes a session log; redaction and dedup it needs are unmeasured) and an installer.

Verified against the real server (bearer auth on) under Python 3.13 and 3.12, and in the exact CI test image. A bug found on the way: ruff at py314 rewrote except (A, B): into the 3.14-only form and broke the script on the user's python3; pinned to py39 for that directory in ruff.toml with two tests. The guard's effect on the dead-end benchmark is not measured (the 27% figure is for the prototype). Docs: docs/claude-code-hooks.md.

Shipped as v6.11.1 (PRs #30, #32; release PRs #31, #33). **Use 6.11.1, not 6.11.0**: the v6.11.0 tag build failed in its test stage (the test image did not copy `claude_config/`), so that tag has no images and no release; 6.11.1 carries the same code plus the fix. What it is: `claude_config/hooks/omnimem_hook.py`, one stdlib-only file talking to the server over MCP. - `SessionStart` injects a read-only briefing, dead ends first. `PreToolUse` denies a mutating tool call that puts an abandoned approach in place, with the reason and what worked instead. - Answer to the open question about the matcher: it keys on the text the call would put in place (`new_string`, `content`, a mutating Bash command), never `old_string`, as a whole abandoned name on word boundaries, ignoring case and separators. Reads are never blocked; `ls vendor/kestrel-rs` passes, `cargo add kestrel-rs` does not. - Server side, additive: `warn_if_abandoned(query, project?, proposal?)` and `briefing(read_only=True)`. Decisions to look at: 1. Each dead end is denied once per session; repeating the call goes through, so a stale record cannot deadlock the agent. Upstream denies every time. 2. The hooks need the server on `MCP_TRANSPORT=http`. The deprecated SSE transport is not supported (the script says so on stderr and does nothing). The shipped default is still `sse`. 3. Auth is the existing `MCP_AUTH_TOKEN` bearer via `OMNIMEM_TOKEN`; never sent over cleartext http to a non-loopback host. 4. Not included: upstream's `session-end` hook (writes a session log; redaction and dedup it needs are unmeasured) and an installer. Verified against the real server (bearer auth on) under Python 3.13 and 3.12, and in the exact CI test image. A bug found on the way: ruff at py314 rewrote `except (A, B):` into the 3.14-only form and broke the script on the user's `python3`; pinned to py39 for that directory in `ruff.toml` with two tests. The guard's effect on the dead-end benchmark is not measured (the 27% figure is for the prototype). Docs: `docs/claude-code-hooks.md`.
Sign in to join this conversation.
No labels
upstream-feature
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
tim/omnimem#22
No description provided.