Skip to content

feat: save full conversation transcript on Claude compaction#105

Merged
bborn merged 2 commits intomainfrom
task/206-handle-claude-compaction
Jan 11, 2026
Merged

feat: save full conversation transcript on Claude compaction#105
bborn merged 2 commits intomainfrom
task/206-handle-claude-compaction

Conversation

@bborn
Copy link
Copy Markdown
Owner

@bborn bborn commented Jan 11, 2026

Summary

  • Leverages Claude Code's PreCompact hook to save the complete conversation transcript to our database before compaction occurs
  • Adds task_compaction_summaries table to store transcripts with metadata (trigger type, token count, session info)
  • Provides persistent backup that survives Claude's session cleanup (cleanupPeriodDays)

Why this is better than just letting Claude compaction proceed

  1. Persistence - Claude's sessions get cleaned up after ~20 days by default. Our saved transcripts survive indefinitely
  2. Full fidelity - We save the complete JSONL transcript, not a lossy summary
  3. Audit trail - Can debug/analyze what happened in long-running tasks
  4. Recovery - Tasks that resume weeks/months later still have full context available
  5. Future flexibility - Can use Claude to re-summarize transcripts if needed

How it works

  1. PreCompact hook fires when Claude is about to compact (manual /compact or auto when context fills)
  2. Hook reads the full transcript JSONL file
  3. Saves to task_compaction_summaries table with metadata
  4. Claude proceeds with its normal compaction

The saved transcript is not injected back into prompts - Claude maintains its own compacted summary. Our transcripts serve as a safety net.

Test plan

  • Added tests for SaveCompactionSummary, GetCompactionSummaries, GetLatestCompactionSummary
  • Added test for cascade delete when task is deleted
  • All existing tests pass

🤖 Generated with Claude Code

bborn and others added 2 commits January 11, 2026 09:31
Leverage Claude Code's PreCompact hook to save the complete conversation
transcript to our database before compaction occurs. This provides:

- Persistent backup that survives Claude's session cleanup (cleanupPeriodDays)
- Full audit trail for debugging and analysis
- Source for future re-summarization if needed
- Recovery option for tasks that resume weeks/months later

Implementation:
- Add PreCompact hook to setupClaudeHooks in executor.go
- Create handlePreCompactHook to save transcript on compaction events
- Add task_compaction_summaries table to store transcripts with metadata
- Track trigger type (manual/auto), token count, and session info

The transcript is saved but not injected back into prompts - Claude
maintains its own compacted summary internally. Our saved transcripts
serve as a safety net and audit trail.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
In addition to saving transcripts during compaction events, now also
save the full conversation transcript when a task completes. This
ensures we always have a record of what Claude did, even if compaction
never occurred during the task.

Trigger types are now:
- "auto" - automatic compaction when context fills
- "manual" - user ran /compact command
- "completion" - task finished successfully

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@bborn bborn merged commit e55247f into main Jan 11, 2026
bborn added a commit that referenced this pull request Jan 31, 2026
The task_compaction_summaries table was bloating the database (1.4GB for
62 rows) by saving full JSONL transcripts when Claude auto-compacts. This
feature was added in PR #105 but never provided real value.

Removed:
- task_compaction_summaries table and migrations
- CompactionSummary struct and all DB methods (SaveCompactionSummary,
  GetCompactionSummaries, GetLatestCompactionSummary, ClearCompactionSummaries)
- MCP server include_transcript parameter for workflow_show_task
- PreCompact hook handler in main.go
- saveTranscriptOnCompletion function in executor
- All related tests

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@bborn bborn mentioned this pull request Jan 31, 2026
3 tasks
bborn added a commit that referenced this pull request Jan 31, 2026
The task_compaction_summaries table was bloating the database (1.4GB for
62 rows) by saving full JSONL transcripts when Claude auto-compacts. This
feature was added in PR #105 but never provided real value.

Removed:
- task_compaction_summaries table and migrations
- CompactionSummary struct and all DB methods (SaveCompactionSummary,
  GetCompactionSummaries, GetLatestCompactionSummary, ClearCompactionSummaries)
- MCP server include_transcript parameter for workflow_show_task
- PreCompact hook handler in main.go
- saveTranscriptOnCompletion function in executor
- All related tests

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
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