Skip to content

v1.20.8 — Conversation History Compaction v2 (ADR-086)

Choose a tag to compare

@jgouviergmail jgouviergmail released this 20 May 15:32

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) + tenacity retry (3×, exponential backoff with min aligned to the multiplier) + global 120 s budget + explicit _truncation_fallback producing a readable SystemMessage instead of the silent stub. should_compact() reordered so token-heavy / message-light conversations still trigger.
  • Consolidation — prior compaction #N summaries merged instead of stacked, removed only when actually consolidated; new single_chunk_with_merge strategy; content blocks serialised via json.dumps.
  • SSE custom stream-modecompaction_start / compaction_done emitted through stream_mode="custom"; no-op writer fallback logged and counted (compaction_writer_unavailable_total).
  • Concurrent SSE keepaliveiter_with_keepalive single-consumer-task design preserves ContextVar stability, pulses : heartbeat every 15 s; removes the legacy last_heartbeat.
  • User-visible UXstatus="compacting" locks the input; sonner toast morphs loading → success/warning (pivot from the scroll-bound banner); ContextUsagePill in the chat header (clamped badge, real ratio in tooltip), hydrated via an aget_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.4 pinned; DeepSeek V4 family added to MODEL_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.