[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"doc-detail-81785-en":3,"doc-seo-81785-105":30,"detail-sidebar-cat-0-en-105":92},{"code":4,"msg":5,"data":6},0,"success",{"doc_id":7,"user_id":8,"nickname":9,"user_avatar":10,"doc_module":4,"category_id":11,"category_name":12,"doc_title":13,"doc_description":14,"doc_content":15,"file_id":16,"file_url":17,"file_type":18,"file_size":19,"view_count":20,"is_deleted":4,"is_public":21,"is_downloadable":21,"audit_status":21,"page_count":22,"language":23,"language_code":24,"site_id":25,"html_lang":24,"table_of_contents":26,"faqs":27,"seo_title":13,"seo_description":14,"update_tm":28,"read_time":29},81785,549758252649,"Ivy","https://ap-avatar.wpscdn.com/avatar/8000253669c5317157?_k=1778319167496531819",8,"Research & Report","Self-GC Self-Governing Context for Long-Horizon LLM Agents","Long-horizon LLM agents accumulate tool results, files, plans, and user constraints that cannot be treated as disposable suffix text. Existing systems rely on run-time heuristics like chronological pruning or late self-summaries, which may hide exact evidence, locators, and editable artifacts. Self-GC treats agent history as lifecycle-governed runtime objects: it indexes turns and tool spans, uses a side-channel planner to fold/mask/prune by future dependency value, and lets a harness enforce recoverable sidecars and safe commit boundaries. Across hard and production suites, it prunes substantially with high no-impact retention and reduces daytime input tokens.","Self-GC: Self-Governing Context for Long-Horizon LLM Agents  \nXubin Hao, Hongjin Meng, Xin Yin, Jiawei Zhu, Chenpeng Cao  \nXiaohongshu  \n{haoxubin, menghongjin, yinxin1, zhujiawei1, [caochenpeng}@xiaohongshu.com](caochenpeng}@xiaohongshu.com)  \narXiv :2607 .00692v 1 [ cs .AI] 1 Jul 2026  \nAbstract  \nLong-horizon LLM agents accumulate tool results, files, plans, and user constraints that are too structured to be treated as a disposable text suffix. Current systems mostly rely onin-run heuristics such as chronological pruning and tooloutput masking, or on final self-summary near a context limit. Heuristics are cheap but blind to future dependencies; summaries preserve narrative state but often hide exact evidence, locators, and editable artifacts. We present Self-GC, where GC denotes self-governing context while deliberately echoing garbage collection: the system does not merely reclaim unused tokens, but governs the lifecycle of agent context objects. Self-GC turns user turns, tool spans, and skill state into indexed objects; asks a side-channel planner to propose fold, mask, and prune actions; and lets the harness enforce recoverable sidecars, safe commit boundaries, and cache-aware commit. On a 33-session Hard Set, Self-GC prunes 43.95% of prefix tokens while leaving 84.85% of future continuations unaffected, compared with no-impact rates of 54.55% to 69.70% for heuristic baselines. On a 332-session productionderived suite, three planner backbones reach no-impact rates of 91.27% to 94.58%, while baselines remain at 77.71% to 87.46% . In production, an online account-level split reduces daytime average input tokens by 10% to 15%, with peak reductions near 20%. These results point to context management as runtime lifecycle control over indexed, recoverable objects rather than post hoc text cleanup.  \nIntroduction  \nLarge language models (LLMs) have rapidly evolved from single-turn assistants into interactive agents that browse the web, invoke tools, edit files, and coordinate multi-step workflows (Liu et al. 2023a; Zhou et al. 2024; Guo et al. 2026) . These agents show strong promise across information seeking, coding, document production, and data analysis. Unlike single-turn prompting, however, a long-horizon agent must carry forward far more than natural-language dialogue. Its active context also accumulates execution traces such as user requests, shell outputs, browser evidence, intermediate artifacts, skill state, and local plans. As the interaction horizon grows, this active context turns into a central runtime resource that directly shapes overall cost, latency, and downstream task quality.  \nHowever, a critical systems challenge persists, because most deployed context-management mechanisms still treat  \nFigure 1: Object-level context management on a shared agent trace. Token-buffer methods drop future-critical anchors; Self-GC preserves them through fold, mask, and prune with sidecar recovery.  \nagent history as a linear token buffer. One family of methods prunes spans during the run with simple rules over message age, length, and type. Another family waits until the context nears a hard limit and then asks a model to summarize the prior interaction (Cassano and Rush 2026; Xu, Zhang, and Arunachalam 2026) . Both strategies are useful, yet they expose a sharp trade-off. Position-based heuristics cannot tell whether an old tool output holds the only URL, table value, file path, or editable body that a later step still needs. Final summaries preserve narrative state, but they often compress  \nexact evidence into prose that can no longer be addressed, audited, or restored.  \nThis work addresses the trade-off by challenging the tokenbuffer view itself. Our key observation is that long-horizon agent context is better understood as a collection of runtime objects with different lifecycle requirements. Some objects are obsolete and can be removed, some are repetitive but should still leave structural hints, and others are bulky","cbCaipI05eOynn44","https://ap.wps.com/l/cbCaipI05eOynn44","pdf",4194743,5,1,15,"English","en",105,"# Abstract\n# Introduction\n## Trade-off in token-buffer context management\n## Self-GC: object-level lifecycle governance\n## Validation and results","[{\"question\":\"What problem does Self-GC address in long-horizon LLM agents?\",\"answer\":\"Self-GC targets the mismatch between linear token-buffer context management and object-level future dependencies that determine whether old tool outputs and artifacts must remain recoverable for later steps.\"},{\"question\":\"How does Self-GC decide what to fold, mask, or prune?\",\"answer\":\"Self-GC indexes user turns, tool spans, and skill state into context objects, then uses a side-channel planner to propose fold/mask/prune actions based on reflected future value of those objects.\"},{\"question\":\"What do the reported experiments show about pruning impact and efficiency?\",\"answer\":\"On a 33-session hard set, Self-GC prunes 43.95% of prefix tokens while keeping 84.85% of future continuations unaffected, outperforming heuristic baselines. In a 332-session production-derived suite, no-impact rates reach 91.27% to 94.58%, and production account-level splitting reduces daytime average input tokens by 10% to 15%.\"}]",1784176122,38,{"code":4,"msg":31,"data":32},"ok",{"site_id":25,"language":24,"slug":33,"title":13,"keywords":34,"description":14,"schema_data":35,"social_meta":87,"head_meta":89,"extra_data":91,"updated_unix":28},"self-gc-self-governing-context-for-long-horizon-llm-agents","",{"@graph":36,"@context":86},[37,54,69],{"@type":38,"itemListElement":39},"BreadcrumbList",[40,44,48,51],{"item":41,"name":42,"@type":43,"position":21},"https://docshare.wps.com","Home","ListItem",{"item":45,"name":46,"@type":43,"position":47},"https://docshare.wps.com/document/","Document",2,{"item":49,"name":12,"@type":43,"position":50},"https://docshare.wps.com/document/research-report/",3,{"item":52,"name":13,"@type":43,"position":53},"https://docshare.wps.com/document/self-gc-self-governing-context-for-long-horizon-llm-agents/81785/",4,{"url":52,"name":13,"@type":55,"author":56,"headline":13,"publisher":58,"fileFormat":61,"inLanguage":24,"description":14,"dateModified":62,"datePublished":63,"encodingFormat":61,"isAccessibleForFree":64,"interactionStatistic":65},"DigitalDocument",{"name":9,"@type":57},"Person",{"url":41,"name":59,"@type":60},"DocShare","Organization","application/pdf","2026-07-26","2026-07-16",true,{"@type":66,"interactionType":67,"userInteractionCount":20},"InteractionCounter",{"@type":68},"ViewAction",{"@type":70,"mainEntity":71},"FAQPage",[72,78,82],{"name":73,"@type":74,"acceptedAnswer":75},"What problem does Self-GC address in long-horizon LLM agents?","Question",{"text":76,"@type":77},"Self-GC targets the mismatch between linear token-buffer context management and object-level future dependencies that determine whether old tool outputs and artifacts must remain recoverable for later steps.","Answer",{"name":79,"@type":74,"acceptedAnswer":80},"How does Self-GC decide what to fold, mask, or prune?",{"text":81,"@type":77},"Self-GC indexes user turns, tool spans, and skill state into context objects, then uses a side-channel planner to propose fold/mask/prune actions based on reflected future value of those objects.",{"name":83,"@type":74,"acceptedAnswer":84},"What do the reported experiments show about pruning impact and efficiency?",{"text":85,"@type":77},"On a 33-session hard set, Self-GC prunes 43.95% of prefix tokens while keeping 84.85% of future continuations unaffected, outperforming heuristic baselines. In a 332-session production-derived suite, no-impact rates reach 91.27% to 94.58%, and production account-level splitting reduces daytime average input tokens by 10% to 15%.","https://schema.org",{"og:url":52,"og:type":88,"og:title":13,"og:site_name":59,"og:description":14},"article",{"robots":90,"canonical":52},"index,follow",{"doc_id":7,"site_id":25},{"code":4,"msg":5,"data":93},[94,98,102,106,110,115,120,123,128,131,135],{"id":21,"doc_module":4,"doc_module_name":46,"category_name":95,"show_sort_weight":96,"slug":97},"Story & Novel",90,"story-novel",{"id":47,"doc_module":4,"doc_module_name":46,"category_name":99,"show_sort_weight":100,"slug":101},"Literature",80,"literature",{"id":53,"doc_module":4,"doc_module_name":46,"category_name":103,"show_sort_weight":104,"slug":105},"Exam",70,"exam",{"id":20,"doc_module":4,"doc_module_name":46,"category_name":107,"show_sort_weight":108,"slug":109},"Comic",60,"comic",{"id":111,"doc_module":4,"doc_module_name":46,"category_name":112,"show_sort_weight":113,"slug":114},6,"Technology",50,"technology",{"id":116,"doc_module":4,"doc_module_name":46,"category_name":117,"show_sort_weight":118,"slug":119},7,"Healthcare",40,"healthcare",{"id":11,"doc_module":4,"doc_module_name":46,"category_name":12,"show_sort_weight":121,"slug":122},30,"research-report",{"id":124,"doc_module":4,"doc_module_name":46,"category_name":125,"show_sort_weight":126,"slug":127},9,"Religion & Spirituality",20,"religion-spirituality",{"id":126,"doc_module":4,"doc_module_name":46,"category_name":129,"show_sort_weight":126,"slug":130},"World Cup","world-cup",{"id":132,"doc_module":4,"doc_module_name":46,"category_name":133,"show_sort_weight":132,"slug":134},10,"Lifestyle","lifestyle",{"id":136,"doc_module":4,"doc_module_name":46,"category_name":137,"show_sort_weight":20,"slug":138},19,"General","general"]