diff options
Diffstat (limited to 'docs/adr/0003-compact-is-a-sanctioned-rewrite.md')
| -rw-r--r-- | docs/adr/0003-compact-is-a-sanctioned-rewrite.md | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/docs/adr/0003-compact-is-a-sanctioned-rewrite.md b/docs/adr/0003-compact-is-a-sanctioned-rewrite.md new file mode 100644 index 0000000..19a42dc --- /dev/null +++ b/docs/adr/0003-compact-is-a-sanctioned-rewrite.md | |||
| @@ -0,0 +1,37 @@ | |||
| 1 | # 0003 — `/compact` is the single sanctioned rewrite of a transcript | ||
| 2 | |||
| 3 | **Status:** accepted | ||
| 4 | |||
| 5 | ## Context | ||
| 6 | |||
| 7 | ADR 0002 made sessions append-only and forbade rewriting history, because the | ||
| 8 | provider's prompt cache depends on a byte-identical prefix and any edit to | ||
| 9 | earlier messages invalidates it. The cost of that decision was a hard context | ||
| 10 | ceiling: a long conversation could not be shortened, only abandoned. | ||
| 11 | |||
| 12 | The default model accepts ~500k tokens, so the ceiling is rarely reached, but | ||
| 13 | when it is, "start a new session" loses everything in the conversation. | ||
| 14 | |||
| 15 | ## Decision | ||
| 16 | |||
| 17 | `/compact` is an explicit, user-initiated command that: | ||
| 18 | |||
| 19 | 1. asks the model for a one-paragraph summary of the conversation (a single | ||
| 20 | non-streaming completion), | ||
| 21 | 2. rewrites the session file to `header + system + one user message` carrying | ||
| 22 | that summary, under the same session id, | ||
| 23 | 3. continues in place. | ||
| 24 | |||
| 25 | It is the **only** code path that truncates a transcript, and it deliberately | ||
| 26 | breaks the prompt cache — an accepted cost, because the user asked for it and it | ||
| 27 | happens once, not on every step. | ||
| 28 | |||
| 29 | ## Consequences | ||
| 30 | |||
| 31 | - A long session can now be continued instead of abandoned, at the price of the | ||
| 32 | detail the summary omits. | ||
| 33 | - The cache is cold after `/compact`; the next turn re-bills the whole prefix. | ||
| 34 | - There is no rollback: the pre-compact messages are gone. The summary is the | ||
| 35 | only record, so a bad summary loses real context. | ||
| 36 | - ADR 0002 still governs everything else: no summarisation, truncation, or | ||
| 37 | sliding window happens automatically. | ||
