v1.20.8 — Conversation History Compaction v2 (ADR-086)
Conversation-history compaction v2 — hardening, observability, and user-visible truncation (ADR-086)
Rebuild of the LangGraph compaction node after the 2026-05-16 production hang where a user could no longer send any message: every turn re-triggered the summary, the LLM answered once then went silent ~93 s until the Cloudflare tunnel cut the SSE stream at 125 s with Erreur de connexion: network error. Root causes: no timeout on the LLM call, no retry, no global budget, no frontend signal, and a silent descriptive_fallback stub counted as success.
Five layers
- Resilience — per-chunk
asyncio.wait_for(35 s) +tenacityretry (3×, exponential backoff withminaligned to the multiplier) + global 120 s budget + explicit_truncation_fallbackproducing a readableSystemMessageinstead of the silent stub.should_compact()reordered so token-heavy / message-light conversations still trigger. - Consolidation — prior
compaction #Nsummaries merged instead of stacked, removed only when actually consolidated; newsingle_chunk_with_mergestrategy; content blocks serialised viajson.dumps. - SSE custom stream-mode —
compaction_start/compaction_doneemitted throughstream_mode="custom"; no-op writer fallback logged and counted (compaction_writer_unavailable_total). - Concurrent SSE keepalive —
iter_with_keepalivesingle-consumer-task design preserves ContextVar stability, pulses: heartbeatevery 15 s; removes the legacylast_heartbeat. - User-visible UX —
status="compacting"locks the input; sonner toast morphs loading → success/warning (pivot from the scroll-bound banner);ContextUsagePillin the chat header (clamped badge, real ratio in tooltip), hydrated via anaget_tuple-based checkpoint reader.
Observability & ops
- 5 new Prometheus metrics + Grafana dashboard
14-compaction.json(7 panels). - Transactional recovery script
scripts/admin/reset_user_checkpoints.sql. - Operator runbook
docs/technical/COMPACTION_v2.md.
Other
tenacity==9.1.4pinned; DeepSeek V4 family added toMODEL_CONTEXT_WINDOWS(1 M tokens).- i18n:
chat.compaction.*+chat.context_usage.*in all 6 languages. - 25 new backend tests + 25 new frontend tests; baseline sweep cleared 19 pre-existing integration-test failures (no production code touched there).
Architecture: ADR-086 · Runbook: COMPACTION_v2.md · Full diff in CHANGELOG.md.