QueryLink: Leveraging Query-Memory Alignment for Long-Term Reasoning in LLM Agents

Xuxian Hu, Zhu Teng, Wei Zhang, Ming He, Jianping Fan

TL;DR

This paper introduces QueryLink, a novel framework that bridges the semantic gap between implicit user queries and explicit memory content in LLM agents. By aligning queries and memories in a shared semantic space using multi-grained representations, QueryLink significantly improves long-term reasoning accuracy and retrieval performance, outperforming existing state-of-the-art methods.

What Problem Does This Paper Address?

Large Language Models (LLMs) are increasingly used to build autonomous agents capable of complex, long-term interactions. However, LLMs are inherently stateless, meaning they struggle to maintain context and recall information over extended periods. Retrieval-Augmented Generation (RAG) systems, which use external memory (often stored in vector databases), are a popular solution. The core challenge addressed here is the "semantic gap" between how users ask questions (implicit, intent-driven queries) and how information is stored in memory (explicit, narrative-based memories). This mismatch leads to retrieval failures and degraded reasoning performance, especially in multi-turn dialogues. Existing RAG approaches often focus on memory organization (like knowledge graphs) but overlook this fundamental semantic misalignment.

Methods

QueryLink tackles this problem with a three-pronged approach:

  1. Coherent Memory Chunking: Instead of fixed-size text chunks, QueryLink uses a dialogue-guided sliding window and summarization strategy. This preserves the semantic integrity and context of multi-turn dialogues, preventing fragmentation of important conversational flow.
  2. Query-Memory Alignment (QM-Align): This is the core innovation. QM-Align projects both queries and memories into a shared, symmetric semantic space. It achieves this by generating multiple granular representations for each piece of text:
  3. Raw Representation (Vraw): Captures surface-level lexical and syntactic features.
  4. Semantic & Episodic Representation (Vsem): Extracts explicit events and implicit intents from memories, and generates hypothetical events/intents from queries.
  5. Entity & Keyword Representation (Vkw): Extracts precise entities and keywords for accurate lexical matching.
  6. Unified Centroid Representation (Vcen): A geometric centroid of the above three, aiming to denoise and capture the core semantic intent.
  7. Multi-Grained Retrieval Strategy: QueryLink performs retrieval independently across all four generated semantic granularities (Vraw, Vsem, Vkw, Vcen) and aggregates the results using a union operation. This "broad in retrieval" approach ensures that relevant memories are captured, even if they don't share direct lexical overlap, by leveraging different semantic perspectives.

Datasets

The paper evaluates QueryLink on two benchmarks:

  • LoCoMo: Features 10 high-quality, long-horizon conversations (averaging 16k tokens each) with 1,986 questions covering Temporal, Causal, Multi-hop, and Summarization tasks.
  • LongMemEval: A comprehensive benchmark with 500 curated questions designed to evaluate five core long-term memory capabilities: information extraction, multi-session reasoning, temporal reasoning, knowledge updates, and abstention.

Key Insights and Ideas

  • The "Semantic Gap" is Real and Detrimental: The paper quantifies the low cosine similarity between raw queries and memories (0.445), explaining retrieval failures. QueryLink significantly improves this similarity to 0.599.
  • Symmetry is Key: The authors argue that aligning both queries and memories symmetrically is crucial, as optimizing only one side leads to a "semantic blind spot."
  • Flat Memory Can Outperform Structured Memory: QueryLink demonstrates that a well-aligned flat memory architecture can outperform complex graph-based memory systems (like Mem0 and Nemori) on benchmarks, challenging the notion that intricate topologies are always necessary.
  • Multi-Granularity Matters: Removing any single semantic granularity (raw, semantic, keyword, unified) leads to a performance decrease, highlighting the benefit of a holistic representation.
  • Coherent Chunking is Crucial: Disrupting conversational continuity (e.g., by using fixed-size chunks) significantly harms performance, especially for tasks requiring co-reference resolution.

Key Results

  • State-of-the-Art Performance: QueryLink achieves an average Judge Score of 81.75 on LoCoMo, outperforming leading baselines like Nemori (74.38) and Mem0 (66.88) by a significant margin. It shows at least a 7% improvement in reasoning accuracy.
  • Strong Temporal Reasoning: QueryLink demonstrates a significant advantage in Temporal tasks, outperforming Mem0 by over 25% in Judge Score by explicitly indexing precise timestamps.
  • Robustness on LongMemEval: QueryLink consistently achieves superior performance across diverse session types and reasoning tasks on LongMemEval.
  • Plug-and-Play Capability: QueryLink can be seamlessly integrated into existing vector-based systems like A-MEM, leading to improvements of over 6% in F1 and B1 scores without architectural redesigns.
  • Efficiency: While QM-Align involves LLM calls for generating semantic views, QueryLink maintains significantly lower overall latency and token costs compared to complex structured memory baselines. It also shows competitive performance on smaller backbone models.

Limitations and Future Work

  • Inference Overhead: The QM-Align mechanism relies on LLM calls to generate semantic views, which increases output tokens during offline indexing. The authors suggest future work could optimize this by distilling view generation into smaller, specialized encoders.
  • Heuristic Dependencies: The framework currently uses fixed heuristics for retrieval hyperparameters (k=4, c=2) and the sliding window summarization strategy. These might not be optimal for all dialogue types or scenarios with rapid context switching. Future work could explore dynamically adjusted retrieval scopes.

Summary updated

BibTeX
@inproceedings{hu2026querylink,
  author = {Xuxian Hu and Zhu Teng and Wei Zhang and Ming He and Jianping Fan},
  title = {{QueryLink: Leveraging Query-Memory Alignment for Long-Term Reasoning in LLM Agents}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2026},
  doi = {10.18653/v1/2026.findings-acl.765},
}

Loading related content...

Figure