fix(hooks): use SessionEnd not Stop for Claude Code transcript extraction#355
Open
Huntehhh wants to merge 1 commit into
Open
Conversation
…tion
The Claude Code adapter installs the `stop.py` extraction hook on the
`Stop` event, which fires per assistant turn (once per response). The
intent — per the README and stop.py docstring — is session-end
extraction. The Gemini adapter at adapters/gemini.py:27 already uses
`SessionEnd` correctly; the Claude adapter was missed.
Per Claude Code docs (code.claude.com/docs/en/hooks):
- `Stop` fires once per turn ("when Claude finishes responding")
- `SessionEnd` fires once per session ("when a session terminates")
Net effect of the bug: every assistant turn triggers an ingest spawn.
The 20/hr budget + 2-process spawn cap prevent runaway, but produces
~1 ingest spawn every ~10s on chatty sessions — most then no-op via
the size-dedup gate but still cost the python.exe spawn cycle.
Fix is the trivial event-name swap on the Claude adapter only.
Codex (adapters/codex.py:30) and Kimi (adapters/kimi.py:30) adapters
intentionally untouched — they correctly use 'Stop' per their own
CLI specs.
Files changed:
- truememory/ingest/cli.py:794 docstring narrative
- truememory/ingest/cli.py:812 installer event key (the bug)
- truememory/ingest/cli.py:1086 expected-events health check
- truememory/ingest/CLAUDE_TEMPLATE.md user-facing narrative
- docs/architecture.md
- install.sh comment
Co-Authored-By: claude-opus-4-7 <wontreply@getfucked.ai>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Claude Code adapter wires
stop.pyto the per-turnStopevent instead of the per-sessionSessionEndevent. Per Claude Code's hook docs:Stopfires once per assistant response;SessionEndfires once per session terminate. Result: every turn triggers an ingest spawn — the 20/hr budget + 2-process spawn cap prevent runaway, but produces visible ingest spam on chatty sessions, most of which then no-op via the size-dedup gate but still pay thepython.exespawn cost.The Gemini adapter at
truememory/hooks/adapters/gemini.py:27already usesSessionEndcorrectly — this brings the Claude adapter in line with that pattern. Codex (adapters/codex.py:30) and Kimi (adapters/kimi.py:30) intentionally untouched — they correctly useStopper their own CLI specs.Changes
truememory/ingest/cli.py:794truememory/ingest/cli.py:812"Stop"→"SessionEnd"(the bug)truememory/ingest/cli.py:1086truememory/ingest/CLAUDE_TEMPLATE.md:36docs/architecture.md:43install.sh:15Test plan
truememory-ingest statusshowsHooks installed: SessionStart, UserPromptSubmit, SessionEnd, PreCompact~/.claude/settings.jsoncontains a"SessionEnd"block pointing atstop.pyps -ef | grep truememory.ingest.clireturns nothing during the conversation)Stopper their CLI specs)References
truememory/hooks/adapters/gemini.py:27Co-Authored-By: claude-opus-4-7 wontreply@getfucked.ai