Commit aefc1eb
fix(claude-code): retain on SessionEnd even when retainEveryNTurns > 1 (#1152)
With retainEveryNTurns > 1, short Claude Code sessions (fewer turns
than the interval) never hit a retain boundary and their transcript is
silently dropped on session close. SessionEnd previously only stopped
the daemon and did not flush.
Refactor retain.py by splitting main() into:
- main(): reads stdin, delegates to run_retain(hook_input, force=False)
- run_retain(hook_input, force=False): the retain body; force=True
bypasses the retainEveryNTurns turn-counter skip so a caller can
request a final flush.
session_end.py now imports run_retain and calls it with force=True
before stopping the daemon, guaranteeing that every session lands on
disk regardless of length or retain cadence.
Net effect: `retainEveryNTurns: 10` (the default) stops silently losing
sessions under 10 turns.
Co-authored-by: biostartechnology <info@biostartechnology.com>1 parent 9c9d791 commit aefc1eb
2 files changed
Lines changed: 22 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
| 72 | + | |
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
| 79 | + | |
87 | 80 | | |
88 | 81 | | |
89 | 82 | | |
| |||
102 | 95 | | |
103 | 96 | | |
104 | 97 | | |
105 | | - | |
106 | | - | |
| 98 | + | |
| 99 | + | |
107 | 100 | | |
108 | 101 | | |
109 | 102 | | |
| |||
226 | 219 | | |
227 | 220 | | |
228 | 221 | | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
229 | 231 | | |
230 | 232 | | |
231 | 233 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
31 | 40 | | |
32 | 41 | | |
33 | 42 | | |
| |||
0 commit comments