Repository navigation
Python: [Bug]: Consolidated memory continuation lines disappear on reload #9228
Description
Activity
- addedpythonUsage: [Issues, PRs], Target: PythonUsage: [Issues, PRs], Target: PythontriageUsage: [Issues], Target: All issues that still need to be triagedUsage: [Issues], Target: All issues that still need to be triaged
on Oct 9, 2026 - addedreproducedUsage: [Issues], Target: all issues that can be reproduced by the triage workflowUsage: [Issues], Target: all issues that can be reproduced by the triage workflow
on Oct 9, 2026 🤖 Automated triage reproduction notes (agent-authored — trust but verify)
Agent analysis
Repro:
python/packages/core/agent_framework/_harness/_memory.py::MemoryTopicRecord.to_markdown/from_markdownloses continuation lines whenMemoryContextProvider._consolidate_topicaccepts a memory string containing LF or CRLF. Minimal repro: consolidate an existing topic withmemories=["Deploy staging.\nThen deploy production."], confirm{"consolidated_topics": 1}, then read it through a freshMemoryFileStore; onlyDeploy staging.is returned.- Failing test:
python/packages/core/tests/core/test_harness_memory.py::test_memory_consolidation_round_trips_multiline_memories - Files examined: python/packages/core/agent_framework/_harness/_memory.py, python/packages/core/tests/core/test_harness_memory.py, python/packages/core/pyproject.toml
- Tests run: test_memory_context_provider_uses_explicit_consolidation_client, test_memory_consolidation_round_trips_multiline_memories
- Reported version:
1.21.0 - Current version:
1.21.0
- Failing test:
- addedharness[Issues, PRs], Target: harness-level items[Issues, PRs], Target: harness-level itemsand removedtriageUsage: [Issues], Target: All issues that still need to be triagedUsage: [Issues], Target: All issues that still need to be triaged
on Oct 9, 2026 Reproduced on current main (65a12f9, core 1.21.0). The write path already normalizes:
_merge_memoryruns every memory through_normalize_memory_text, sowrite_memorynever persists a line break. The consolidation path skips that step:_consolidate_topicpasses the LLM'smemoriesstrings straight intoMemoryTopicRecord,to_markdownwrites the break verbatim as a non-bullet line, andfrom_markdownonly reads-bullets, so the continuation vanishes on the next load while the raw file still shows it.I'd like to take this. Proposed fix: normalize memories in
MemoryTopicRecord.__init__with the same_normalize_memory_textthe write path uses (keeping the current drop-empty tolerance), so single-line memories become a record invariant and the markdown round-trip is stable by construction. That covers consolidation, extraction, and any future JSON-sourced path at once, matching thewrite_memorybehavior you noted as the reference. Regression coverage: LF and CRLF consolidation memories read back intact (normalized) through a fresh store, plus a record-level markdown round-trip.This is exactly what #9240 fixes:
to_markdownwrote the line break verbatim as a non-bullet line, and the reload path only collected bullet items, so everything after the first break was dropped. The PR makes multi-line memory strings survive the round trip; verified with the same fresh-store reload scenario.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNo status
Observed Behavior
consolidate_memoriesaccepts a valid JSON response whosememoriesarray contains a string with an ordinary line break and returns{"consolidated_topics": 1}. A freshMemoryFileStorethen returns only the first line of that memory.For example, the supplied memory is
Deploy staging.\nThen deploy production., but a fresh read returns['Deploy staging.']. The continuation is still present in the raw Markdown file immediately after consolidation; it is omitted by the record parser. This report concerns that parsed-memory discrepancy, not a model-quality result or a general storage-loss claim.The same string through the public
write_memorytool retains both sentences by normalizing whitespace. A single-line consolidation result round-trips normally. The default consolidation prompt asks for strings in amemoriesarray and does not prohibit line breaks.Expected Behavior
A successful consolidation should not silently omit part of an accepted memory when the file is read again. Either preserve all of the memory text, normalize it to the existing single-line representation, or reject unsupported formatting while preserving the previous record.
Steps to Reproduce
MemoryFileStoreandMemoryContextProviderwith the deterministic offline client below.Minimal Reproduction
The client returns an actual SDK
ChatResponse; there are no private provider calls, network requests or model calls.Observed output, with the experimental warning retained:
Package Versions
agent-framework-coresource at current main2d9cc3f8ae465baf1aed3022f89b6848db4ffa7b(pyproject.tomlversion1.21.0). All 84 checked package Python files match that commit's Git blobs. The cached dependency environment reports Core1.20.0metadata; the imported executable source is the verified main source. No fresh workspace-lock installation or full core-suite claim.Python Version
Python 3.14.3.
Operating System
Windows.
Regression
Unknown.
Additional Context
The original memory harness and Markdown format belong to #5613. Its review already called for heading-marker round-trip preservation; this observation uses an ordinary continuation line and the accepted consolidation response path. #9078/#9079 concern summary text resembling metadata; #9153 and #9205/#9227 concern topic identity; #9218 concerns consolidation scheduling markers. Their existing scope and authorship are preserved.
Public provider/store/tool controls covered single lines, ordinary LF/CRLF continuations, list continuations and heading controls. A separate independent check confirms LF/CRLF omissions and normal single-line, two-item, list and Unicode controls. Matrices overlap and are not added. No product patch, live model, remote store, other operating system or performance validation.
Please confirm the desired single-line normalization or unsupported-format handling before implementation. This report does not propose a new file format or attempt to reconstruct already omitted content.
AI Assistance
AI-assisted analysis, reproduction, and writing.
Acknowledgements