让大模型对话像代码版本控制一样分支,避免思路混乱。
Context Branching for LLM Conversations: A Version Control Approach to Exploratory Programming
- 用版本控制思想管理对话,支持创建分支探索不同方案。
- 复杂任务中分支对话质量更高,上下文大小减少58.1%。
- 适合需要反复试错的编程探索,尤其在概念差异大的场景。
大型语言模型(LLMs)已融入软件工程流程,但在多轮对话中表现显著下降,指令跨轮次传递时平均性能降低39%,模型易提前假设且无法修正方向(Laban et al., 2025)。这在探索性编程中尤为棘手——开发者需尝试多种路径却不愿锁定单一方向。现有方案迫使用户二选一:在污染严重的对话中继续,或重启对话丢失上下文。本文提出ContextBranch,一种将版本控制语义应用于LLM交互的对话管理系统。其提供四类核心操作:checkpoint(快照)、branch(分支)、switch(切换)、inject(注入),支持捕获对话状态、独立探索替代路径,并选择性合并见解。在30个含故意污染探索的软件工程场景中评估发现,分支对话相比线性对话显著提升响应质量,聚焦度与上下文感知能力增强。复杂任务中效果更明显,分支使上下文规模从31.0条消息降至13.0条,减少58.1%,有效剔除无关探索内容。本研究确立对话分支为AI辅助探索的核心机制,证明隔离可防止探索过程中的上下文污染。
原文摘要 · Abstract (English)
Large Language Models (LLMs) have become integral to software engineering workflows, yet their effectiveness degrades significantly in multi-turn conversations. Recent studies demonstrate an average 39% performance drop when instructions are delivered across multiple turns, with models making premature assumptions and failing to course correct (Laban et al., 2025). This degradation is particularly problematic in exploratory programming tasks where developers need to investigate alternative approaches without committing to a single path. Current solutions force users into a false dichotomy: continue in a context-polluted conversation where the LLM becomes increasingly confused, or start fresh and lose all accumulated context. We present ContextBranch, a conversation management system that applies version control semantics to LLM interactions. ContextBranch provides four core primitives--checkpoint, branch, switch, and inject--enabling users to capture conversation state, explore alternatives in isolation, and selectively merge insights. We evaluate ContextBranch through a controlled experiment with 30 software engineering scenarios featuring intentionally polluting explorations. Branched conversations achieved higher response quality compared to linear conversations, with large improvements in focus and context awareness. Benefits were concentrated in complex scenarios involving conceptually distant explorations. Branching reduced context size by 58.1% (31.0 to 13.0 messages), eliminating irrelevant exploratory content. Our work establishes conversation branching as a fundamental primitive for AI-assisted exploratory work, demonstrating that isolation prevents context pollution when exploring alternatives.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。