| 1 | # Chat Compaction Plugin DOX |
| 2 | |
| 3 | ## Purpose |
| 4 | |
| 5 | - Own compacting an entire chat history into a single optimized summary message. |
| 6 | - Keep compaction prompt, helper, API, and modal behavior aligned. |
| 7 | |
| 8 | ## Ownership |
| 9 | |
| 10 | - `plugin.yaml` and `default_config.yaml` own metadata and compaction defaults. |
| 11 | - `api/compact_chat.py` owns the compaction endpoint. |
| 12 | - `helpers/compactor.py` owns summary generation and history rewrite logic. |
| 13 | - `prompts/` owns compaction system and message prompts. |
| 14 | - `webui/` owns the compaction modal and store. |
| 15 | |
| 16 | ## Local Contracts |
| 17 | |
| 18 | - Preserve chat history integrity and persistence after compaction. |
| 19 | - Backup JSON and transcript artifacts must remain UTF-8 writable when chat content contains malformed Unicode such as lone surrogates. |
| 20 | - Keep generated summaries bounded by configured model and token limits. |
| 21 | - Compacted summaries must be resumable task state: preserve the latest request, authorization boundaries, decisions, evidence, modified artifacts, pending jobs and their IDs, the next executable step, blockers, and checks not run. |
| 22 | - Store the compacted summary as non-assistant history context so provider-history normalization cannot discard it as an orphaned assistant turn. |
| 23 | - Preserve loaded skill names from `skill_instructions` metadata without copying full skill bodies into compacted summaries. |
| 24 | - Preserve only secret references such as names, aliases, purposes, or storage locations; never preserve secret values. |
| 25 | - Clear the cached context window after replacing history so stale transcript content is not persisted as active resumable state; the cache rebuilds on the next model turn. |
| 26 | - After replacing local history, clear the active Responses provider continuation while preserving stored response IDs for cleanup. |
| 27 | - Do not discard original context data unless the compaction flow explicitly owns that behavior. |
| 28 | |
| 29 | ## Work Guidance |
| 30 | |
| 31 | - Coordinate prompt changes with helper behavior and UI confirmation text. |
| 32 | |
| 33 | ## Verification |
| 34 | |
| 35 | - Smoke-test compacting a chat and reloading it after persistence. |
| 36 | |
| 37 | ## Child DOX Index |
| 38 | |
| 39 | No child DOX files. |