fix(session-end): skip end marker for empty sessions#37
Conversation
Empty sessions (transcriptMessages.length === 0) previously emitted a [Session ended] lifecycle marker that the Honcho deriver dutifully extracted as durable memory observations: "<peer>'s session ended on May 7, 2026, at 00:18:47 UTC." "The session <peer> ended on May 7, 2026, contained zero messages." These observations have no future-recall value — they are session-plumbing exhaust extracted as user/AI facts. Each one also costs deriver LLM tokens to process. Multi-profile setups where Claude Code restarts often (resume, fork) accumulate these at high frequency. The fix gates endMarker creation behind transcriptMessages.length > 0. Side-channel queued messages (e.g. [Git External] from session-start, queued user prompts) still upload normally; only the lifecycle marker is suppressed. The existing if (allMessages.length > 0) guard handles the fully-empty case (no user, no assistant, no marker) and skips the upload entirely. Also tightens the API-call log line to reflect whether a marker was included or skipped.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughThe ChangesSession-End Empty Marker Suppression
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
The
session-endhook unconditionally posts a[Session ended] Reason: ${reason}, Messages: ${count}, Time: ${iso}marker to Honcho on every termination, including sessions with zero transcript messages (e.g. resumed but never used). Honcho's deriver then extracts these markers as durable memory observations, e.g.:These have no future-recall value — they're session-plumbing exhaust extracted as user/AI facts — and each one costs deriver LLM tokens.
What this changes
Gates
endMarkercreation behindtranscriptMessages.length > 0inplugins/honcho/src/hooks/session-end.ts.[Git External]from session-start, queued user prompts) still upload normally — only the lifecycle marker is suppressed.if (allMessages.length > 0)guard handles the fully-empty case and skips the upload entirely.Why minimal
The fix is intentionally narrow. Non-empty sessions still get their end markers (preserves session-end timestamps in memory). Only the zero-message lifecycle artifact — the one with no signal at all — is dropped.
Test plan
bunx tsc --noEmitcleanmainand ships no new tests;config.test.tsis added by feat(config): HONCHO_PROFILE env var for per-session identity routing #33/feat(config): HONCHO_SESSION env var for per-launch session pinning #36)🤖 Generated with Claude Code
Summary by CodeRabbit