feat: use compressObservation for tool capture in session transcripts#75
feat: use compressObservation for tool capture in session transcripts#75myselfsiddharth wants to merge 2 commits into
Conversation
Wire the existing compress.js helper into transcript-formatter so auto-captured tool activity is summarized semantically instead of truncating raw tool output to 500 characters. Store tool name and input in toolUseMap so compressObservation can produce concise descriptions (e.g. "Edited stdin.js: ..." instead of a blob of tool result text). Remove unused MAX_TOOL_RESULT_LENGTH and drop truncate from public exports. Rebuild summary-hook.cjs bundle.
There was a problem hiding this comment.
Summary
Reviewed — found 1 issue(s). This PR changes transcript formatting to capture tool results through compressObservation() and updates the generated summary hook bundle. The review focused on correctness and data quality risks in captured session transcripts.
Findings
src/lib/transcript-formatter.js
tool_resultformatting now always usescompressObservation(), which can drop meaningful output for unsupported includable tools and misleadingly summarize failed operations without preserving the actual error text.
Verdict
| ); | ||
| const status = block.is_error ? 'error' : 'success'; | ||
| if (resultContent) { | ||
| const compressed = compressObservation(toolName, toolEntry.input, { |
There was a problem hiding this comment.
compressObservation() replaces the previous cleaned/truncated tool_result content for every included tool, but it only has meaningful summaries for a subset of documented includable tools and does not reliably preserve failure output. For unsupported tools such as TodoWrite, TaskOutput, AskUserQuestion, or LSP, transcript capture can degrade to generic text like Used <tool>, and failed operations such as Edit, Write, or Read can omit the actual error that explains what happened. Please keep a fallback to the cleaned/truncated block.content when the tool is unsupported or block.is_error is true, or extend compressObservation() so every includable tool and failure path preserves a meaningful result summary.
There was a problem hiding this comment.
Fixed It! mb, did not consider that
TestingFunctional verification was performed against PR commit Commands run: git worktree add --detach /tmp/claude-supermemory-pr75 origin/pr-75
cd /tmp/claude-supermemory-pr75
npm ci
npm run clean
npm run build
grep -q 'Edited ' plugin/scripts/summary-hook.cjs
grep -q 'Used ' plugin/scripts/summary-hook.cjs
grep -q 'compressObservation' plugin/scripts/summary-hook.cjs
npm run lint
node /tmp/pr75-formatter-tests.cjs
unset SUPERMEMORY_CC_API_KEY
echo '{}' | node plugin/scripts/context-hook.cjs
printf {session_id:pr75-smoke,transcript_path:%s,cwd:%s}n "$tmptranscript" "$PWD" | node plugin/scripts/summary-hook.cjsResult: Verdict✅ Passed. The exercised build, lint, formatter, and hook smoke checks completed successfully; the repository still lacks committed regression tests for |
Address review feedback on compressObservation integration: - Fall back to cleaned, truncated tool_result content when compressObservation returns a generic "Used <tool>" string (unsupported includable tools like TodoWrite, LSP, etc.) - On failed tools, append the actual error output after the compressed summary so captured memories retain failure context Rebuild summary-hook.cjs bundle.
|
Thanks — confirmed the latest PR head |
Summary
Session auto-capture (
summary-hook) formats Claude Code transcripts before saving them to Supermemory. WhenincludeToolsis configured, tool activity was previously stored by truncating raw tool result text to 500 characters. That produced noisy, low-signal memories.This PR wires up the existing
compress.jsmodule (which was already in the repo but unused) intotranscript-formatter.js. Tool results are now summarized withcompressObservation(), using the original tool name and input from the assistant'stool_useblock.Before: raw truncated output
After: semantic summary
Changes
compressObservationfrom./compressintranscript-formatter.js{ name, input }intoolUseMapinstead of just the tool name stringMAX_TOOL_RESULT_LENGTHtruncation withcompressObservation()for tool resultsMAX_TOOL_RESULT_LENGTHconstanttruncatefrommodule.exports(still used internally; nothing imported it externally)plugin/scripts/summary-hook.cjsNo changes to
compress.jsitself.Why this matters
Supermemory extracts memories from these transcripts using
PERSONAL_ENTITY_CONTEXT. Higher-quality tool summaries give the extraction layer better signal about what the user actually did, especially for Edit, Write, Bash, Read, and Grep turns.Test plan
npx biome check src/lib/transcript-formatter.jspassesnpm run buildsucceedssummary-hook.cjsbundle changes (the sole consumer oftranscript-formatter)includeTools: ["Edit", "Write"]in settings produces compressed tool lines in saved session memoryformatSignalEntries) is unaffected (it uses text-only formatting and skips tool results)Session Details
(aside)to your comment to have me ignore it.