cs.AIOct 18, 2026

Editing as Language: Teaching LLM Agents a Grammar for Native Context Editing

Authors: Yunlong Deng, Yan Li, Xing Hu, Yida Zhu, Sean Du, Weiyang Liu, Guangyi Chen

Organizations: The Chinese University of Hong Kong · Meituan LongCat Team · Nanyang Technological University · Mohamed bin Zayed University of Artificial Intelligence · 

Abstract

A synopsis in novels folds a story into a few lines; a function in code gathers many steps with a single execution. Context editing is native to language itself. In this paper, we propose the Native Context Editing (NCE) framework, which gives language model agents a grammar for natively editing their own context. By encoding context-editing operations in a grammar of dedicated special tokens, we teach the agents to invoke edits through the language itself. We train agents on iteratively constructed trajectory segments, with each teacher edit conditioned on the evolving context. This establishes context editing as an atomic and inherent capability of LLM agents, enabling them to dynamically modify their context as they generate responses over long-horizon reasoning and interaction. Compared with context-editing methods that learn to generate tool-use code within specific external harness environments, our approach integrates context editing as an internal mechanism of the model's native generation process, enabling better generalization across diverse real-world workflows. On four long-horizon agentic benchmarks (Terminal-Bench 2.0, SWE-bench Verified, SWE-bench Multilingual, and SWE-bench Pro), NCE improves the average task success rate over the base model by 5.6 percentage points for LongCat-Flash-Lite-Sparse and by 4.5 for Qwen3.6-35B-A3B, while reducing average token usage by 36% and 15%, respectively.

Figures & tables

Appendix figures & tables16 assets

Supplementary material from the paper’s appendix.

Appendix

Explore similar work

CardsList
  1. Agent-Editing World Model: Rethinking World Modeling for LLM Agents

    Sep 23, 2026Shuang Sun, Guoxin Chen, Fanzhe Meng +6LLM World ModelsWorld Models

  2. ACE: Pluggable Adaptive Context Elasticizer across Agents

    Jun 30, 2026Ning Liao, Zihao Long, Xiaoxing Wang +6Long-Horizon LLM AgentsLLM Context Management

  3. InComeS: Integrating Compression and Selection Mechanisms into LLMs for Efficient Model Editing

    May 28, 2025Shuaiyi Li, Zhisong Zhang, Yang Deng +6In-Context LearningModel Editing