OctoLong: Mid-Training On Cross-Repository Code Contexts Enhances Long-Context Modeling
On the map: LLM agents and tool use → Software engineering coding agents
Abstract (arXiv)
Context lengths of language models (LMs) have dramatically increased, driven by the demands for in-context learning, self-improvement, and long-horizon agentic workflows. However, existing long-context corpora are dominated by books, academic articles, and code repositories, which are finite and often lack long-distance dependencies. In this work, we introduce OctoLong, a context-engineering pipeline that instruments an AST parser, a language server backend, and a package manager to recursively retrieve code references, enabling the curation of dependency-rich code contexts up to millions of tokens long. We then train OctoLong-Instruct, a suite of capable long-context open LMs, derived from base models ranging in size from 600M to 14B parameters, via context-extension mid-training on a approx 50B-token mixture containing approx 6.2B tokens of OctoLong code contexts, followed by approx 10B tokens of instruction tuning. Our ablations and experimental evaluations against 18 strong long-context open-weight LMs show that supplanting just 12% of conventional context-extension corpora with OctoLong data yields substantial gains in long-range retrieval, long-term state tracking, repository-level code understanding, and downstream agentic tasks, while also enhancing API usage in regular coding scenarios.
Key facts. Cited by 2 papers in the map (data through 14 Oct 2026). Placed in Software engineering coding agents, one of 16 directions in LLM agents and tool use. Builds on 121 of its 169 references that are in the map. First posted on arXiv 5 Aug 2026.
Builds on
121 of 169 references.
Closest ancestors · 4
Same direction, newest first
- 2026BeyondSWE: Can Current Code Agent Survive Beyond Single-Repo Bug Fixing?3 Mar
- 2026ContextBench: A Benchmark for Context Retrieval in Coding Agents5 Feb
- 2026Large-Scale Terminal Agentic Trajectory Generation from Dockerized Environments1 Feb
- 2026daVinci-Dev: Agent-native Mid-training for Software Engineering26 Jan
Other references · 117
- 2020Language Models are Few-Shot Learnerscited by 32,419
- 2024The Llama 3 Herd of Modelscited by 14,715
- 2023Lost in the Middle: How Language Models Use Long Contextscited by 3,455
- 2020Longformer: The Long-Document Transformercited by 3,413
- 2023SWE-bench: Can Language Models Resolve Real-World GitHub Issues?cited by 3,373
- 2024LiveCodeBench: Holistic and Contamination Free Evaluation of Large Language Models for Codecited by 2,004
- 2024Phi-3 Technical Report: A Highly Capable Language Model Locally on Your Phonecited by 1,917
- 2024RULER: What's the Real Context Size of Your Long-Context Language Models?cited by 1,346
- 2024Transformers are SSMs: Generalized Models and Efficient Algorithms Through Structured State Space Dualitycited by 1,336
- 2024DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligencecited by 1,181
- 2024The FineWeb Datasets: Decanting the Web for the Finest Text Data at Scalecited by 1,160
- 2024Tulu 3: Pushing Frontiers in Open Language Model Post-Trainingcited by 1,053
38 more
- 2024SnapKV: LLM Knows What You are Looking for Before Generationcited by 880
- 2023Enhancing Chat Language Models by Scaling High-quality Instructional Conversationscited by 839
- 2024LongMemEval: Benchmarking Chat Assistants on Long-Term Interactive Memorycited by 707
- 2024WildChat: 1M ChatGPT Interaction Logs in the Wildcited by 629
- 2026Terminal-Bench: Benchmarking Agents on Hard, Realistic Tasks in Command Line Interfacescited by 585
- 2025Beyond the 80/20 Rule: High-Entropy Minority Tokens Drive Effective Reinforcement Learning for LLM Reasoningcited by 559
- 2018A Discourse-Aware Attention Model for Abstractive Summarization of Long Documentscited by 478
- 2023Ring Attention with Blockwise Transformers for Near-Infinite Contextcited by 457
- 2019Multi-News: a Large-Scale Multi-Document Summarization Dataset and Abstractive Hierarchical Modelcited by 431
- 2025Native Sparse Attention: Hardware-Aligned and Natively Trainable Sparse Attentioncited by 407
- 2023Understanding the Effects of RLHF on LLM Generalisation and Diversitycited by 396
- 2024LongBench v2: Towards Deeper Understanding and Reasoning on Realistic Long-context Multitaskscited by 379
- 2023RepoCoder: Repository-Level Code Completion Through Iterative Retrieval and Generationcited by 367
- 2022The Stack: 3 TB of permissively licensed source codecited by 359
- 2024SWIFT:A Scalable lightWeight Infrastructure for Fine-Tuningcited by 355
- 2024Magpie: Alignment Data Synthesis from Scratch by Prompting Aligned LLMs with Nothingcited by 346
- 2023Magicoder: Empowering Code Generation with OSS-Instructcited by 256
- 2024OpenCodeInterpreter: Integrating Code Generation with Execution and Refinementcited by 247
- 2023DeepSpeed Ulysses: System Optimizations for Enabling Training of Extreme Long Sequence Transformer Modelscited by 245
- 2023L-Eval: Instituting Standardized Evaluation for Long Context Language Modelscited by 233
- 2024BABILong: Testing the Limits of LLMs with Long Context Reasoning-in-a-Haystackcited by 215
- 2022LinkBERT: Pretraining Language Models with Document Linkscited by 211
- 2024Data Engineering for Scaling Language Models to 128K Contextcited by 186
- 2021BookSum: A Collection of Datasets for Long-form Narrative Summarizationcited by 184
- 2024Scaling Laws and Compute-Optimal Training Beyond Fixed Training Durationscited by 170
- 2025APIGen-MT: Agentic Pipeline for Multi-Turn Data Generation via Simulated Agent-Human Interplaycited by 167
- 2025Goedel-Prover-V2: Scaling Formal Theorem Proving with Scaffolded Data Synthesis and Self-Correctioncited by 154
- 2024How to Train Long-Context Language Models (Effectively)cited by 146
- 2024LongWriter: Unleashing 10,000+ Word Generation from Long Context LLMscited by 144
- 2023Continual Pre-Training of Large Language Models: How to (re)warm your model?cited by 137
- 2025OpenRubrics: Towards Scalable Synthetic Rubric Generation for Reward Modeling and LLM Alignmentcited by 132
- 2023What's In My Big Data?cited by 129
- 2024In-Context Learning with Long-Context Models: An In-Depth Explorationcited by 128
- 2025Context Length Alone Hurts LLM Performance Despite Perfect Retrievalcited by 127
- 2025NoLiMa: Long-Context Evaluation Beyond Literal Matchingcited by 126
- 2023Scaling Laws of RoPE-based Extrapolationcited by 125
- 2024MemoRAG: Boosting Long Context Processing with Global Memory-Enhanced Retrieval Augmentationcited by 119
- 2024RAGBench: Explainable Benchmark for Retrieval-Augmented Generation Systemscited by 117
50 most cited of 117 All 117 (JSON)
Built on by
Citing papers per year: 2026: 2.
2 papers.
Similar, not cited
Close in wording, no citation either way
- 2026Trained Agentic Context Management
- 2024Bootstrap Your Own Context Length
- 2026ReCUBE: Evaluating Repository-Level Context Utilization in Code Generation
- 2025Scaling Instruction-Tuned LLMs to Million-Token Contexts via Hierarchical Synthetic Data Generation
- 2024LongAlign: A Recipe for Long Context Alignment of Large Language Models
- 2024An Effective Framework to Help Large Language Models Handle Numeric-involved Long-context Tasks
- 2023LongBench: A Bilingual, Multitask Benchmark for Long Context Understanding
- 2023ToolLLM: Facilitating Large Language Models to Master 16000+ Real-world APIs