COSMIR: Chain Orchestrated Structured Memory for Iterative Reasoning over Long Context

Naman Gupta, Shreeyash Gowaikar, Arun Iyer, Kirankumar Shiragur, Ramakrishna B Bairi, Rishikesh Maurya, Ritabrata Maiti, Sankarshan Damle, Shachee Mishra Gupta · DOI

TL;DR

Reasoning over long documents is a major challenge for LLMs, as existing methods either lose information or struggle with selectivity. COSMIR introduces a novel framework that uses a structured memory and a fixed agent workflow (Extract, Infer, Refine) to improve long-context reasoning, outperforming previous methods on long-context QA benchmarks.

What Problem Does This Paper Address?

Large Language Models (LLMs) are powerful, but they struggle when faced with very long inputs like books or extensive technical documents. Current solutions have drawbacks: retrieval methods can miss crucial details, expanding context windows strains the model's ability to focus, and multi-agent systems that pass free-form summaries between agents can lose important information and amplify errors. This makes it difficult for LLMs to perform accurate reasoning over extended texts.

Methods

COSMIR tackles this by introducing a "Chain Orchestrated Structured Memory" (COSMIR) framework. Instead of agents passing unstructured summaries, COSMIR uses a structured, centralized working memory. The process involves three main agents:

  1. PLANNER: Takes the user's query and breaks it down into concrete, checkable sub-questions.
  2. WORKER: Processes text in chunks using a fixed micro-cycle:
  3. EXTRACT: Gathers relevant evidence from the current chunk and adds it to the structured memory.
  4. INFER: Derives new, grounded claims from the gathered facts and adds them to the memory.
  5. REFINE: Updates the question set, marking resolved questions and creating new ones if needed.
  6. MANAGER: Synthesizes the final answer directly from the structured memory.

This approach preserves the benefits of step-wise reasoning while using a structured memory and a defined worker procedure, leading to better information retention, aggregation, and auditability.

Datasets

COSMIR is evaluated on the long-context QA split of the HELMET benchmark, which includes:

  • InfBench-QA: Freeform questions on English novels with entity replacement (evaluated with ROUGE F1).
  • InfBench-MC: Multiple-choice questions on English novels with entity replacement (evaluated with Exact Match).
  • NarrativeQA: Freeform questions on English books and movie scripts (evaluated with ROUGE F1). A subset of NarrativeQA, NarrativeQA-256k, consisting of contexts with at least 256,000 tokens, was also used.

Key Insights and Ideas

  • Structured Memory is Key: Replacing ad-hoc message passing with a structured memory (containing questions, gathered facts, inferred facts, and the final answer) is crucial for preventing information loss and enabling better long-range aggregation.
  • Fixed Micro-Cycle for Workers: The Extract-Infer-Refine cycle provides a consistent and structured way for workers to process information, ensuring that facts are not just extracted but also reasoned upon and refined.
  • Planner for Focused Reasoning: Decomposing the user query into specific sub-questions by the PLANNER agent guides the WORKER agents more effectively, leading to more targeted and comprehensive fact extraction.
  • Auditability: The structured memory provides a transparent trace of how the answer was derived, making the reasoning process interpretable and auditable.

Key Results

COSMIR consistently outperformed its baselines, including the Chain of Agents (CoA) and a truncated context (TC) setting, across all three datasets and models tested (GPT-4.1, GPT-4.1-mini, and Qwen3-14B). The largest gains were observed on the free-form question-response benchmarks (InfBench-QA and NarrativeQA-256k). For example, on InfBench-QA, COSMIR achieved significantly higher ROUGE F1 scores compared to CoA for all models. The paper also highlights that the EXTRACT phase of the WORKER agent is a critical bottleneck, and its quality heavily influences overall performance.

Limitations and Future Work

The authors acknowledge several limitations:

  • Extraction Quality Dependency: COSMIR's performance heavily relies on the quality of fact extraction. Missed or low-quality extractions are hard to recover later.
  • Increased LLM Calls: COSMIR requires more LLM calls than simpler methods like CoA.
  • Fixed-Length Chunks and Order: The current experiments use fixed-length chunks processed in their original order.

Future work could explore:

  • Cost Reduction: Mixing models with different per-token costs to optimize overall expense.
  • Dynamic Chunking: Investigating dynamic chunking strategies and optimal chunk ordering.
  • Broader Domain Applicability: Extending COSMIR to tasks beyond QA, such as summarization or legal/medical text analysis.
  • Addressing Extraction Bottleneck: Developing more efficient methods to improve fact extraction.

Summary updated

BibTeX
@misc{gupta2025cosmir,
  author = {Naman Gupta and Shreeyash Gowaikar and Arun Iyer and Kirankumar Shiragur and Ramakrishna B Bairi and Rishikesh Maurya and Ritabrata Maiti and Sankarshan Damle and Shachee Mishra Gupta},
  title = {{COSMIR: Chain Orchestrated Structured Memory for Iterative Reasoning over Long Context}},
  year = {2025},
  eprint = {2510.04568},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2510.04568},
}
Figure