Source-linked AI summary

HasMem: Hard-Origin Adaptively Softened Memory for Long-Term LLM Agents

Zihong He, Junxiao Shen, Chen Liang, Hai-Ning Liang

arXiv:2609.30797v1cs.AI

TL;DR

Resizing continuous memory changes the input to a frozen LLM, coupling capacity allocation, re-encoding, and readout. HasMem starts from frozen token embeddings and adapts widths, re-encodes resized entries, and adjusts readout; it improves F1 on both evaluations while EM is lower than the hard reference.

  • Problem

    Resizing persistent continuous memory changes the frozen LLM’s input, coupling memory-capacity allocation with re-encoding and readout.

    Source: §1 · p. 1
  • Method

    HasMem starts from frozen token embeddings, uses a Controller and Writer to adjust and re-encode record widths, and adds Reader and Global readout adaptation.

    Source: §1 · p. 1
  • Results

    F1 improves on both evaluations while EM is lower than the hard reference; MSC-derived lexical F1 rises by 4.4 percentage points at 93.6% of its framed positions, and LongMemEval-S local lexical F1 improves by 5.6 points.

    Source: §1 · p. 1, §6 · p. 8
  • Takeaways & Limitations

    Width-allocation and readout benefits depend on budget and deployment conditions, supporting further study of continual softening.

    Source: §6 · p. 8

    The MSC-derived evaluation uses development-split sentence reconstruction with at most 7 records per owner; longer histories and independent testing are needed to assess accumulation, interference, scaling, and generalization.

    Source: §5 · p. 8

Abstract

from arXiv · show

Text-based memory and context compression support reuse of past interactions. Resizing continuous memory changes the input to a frozen LLM, coupling capacity allocation with readout. We propose Hard-Origin Adaptively Softened Memory (HasMem). Frozen hard-prompt embeddings provide a verifiable initial state. A controller adjusts memory widths, a Writer re-encodes resized entries, and Reader and Global provide readout adaptation and cross-turn state. On all $535$ questions in a reconstruction probe derived from the Multi-Session Chat (MSC) development split, the main configuration achieves lexical F1 of $95.3$ ($+4.4$ percentage points) at $93.6\%$ of the hard reference's framed memory positions. With approximately matched per-question target body budgets, six configurations at mean per-entry retention around $0.83$--$0.91$ exceed rule-based re-encoding by $8.0$--$23.6$ exact-match (EM) percentage points. With fixed model parameters and rule target width ratio $0.75$, Global's EM gain passes a user-level exact paired test with Bonferroni correction over eight comparisons. On all $500$ LongMemEval-S questions, local lexical F1 rises from the hard reference's $3.4$ to $8.9$, and answer negative log-likelihood (NLL) falls from $12.257$ to $5.274$. F1 gains accompany lower EM on both evaluations.

1 Introduction

Resizing continuous memory changes a frozen LLM’s input, coupling capacity allocation, re-encoding, and readout. HasMem starts from frozen token embeddings and combines width adaptation with learned re-encoding and readout; results show lexical F1 gains alongside lower EM.

1 Introduction

  • HasMem initializes records from frozen token embeddings; a Controller selects KEEP, SHRINK, or EXPAND, and a Writer re-encodes resized entries.The Soft Bank is outside the frozen LLM parameters, and KEEP preserves the slot.Source: §1 · p. 1
  • On MSC-derived, the main configuration improves lexical F1 by 4.4 percentage points at 93.6% of the hard reference’s framed positions; on LongMemEval-S, local lexical F1 rises 5.6 points and answer NLL falls 6.983.Source: §1 · p. 1
  • At approximately matched per-question target body budgets, six configurations with mean per-entry retention around 0.83–0.91 exceed rule-based re-encoding by 8.0–23.6 EM percentage points.The comparison shares trained parameters and the re-encoder.Source: §1 · p. 1
  • Reader adds low-rank readout adaptation, while recurrent Global state conditions both re-encoding and readout.A causal gate preserves hard-prompt equivalence for all-KEEP trajectories under identical retrieval and input construction.Source: §1 · p. 1
  • With model parameters and per-question positions fixed, Global readout at rule target ρ = 0.75 raises question-weighted MSC-derived EM by 2.24 percentage points, passing a Bonferroni-adjusted user-level exact paired test.The adjusted p-value is 0.0146 over eight comparisons.Source: §1 · p. 2

2 Related Work

Related work spans learned memory management, persistent continuous-context methods, and token or memory pruning; HasMem’s stated distinction is continual adaptation of continuous record widths from hard-prompt embeddings.

2.1 Learning-Based Memory Management

  • Memory-management approaches include retrieval and note systems, importance-based forgetting, learned text-memory operations, and HasMem’s continuous per-record width control.The passage also describes graph retrieval, context paging, and one-shot episodic-memory edits.Source: §2.1 · p. 2

2.2 Persistent Memory in Continuous Contexts

  • Persistent continuous-context methods include learned prompts and prefixes, recurrent states, shared pools, and budgeted compression; HasMem starts from hard-prompt embeddings and continually revises record width.The cited passage contrasts this with FlexComp’s predicted write-time budgets from context.Source: §2.2 · p. 2

2.3 Token and Memory Pruning

  • Token and memory pruning methods rank or prune text, delete or merge memories, or evict KV entries; HasMem allocates persistent record widths before questions arrive.The passage also notes learned KV append/merge operations and recursive state compression.Source: §2.3 · p. 2

3 Method

HasMem stores records as variable-width continuous slots outside the frozen backbone, with a Controller and Writer for width changes and Reader and Global modules for readout adaptation. Its inference and training procedures preserve a hard-prompt reference while learning memory changes from question-answering supervision.

3.1 Architecture

  • HasMem maintains a variable-width Soft Bank and cross-turn Global state outside the frozen backbone, with records stored in arrival order.Each record has a body slot whose width can change while its role-framing tokens remain fixed.Source: §3.1 · p. 2

3.1.1 Controller

  • The Controller selects KEEP, SHRINK, or EXPAND for a scheduled entry, using slot features, the latest record, and metadata to predict relative costs.Widths remain bounded by each record’s original length and a minimum width for sufficiently long records.Source: §3.1.1 · pp. 2–3

3.1.2 Soft Bank and Writer

  • The Writer re-encodes resized slots by pooling for shrinkage or interpolation for expansion, then adds a Global-conditioned residual.KEEP preserves the slot, and EXPAND cannot exceed the record’s original length.Source: §3.1.2 · pp. 3–4

3.1.3 Reader

  • Reader uses QA-supervised low-rank adaptation of selected attention output projections to read softened slots, with added parameters fixed at inference.The Reader’s low-rank parameters are zero-initialized.Source: §3.1.3 · p. 4

3.1.4 Global

  • Global updates recurrently in record order and conditions both Writer re-encoding and Reader’s generated readout projection.Its recurrent update and hypernetwork parameters are zero-initialized; maintenance leaves the state unchanged.Source: §3.1.4 · p. 4

3.2 Inference Procedure

  • New records begin as frozen token embeddings at their original body width, and an all-KEEP trajectory preserves hard-prompt equivalence under identical input construction and inference settings.Softening visits at most one entry per new-record step; retrieval selects up to k entries using slot-derived keys.Source: §3.2 · p. 4

3.3 Training

  • Training uses owner-level QA supervision with the backbone frozen, warm-up across all actions, then policy training for the Controller, shared encoder, and Writer output layer.Policy search favors SHRINK sequences that reduce cumulative positions while meeting per-question NLL tolerance against matched KEEP.Source: §3.3 · p. 5

4 Experiments

Experiments compare HasMem with hard-prompt references on an MSC-derived reconstruction probe and LongMemEval-S, then test configuration choices, re-encoding strategies, and model components. Lexical F1 improves, but EM is lower than the hard reference on both evaluations.

4.1 Experimental Setup

  • The evaluation uses all 535 MSC-derived development questions and all 500 LongMemEval-S questions, with the main run using frozen Qwen2.5-7B at k = 8.The MSC probe filters to 268 owners and 535 questions; k = 8 retrieves all records. Scores use specified lexical, EM, and NLL metrics, with paired inference and seed variation also examined.Source: §4.1 · pp. 5–6

4.2.1 Comparison with Hard-Prompt References

  • MSC-derived F1 rises 4.4 percentage points at 93.6% of hard-reference framed positions, while LongMemEval-S F1/Cover rise 5.6/3.6 points and NLL falls 6.983; EM declines on both.Source: Table 1 · p. 6, §4.2.1 · p. 6, Table 2 · p. 6
  • Across eleven configurations, NLL improves in eight, local judge scores improve in four, and MSC-derived EM decreases at every retrieval width.Runs vary in backbone, retrieval width, and update count.Source: §4.2.1 · p. 6

4.2.2 Configuration and Strategy Comparisons

  • Across five Qwen2.5 backbones, each backbone’s highest EM occurs at λband ≥3.0 and relative budgets of 0.924–1.000; EM is nonmonotonic for four.The 14B model at λband = 3.0 selects KEEP throughout and matches the hard reference.Source: §4.2.2 · p. 7, Table 3 · p. 7
  • Across eight seeds, mean F1/EM is 94.2/82.6, with EM ranging from 77.4 to 88.1; all four training recipes raise LongMemEval-S F1 and lower its NLL and MSC-derived EM versus the hard reference.Objectives, input distributions, and realized budgets vary jointly.Source: §4.2.2 · p. 7
  • At approximately matched target budgets, six learned configurations at mean retention 0.83–0.91 exceed rule-based re-encoding by 8.0–23.6 EM points.Learned re-encoding occurs during writing and maintenance, whereas rule-based re-encoding follows the completed history.Source: §4.2.2 · p. 7, Table 4 · p. 7

4.2.3 Ablation and Mechanism Analysis

  • Removing forced softening or the target band lowers F1, EM, and realized budgets, while removing Writer hinge yields all KEEP and matches the hard reference.The main MSC-derived trajectory has 1470 KEEP, 516 SHRINK, and no EXPAND actions.Source: §4.2.3 · p. 7, Table 5 · p. 8
  • With model parameters and per-question positions fixed, Global at rule target ρ = 0.75 gains 2.24 EM points and passes correction; Reader gains 1.87 points but does not.Disabling either pathway increases NLL throughout, while EM gains depend on allocation and deployment.Source: §4.2.3 · p. 8

5 Limitations

The evaluations have bounded scope and do not isolate every source of performance or cost differences. Several deployment and inference claims therefore remain conditional on the tested settings.

5 Limitations

  • MSC-derived evaluation uses development-split sentence reconstruction with at most seven records per owner; longer histories and independent testing remain needed to assess accumulation, interference, scaling, and generalization.Source: §5 · p. 8
  • Discrete position residuals and maintenance timing limit attribution of Table 4 differences to width allocation alone.Source: §5 · p. 8
  • Fixed-model readout interventions estimate answering-stage pathway effects, not retrained module effects, configuration–module interactions, or EXPAND’s independent contribution.Source: §5 · p. 8
  • Owner-clustered intervals capture evaluation-sample variability and assume independent owners representative of the target population.Source: §5 · p. 8
  • The local LongMemEval-S judge requires validation against the reference evaluation configuration.Source: §5 · p. 8
  • Realized budgets and integration protocols limit equal-resource comparisons with external systems.Source: §5 · p. 8

6 Conclusion

HasMem adapts per-record memory widths, re-encoding, and readout around a frozen LLM, with hard-prompt equivalence for all-KEEP trajectories. Its reported gains coexist with lower EM, while supplementary reconstruction comparisons reflect task-specific scoring and integration choices.

6 Conclusion

  • At 93.6% of the hard reference’s framed positions, the main configuration improves MSC-derived F1 by 4.4 percentage points; LongMemEval-S F1 improves by 5.6 points and NLL falls by 6.983, while EM is lower.Source: §6 · p. 8
  • HasMem learns per-record width adjustment, re-encoding, and readout around a frozen LLM, starting from verifiable token-aligned embeddings.Source: §6 · p. 8

Generative Artificial Intelligence (AI) Usage Disclosure

  • The authors state that AI tools assisted with ideation, experimental refinement, implementation, analysis, literature work, and drafting, while the authors take responsibility for final research judgments and content.Source: Generative Artificial Intelligence… · p. 8

A.1 Answering and Paraphrasing Sensitivity on MSC-derived

  • The MSC-derived probe converts profile and dialogue values into tagged records and tests reconstruction jointly across memory construction, retrieval, and answer generation.Source: §A.1 · p. 12
  • Verbatim-text references achieve higher F1 and EM than the evaluated external memory adaptations, a comparison tied to sentence reconstruction rather than general semantic QA.Source: §A.1 · p. 12
  • Mem0 and LLMLingua-2 score zero lexical EM on this field-based probe, but the comparisons do not isolate why; the local Memory-R1 adaptation lacks an RL-trained configuration.Source: §A.1 · p. 12

A.2 Complete Supplementary Results on LongMemEval-S

Supplementary LongMemEval-S comparisons are descriptive under their respective protocols, and complete question-isolated results are unavailable for two adaptations. On MSC-derived reconstruction, both external compressors score below their paired hard references.

A.2 Complete Supplementary Results on LongMemEval-S

  • Complete results with independent state for each LongMemEval-S question are unavailable for Mem0 and Memory-R1 because their runs share state across questions.Source: §A.2 · p. 12
  • LLMLingua-2 scores F1 9.23 versus HasMem’s 8.94 under their respective deployment protocols; it has higher Cover and lower Brief, so the comparison is descriptive rather than equal-protocol.Source: §A.2 · p. 12

A.3 Sentence Reconstruction with HasMem and External Compressors

  • Both external compressors score below their paired hard references on verbatim reconstruction; LLMLingua-2 produces no exact matches, while ICAE uses 1.48× and 7.13× the hard reference’s positions.Source: Table A3 · p. 13, §A.3 · p. 13
  • The compressor comparisons use different integration protocols: LLMLingua-2 compresses the whole context in event-arrival order, while its reference orders events by question similarity.Source: §A.3 · p. 13

B Target-Band Penalty Sweep

The target-band sweep shows that the relationship between penalty strength, realized budget, and EM varies across backbones. Some configurations improve over their hard references, while one matches its hard reference exactly under an all-KEEP trajectory.

B Target-Band Penalty Sweep

C Cross-Seed Variation in Training and Checkpoint Selection

Eight-seed evaluation measures variation under a shared training and checkpoint-selection procedure. The hard reference provides a common comparison, while one reported seed selects an all-KEEP trajectory matching that reference.

C Cross-Seed Variation in Training and Checkpoint Selection

D Paired Sensitivity Analysis of Budget Residuals

The section reports action-policy comparisons, training-setting variants, and sensitivity to position-budget differences. Comparisons across allocation strategies are qualified by the fact that realized trajectories and budgets can differ.

D Paired Sensitivity Analysis of Budget Residuals

  • For the original Table 4 configuration, the rule-based trajectory uses fewer body positions on 299 questions, averaging 0.94 fewer across 535 questions and at most five fewer per question.Equal-position subsets preserve existing predictions and maintenance trajectories, but change the estimand because subsets depend on deployment outcomes.Source: D Paired Sensitivity Analysis of… · pp. 14–15, Table D1 · p. 15

E.1 Training Settings for Backbone and Retrieval-Width Configurations

  • The backbone and retrieval-width configurations use the MSC-derived training set and the same wall-clock budget; Table 1 covers Qwen2.5-7B with k = 2, 6, 8, and 12.Table 2 reports configurations on LongMemEval-S 500.Source: §E.1 · p. 15, Table E1 · p. 15

E.2 Seed and Hyperparameter Configurations

  • The final-target-frequency 0.32 group has mean EM 88.4, with three of four runs matching or exceeding the hard reference at relative budgets of 0.949–0.976.The additional-hard-anchoring group has mean EM 82.9, below the hard reference’s 88.1; stronger-band outcomes vary by backbone and retrieval width.Source: §E.2 · pp. 15–16, Table E2 · p. 16

E.3 Action-Policy Comparisons

  • HasMem’s EM is 34.0 and 61.4 percentage points higher than random-action and fixed-action conditions, respectively.These differences jointly reflect action decisions, final widths, and state trajectories.Source: §E.3 · p. 16, Table E3 · p. 16
  • The random-action condition shares trained parameters and Writer with HasMem, while the all-KEEP no-shrink path shares the hard reference’s implementation branch.The all-KEEP path’s results therefore follow from the stated equivalence.Source: §E.3 · p. 16, Table E3 · p. 16

E.4 Common-Deployment Evaluation of Training Recipes

Under common deployment, all four softening configurations trade lower MSC-derived EM for higher LongMemEval-S lexical F1 and lower answer NLL than the hard reference. The section also reports retraining ablations and training-supervision details.

E.4 Common-Deployment Evaluation of Training Recipes

  • All four softening configurations have lower MSC-derived EM, higher LongMemEval-S lexical F1, and lower LongMemEval-S answer NLL than the hard reference.The Gaussian-input-trained model experiences input-distribution shift when deployed from hard embeddings; the two rule-trained models use more memory positions than the full-curriculum model.Source: §E.4 · pp. 16–17, Table E4 · p. 17
  • The fixed-ratio rule-trained model never outputs UNKNOWN on the 535 MSC-derived questions and has question-weighted F1/EM of 98.5/78.3.All four recipes use their final checkpoint after 5465 updates, including 5081 policy updates.Source: §E.4 · pp. 16–17

E.5 Retraining Ablations

  • On LongMemEval-S, disabling Soft Bank, the Global readout increment, and Reader yields lexical F1 of 2.8/2.7, 5.2/4.4, and 7.3/7.2, respectively, across the two listed seeds.The full fixed-update model achieves 9.8; completed training updates differ across these groups.Source: §E.5 · p. 17

F Training Objectives and Supervision

  • Policy supervision selects the first departure from KEEP in the lowest-scoring qualifying SHRINK branch, using training QA, position savings, and an NLL tolerance; otherwise weak labels or KEEP are used.The band penalty discourages deviations from the prescribed non-KEEP prediction frequency, while forced labels supervise rare non-KEEP actions.Source: F Training Objectives and Supervision · p. 18

G.1 Default Configuration

  • Embeddings and logits satisfy the listed hard-equivalence tolerance at initialization and on trained all-KEEP trajectories.Table G1 gives defaults unless an experiment specifies a variant.Source: §G.1 · p. 18, Table G1 · p. 19

G.2 Data, Scoring, and Statistical Procedures

The appendix specifies the MSC-derived data and scoring procedures and reports fixed-model readout ablations. The ablation comparisons hold model parameters and, within conditions, memory positions constant.

G.2 Data, Scoring, and Statistical Procedures

  • The MSC-derived probe contains all 535 questions from 268 retained owners, after filtering records and histories and selecting first and last retained tags as targets.Question weighting gives each correct answer approximately 0.19 EM percentage points; under owner weighting its contribution depends on the owner’s question count.Source: §G.2 · p. 19
  • EM uses exact normalized-string matches, F1 measures bag-of-words overlap, and answer NLL averages gold-token negative log probabilities under teacher forcing.Normalization lowercases, removes punctuation and articles, and collapses whitespace.Source: §G.2 · pp. 19–20
  • LongMemEval-S Cover applies question-type-specific local rules, while Brief additionally requires a covered answer within a length limit.The local Qwen judge uses the official yes/no prompts; at accuracy near 0.11, a 500-question estimate has binomial standard error of approximately 1.4 percentage points.Source: §G.2 · p. 20
  • The exact paired test assumes independent owners and invariance under swapping each owner’s paired outcomes; significance uses Bonferroni-adjusted p < 0.05.The eight rule-width/pathway comparisons form one family, while two learned-trajectory comparisons form another.Source: §G.2 · p. 20

G.3 Complete Fixed-Model Readout Ablations

  • Under learned allocation, Global’s pointwise bootstrap interval is [0.19, 2.24], but its multiplicity-adjusted exact-test p is 0.1406.The interval is unadjusted for multiple comparisons; readout interventions retain state updates and Writer conditioning while sharing model parameters and per-question budgets.Source: §G.3 · p. 20, Table G3 · p. 20
Loading 2609.30797v1…