Skip to content

RelationshipMemory.hook.ts silently broken in v4.0 — references nonexistent ParsedTranscript.userPrompt #971

@catchingknives

Description

@catchingknives

Summary

RelationshipMemory.hook.ts was refactored in v4.0.0 to use the new shared TranscriptParser, but the migration introduced a breaking reference to a field (userPrompt) that doesn't exist on the ParsedTranscript interface. The hook silently produces zero output and has been non-functional since v4.0.0.

Bug Details

In v3.0, the hook parsed transcripts directly via readFileSync + JSON line parsing, accessing entry.message.content on each JSONL entry. This worked — both user and assistant messages were read.

In v4.0.0, the hook was refactored to use parseTranscript() from PAI/Tools/TranscriptParser.ts:

// RelationshipMemory.hook.ts, lines 76-84
const parsed = parseTranscript(path);
const entries: TranscriptEntry[] = [];
if (parsed.userPrompt) {          // <-- doesn't exist
  entries.push({ type: 'user', text: parsed.userPrompt });
}
if (parsed.plainCompletion) {
  entries.push({ type: 'assistant', text: parsed.plainCompletion });
}

ParsedTranscript interface (TranscriptParser.ts) has these fields:

raw, lastMessage, currentResponseText, voiceCompletion,
plainCompletion, structured, responseState

No userPrompt field. It's always undefined.

Impact

Three compounding failures:

  1. User messages never capturedparsed.userPrompt is undefined, so preference/frustration/positive pattern matching against user input never fires
  2. Assistant content too narrowplainCompletion is a short extracted string, not the full response. Most SUMMARY: and milestone regex patterns don't match against it
  3. Silent failure — the hook exits cleanly with [RelationshipMemory] No relationship notes to capture, no error thrown

Result: MEMORY/RELATIONSHIP/ receives zero new entries. In my install, the last entry is from Feb 27 (pre-v4.0 upgrade). No 2026-03 directory was ever created despite daily use.

Steps to Reproduce

  1. Install PAI v4.0.x
  2. Run any session and let it end cleanly (SessionEnd fires)
  3. Check MEMORY/RELATIONSHIP/ — no new files created
  4. Check stderr — hook logs "No relationship notes to capture"

Suggested Fix

Either:

  • Minimal: Add userPrompt field to ParsedTranscript in TranscriptParser.ts and populate it from the last user message in the transcript
  • Better: Expose full userMessages and assistantMessages arrays from ParsedTranscript so hooks can access the complete conversation, not just the last turn. The v3.0 approach of iterating all JSONL entries was more thorough

Environment

  • PAI v4.0.3 / Algorithm v3.7.0
  • Claude Code 2.1.78
  • macOS Darwin 25.3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions