Session summary chunk merge: `concepts` duplicated across chunks, and silently emitted empty when chunks fail
Summary
Two related defects in how mem::summarize merges per-chunk results into a session summary's concepts array. Both were found while backfilling summaries across ~900 historical sessions on a self-hosted deployment.
- No dedupe on merge — each chunk contributes its own concepts and they are concatenated verbatim, so a multi-chunk session accumulates near-identical entries.
- Silent empty array on partial chunk failure — when some chunks fail, the merge can still emit a summary that looks complete but has
concepts: []. No error is surfaced and the summary passes every "is this session summarized?" check.
The second is the more damaging one, because it is invisible: the summary has a good title, a coherent narrative, and a populated keyDecisions array. Only inspecting the concepts field reveals it.
No credentials, hostnames, or request contents are included in this report.
Environment
- agentmemory
0.9.28,iiiruntime0.11.2, Docker - Local OpenAI-compatible endpoint, non-reasoning instruct model
SUMMARIZE_CHUNK_SIZE=120,SUMMARIZE_CHUNK_CONCURRENCY=2
Observed — 1. duplication
A 370-observation / 4-chunk session produced 15 concepts, of which roughly 6 were distinct. Representative near-duplicates within a single summary (lightly redacted):
"<X> File Archival Verification" vs "<X> file forensics and archival search"
"Remote shell exploration (SSH/PS)" vs "Remote Shell Execution (SSH/Bash)"
vs "PowerShell Scripting"
vs "SSH/PowerShell scripting for forensics"
These are chunk-local phrasings of the same underlying concept. Since concepts feed the consolidation tiers, the inflation propagates downstream as redundant semantic facts.
Observed — 2. silent empty concepts
Across 905 sessions, 21 summaries had an empty concepts array. The distribution is the tell — 17 of the 21 were large multi-chunk sessions (1,099 to 57,771 observations), and most of those had a fully populated keyDecisions array at the same time:
obs=2015 concepts=0 decisions=13
obs=7222 concepts=0 decisions=54
obs=15536 concepts=0 decisions=15
obs=57771 concepts=0 decisions=20
A summary with 54 decisions and 0 concepts is not a model that had nothing to say — it is a merge that lost one field.
These recover on a plain retry. Re-running POST /agentmemory/summarize on the same sessions, with no config change other than having removed the underlying chunk failures, took them from concepts=0 to populated (e.g. a 1,099-observation session went 0 concepts / 0 decisions → 7 / 6). So the content was always derivable; the merge discarded it under partial failure.
Why this is hard to detect
A caller cannot distinguish "this session genuinely had no concepts" from "the merge dropped them". Any completion check based on "does a summary object exist" — which is the natural check, and what a backfill script will use — reports these as healthy. In our case they survived an entire backfill and were only found by an explicit field-level sweep afterwards.
Suggested behavior
- Dedupe concepts during merge — case-insensitive, ideally with light normalization, so chunk-local rephrasings of one concept collapse to a single entry.
- Do not emit a summary with a silently empty required field after partial chunk failure. Either fail the summarize call so the caller can retry, or persist an explicit marker (e.g.
partial: truewithchunksFailed: N/M) so downstream consumers and backfill scripts can detect and re-run it. - Optionally, surface per-field completeness in the
/sessionspayload so an integrity sweep does not require fetching and inspecting every summary.
Related
- #1059 covers
observation.conceptsunderAUTO_COMPRESS=false. That is the observation layer; this report is about the session-summary merge, which is a separate path. - The partial-failure half of this is often triggered by provider errors opening the circuit breaker mid-session — see my comment on #1075 for that mechanism.