Skip to content

fix(session-end): skip end marker for empty sessions#37

Open
sasha-id wants to merge 1 commit into
plastic-labs:mainfrom
sasha-id:fix/skip-empty-session-marker
Open

fix(session-end): skip end marker for empty sessions#37
sasha-id wants to merge 1 commit into
plastic-labs:mainfrom
sasha-id:fix/skip-empty-session-marker

Conversation

@sasha-id
Copy link
Copy Markdown

@sasha-id sasha-id commented May 7, 2026

Summary

The session-end hook 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.:

  • "<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 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 endMarker creation behind transcriptMessages.length > 0 in plugins/honcho/src/hooks/session-end.ts.

  • 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 and skips the upload entirely.
  • API-call log line now reflects whether a marker was included or skipped.

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

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Session-end hook now skips emitting the session-ended marker when sessions contain no transcript messages, while continuing to upload other queued messages as expected.

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.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 7, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7b0d593d-2538-4664-a62d-f9017e06a38c

📥 Commits

Reviewing files that changed from the base of the PR and between 0813ebd and 1ea3f39.

📒 Files selected for processing (2)
  • CHANGELOG.md
  • plugins/honcho/src/hooks/session-end.ts

Walkthrough

The session-end hook is updated to conditionally suppress the [Session ended] marker when a session contains zero transcript messages. Side-channel queued messages continue uploading normally; only the marker extraction is gated for empty sessions.

Changes

Session-End Empty Marker Suppression

Layer / File(s) Summary
Core Logic
plugins/honcho/src/hooks/session-end.ts
handleSessionEnd now creates the [Session ended] marker only when transcriptMessages.length > 0. For empty sessions, the marker is set to null and omitted from the final payload, while other queued messages remain unaffected. Logging updated to reflect marker inclusion status.
Documentation
CHANGELOG.md
Changelog entry added under [Unreleased] → Fixed documenting the new behavior that prevents durable-memory marker emission for empty sessions.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 An empty session whispers low,
No marker needed—silence, though!
The side-channel flows, messages stay,
While phantom endings fade away. ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(session-end): skip end marker for empty sessions' accurately and specifically summarizes the main change: conditionally skipping the end marker for empty sessions.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant