🐛 v8.62.1 - Critical SessionEnd Hook Fix
Release Date: December 28, 2025
Overview
This patch release fixes a critical bug in the SessionEnd hook where it was using hardcoded mock conversation data instead of reading the actual session transcript from Claude Code. This resulted in all session consolidation memories containing identical mock phrases regardless of actual conversation content.
Special thanks to @channingwalton for discovering and fixing this bug in PR #301!
Fixed
SessionEnd Hook: Read Actual Conversation from Transcript
Problem:
- SessionEnd hook always used hardcoded mock data
- Never read stdin from Claude Code
- All session-consolidation memories contained identical mock phrases
Root Cause:
- Main execution block (
if (require.main === module)) always used mock conversation data readStdinContext()function was missing to read from Claude Code's stdin- No transcript parsing logic to extract real conversation
Solution:
- ✅ Added
readStdinContext()to parse JSON context from Claude Code stdin - ✅ Added
parseTranscript()to read and parse JSONL transcript files - ✅ Handles both string and array content formats (robust parsing)
- ✅ Gracefully handles malformed JSON entries
- ✅ Filters correctly to user/assistant messages only
- ✅ Mock data preserved as fallback for manual testing
Impact:
- Session consolidation memories now contain actual conversation content
- SessionEnd hook accurately captures topics, decisions, insights, and code changes
- Improved memory quality and relevance
Testing:
- 4 new integration tests added:
- String content messages
- Array content blocks
- Non-user/assistant entry filtering
- Malformed JSON handling
Files Changed:
claude-hooks/core/session-end.jsclaude-hooks/tests/integration-test.jsclaude-hooks/utilities/context-formatter.js
SessionEnd Hook: Remove Arbitrary 5-Topic Limit
Problem:
analyzeConversation()limited topics to 5 via.slice(0, 5)- Order-dependent matching meant specific topics (e.g., "database") were dropped when generic keywords matched first
Solution:
- ✅ Removed the
.slice(0, 5)limit (only 10 possible topics anyway) - ✅ All matching topics now captured in session summaries
Impact:
- More comprehensive session consolidation
- No relevant topics lost due to arbitrary limit
Technical Details
New Functions
readStdinContext()
- Reads JSON context from Claude Code stdin
- Returns:
{ transcript_path, reason, cwd, session_id } - 100ms timeout for graceful fallback to mock data
- Proper error handling for stdin errors
parseTranscript(transcriptPath)
- Parses JSONL transcript file to extract conversation messages
- Returns:
{ messages: Array<{role, content}> } - Handles both string and array content formats
- Gracefully skips malformed JSON lines
- Filters to user/assistant messages only
Hook Execution Flow
// 1. Read stdin context from Claude Code
const stdinContext = await readStdinContext();
// 2. Parse transcript file if provided
if (stdinContext && stdinContext.transcript_path) {
const conversation = await parseTranscript(stdinContext.transcript_path);
// Use real conversation data
} else {
// Fallback to mock data for manual testing
}
// 3. Analyze and store session consolidation
await onSessionEnd(context);Integration Test Coverage
| Test | Description |
|---|---|
| String content messages | Validates parsing of simple string content |
| Array content blocks | Validates joining of multi-block content |
| Non-message entry filtering | Validates skipping file-history-snapshot and system entries |
| Malformed JSON handling | Validates graceful recovery from parse errors |
Upgrade Notes
No breaking changes - This release is backward compatible.
Recommended Actions:
- Update to v8.62.1:
pip install --upgrade mcp-memory-service - Restart MCP Memory Service
- Verify session consolidation now captures real conversation content
Acknowledgments
Huge thanks to @channingwalton for:
- Discovering this undiscovered bug
- Providing a comprehensive fix with robust error handling
- Adding thorough integration tests
- Following project conventions and documentation standards
This is exactly the kind of high-quality external contribution we love to see!
What's Next
This patch release ensures session consolidation memories accurately reflect actual conversation content. Future enhancements will build on this foundation to provide even better context awareness.
Full Changelog: https://github.com/doobidoo/mcp-memory-service/blob/main/CHANGELOG.md
PyPI Package: https://pypi.org/project/mcp-memory-service/8.62.1/
Docker Image: ghcr.io/doobidoo/mcp-memory-service:8.62.1