SideQuest replaces heuristic KV cache eviction with a parallel auxiliary LRM thread that semantically reasons about stale tool responses and issues structured deletion commands, achieving 56–65% peak token reduction on agentic benchmarks (FRAMES, BrowseComp) with ≤5% accuracy loss, trained on only 215 hindsight-annotated traces.
在 ReAct 框架下的 deep research / coding agent 等长任务中,每轮 tool call 的返回(网页内容、搜索结果等)持续追加到上下文,KV cache 线性增长。这带来两个瓶颈:(1) GPU 显存占用挤压 batch size,降低并发;(2) attention 计算变为 memory-bandwidth bound。
现有启发式 KV 压缩方法(H₂O、SnapKV、R-KV 等)基于累积 attention score 或 token 冗余度做静态重要性估计,设计目标是固定长文档的单轮查询场景。但 agentic 上下文中 token 重要性是非单调的——某个 tool response 在第 $t$ 轮看似无用,到第 $t+n$ 轮合成最终答案时可能重新变得关键(论文以 Cursor 0 vs Cursor 1 的"暂时无关后复活"为例说明)。启发式剪枝在此场景下不仅导致精度下降,更引发模型崩溃(non-completion rate 高达 60%+),产生不可解析的输出。
SideQuest 的核心洞察:让大语言推理模型自身判断哪些 tool response 已过期,而非依赖注意力分数等代理指标。
具体机制分三部分:
Memory management mode 触发短语开头,对当前所有 open cursor 进行语义推理,输出 {del_cursors: [ids]} 结构化删除命令。主线程当前轮结束后同步执行 eviction。核心技术壁垒:将 KV cache eviction 重新构建为与主推理任务并行的辅助推理任务,使得 (a) 管理 token 不污染主上下文窗口,(b) eviction 决策具有语义理解而非仅依赖统计代理,(c) 架构可组合——可部署在 RLM / Context Fold 等分层 agent 的子任务内部。这一 framing 需要同时解决共享 KV cache 的异步同步、触发式模式切换、以及极少样本下不破坏原有能力的微调,三者缺一不可。
| 指标 | 数值 | 条件 |
|---|---|---|
| Peak token 降幅 | 56–65% | vs uncompressed baseline, FRAMES + BrowseComp |
| KV cache reads 降幅 | 53–71% | vs uncompressed baseline |
| 精度损失 | ~2% (FRAMES), ~5% (BrowseComp) | vs uncompressed baseline |
| Non-completion rate | 近零 (≈baseline) | vs heuristic baselines 20–60%+ |
| SGLang 峰值吞吐 | 1523 tok/s (+83.9%) | vs 828 tok/s baseline, H100 单卡 |
| 峰值 KV cache 占用 | 0.450 (−53.9%) | vs 0.977 baseline (normalized) |
| 端到端运行时间 | 1489s (−36.8%) | vs 2356s baseline, FRAMES benchmark |
| 训练样本量 | 215 | LoRA fine-tuning on gpt-oss-20b |

Paper's Figure 1, verbatim (caption: "Walkthrough example of SideQuest. (a) The main thread processes the user request by performing multi-turn reasoning and tool calling. (b) At regular intervals we spawn an auxiliary thread that runs in parallel with the shared context (c) The auxiliary thread reflects on the context and lists the cursors that can be deleted. (d) We clear the messages in the context by invoking a tool, reducing the context size for future turns.").
Figure 1 展示了 SideQuest 的四阶段工作流:主线程在 ReAct 循环中交替进行推理和 tool call (a),每隔 $K$ 轮 fork 出辅助线程 (b),辅助线程对所有 open cursor 进行语义分析判断哪些可删 (c),等主线程当前轮完成后执行 KV cache 清理 (d)。关键设计点:辅助线程共享主线程的 KV cache,但其生成的管理 token 不合并回主上下文。
下面用状态图补充 Algorithm 1 的三阶段循环逻辑:
记忆模型:短期记忆 = KV cache 中的完整上下文窗口(主线程 + 辅助线程共享);无显式长期记忆或向量数据库;辅助线程输出的删除命令是唯一的"记忆管理"通道。
错误恢复:如果辅助线程未完成(主线程先结束当前轮),则不执行 eviction,下一轮重新检查。同步策略保证 eviction 不会在主线程生成中途打断。
训练管线(Algorithm 2)产生两类数据:
联合损失:$\mathcal{L} = \mathcal{L}_{\text{CE}}(\mathcal{D}_{\text{aux}}) + \lambda \mathcal{L}_{\text{distill}}(\mathcal{D}_{\text{main}})$
无形式化作者证明 — 仅实证。
论文不提供 eviction 正确性或推理保持的形式化保证。证明方式完全依赖经验评估。
符号表:
| 符号 | 含义 |
|---|---|
| $Q$ | 用户 query |
| $\mathcal{M}$ | 推理模型 (gpt-oss-20b) |
| $K$ | 辅助线程触发间隔(每 $K$ 轮) |
| $p$ | 触发短语 Memory management mode |
| $\mathcal{C}$ | 当前上下文 token 序列 |
| $\mathcal{S}_{\text{thread}}$ | 辅助线程句柄 |
| $\Delta_{\text{ids}}$ | 待 evict 的 cursor ID 集合 |
| $\ell_c$ | cursor $c$ 的 last-use turn index |
| $\lambda$ | distillation loss 权重 |
6 项经验检查:
可形式化但未做的方向:可以对 eviction 策略建模为 MDP,证明在"cursor utility 可正确估计"假设下的 regret bound;也可分析辅助线程同步延迟(≥1 轮 lag)对理论最优 eviction timing 的影响。

Paper's Figure 2, verbatim (caption: "Distribution of ReAct Iterations and token count for FRAMES and BrowseComp with gpt-oss-20b (medium effort).").
Figure 2 揭示了 agentic workload 的规模:FRAMES 任务集中在 10–20 轮 ReAct 迭代、10K–40K token,而 BrowseComp 更重尾,部分任务超过 80 轮、120K token。这解释了 BrowseComp 上 heuristic 方法崩溃更严重的原因——更长的任务意味着更多的非单调 token utility 转折点,静态启发式更容易误判。

Paper's Figure 3, verbatim (caption: "Efficiency vs. Utility Trade-off. We evaluate Accuracy against Peak Token Usage and KV cache memory reads for gpt-oss-20b with Medium and High reasoning effort, on the FRAMES and BrowseComp benchmarks. The Uncompressed Baseline establishes the upper bound for accuracy but incurs the highest memory cost. SideQuest achieves substantial memory savings—reducing peak token usage by 56-65% compared to the baseline—while providing a better accuracy compared to heuristic based methods.").
Figure 3 是论文的核心结果。八个子图(2 benchmark × 2 effort × 2 metric)中,SideQuest(绿色星形)始终位于 Pareto 前沿的左上方:相比 uncompressed baseline(黑色方块),peak token usage 降低 56–65%,同时精度仅低 2–5%。关键观察:H₂O、SnapKV、R-KV 在类似压缩率下精度大幅低于 SideQuest,尤其在 BrowseComp (High) 上,heuristic 方法精度几乎腰斩。

Paper's Figure 4, verbatim (caption: "Non-Completion Rate across benchmarks, categorized by failure type: Unparsable Responses (orange), Context Limits (green), and Turn Limits (purple). SideQuest demonstrates superior reliability, matching the near-zero failure rate of the uncompressed baseline, while other methods suffer from high rates of model collapse.").
Figure 4 揭示了一个比精度损失更严重的问题:heuristic eviction 在 agentic 设置下导致模型崩溃。BrowseComp (High) 上 H₂O (16K) 的 non-completion rate 超过 60%,几乎全是 Unparsable Response(橙色)。这说明关键 token 被 evict 后模型无法维持合法的 ReAct 格式输出。SideQuest 的 non-completion rate 与 uncompressed baseline 同量级,是其语义理解优势的最直接体现。

Paper's Figure 5, verbatim (caption: "Serving Performance in SGLang. We compare Sidequest against the uncompressed baseline for gpt-oss-20b (Medium Effort) on the FRAMES benchmark using a single NVIDIA H100 GPU.").
Figure 5 将 SideQuest 的 token 级收益转化为系统级指标。左图:SideQuest 在 batch size 36 时达到 1523 tok/s 峰值吞吐,而 baseline 在 batch size 24 时已因显存饱和而无法扩展(828 tok/s)。中图:归一化 KV cache 占用从 0.977 降至 0.450,释放的显存直接转化为更大 batch size。右图:端到端 benchmark 运行时间从 2356s 降至 1489s(−36.8%)。三者的因果链清晰:eviction → 显存释放 → 更大 batch → 更高吞吐 → 更短总时间。

Paper's Figure 7, verbatim (caption: "Examples of memory-management reasoning produced by SideQuest.").
Figure 7 展示三个辅助线程推理实例。模型能做出非平凡判断:例如中间的例子中,模型识别出 Cursor 0(搜索结果页)在 Cursor 1(具体电影页面,已包含发行年份)被获取后变得冗余,但保留 Cursor 2(选举结果查询)因其仍被后续推理需要。这种语义级的 stale/useful 判断是 attention score heuristic 无法做到的。
| 步骤 | 论点 | 证据 | 依赖 |
|---|---|---|---|
| 1 | Agentic workload 中 KV cache 线性增长是核心瓶颈 | Fig 2: FRAMES/BrowseComp 任务 token count 分布长尾,部分超 120K | 前提 |
| 2 | 现有 heuristic eviction 基于静态重要性估计,不适用于 token utility 非单调变化的 agentic 场景 | Fig 4: heuristic baselines non-completion rate 高达 60%+,主要为 Unparsable Response | 步骤 1 |
| 3 | LRM 自身具有判断 tool response 语义有效性的能力 | Fig 7: 辅助线程产生非平凡的 stale/useful 推理;仅 215 样本 LoRA 微调即可激活 | 步骤 2 |
| 4 | 并行辅助线程架构可隔离管理 token,避免主上下文污染和延迟增加 | Algorithm 1: 辅助线程异步执行、主线程轮次结束后同步 evict;对比 sequential 方案的两个缺点 | 步骤 3 |
| 5 | Hindsight 标注 + distillation 联合训练可用极少数据教会 eviction 而不破坏原有能力 | FRAMES 精度仅降 ~2%(Fig 3);non-completion rate 与 baseline 同量级(Fig 4) | 步骤 3, 4 |
| 6 | Token 级 eviction 收益可转化为系统级吞吐和延迟改善 | Fig 5: SGLang 吞吐 +83.9%,运行时 −36.8%,KV 占用 −53.9% | 步骤 5 |
论证链完全基于论文内部数据,因果方向:问题定义(1) → 现有方法失败(2) → 能力存在性(3) → 架构设计(4) → 训练可行性(5) → 系统收益(6)。
[实现未公开]
论文未公开代码。以下为论文描述的关键实现细节:
核心技术壁垒实现要点:
并行辅助线程需要在 serving framework 层面支持 KV cache 的共享只读 fork。论文在 SGLang 上实现了这一机制——辅助线程与主线程共享同一份 KV cache tensor,辅助线程只读不写回主上下文。这要求 serving 框架支持:(a) 同一 request 内的多分支 generation;(b) 分支级别的 KV cache 引用计数管理(eviction 操作需要原子地从所有分支的视图中移除指定 cursor 的 KV entries)。
关键实现细节:
C_aux = C + p,其中 $p$ = Memory management mode 。这个短语必须在训练时保持一致,否则模型无法可靠切换到管理模式。训练数据中通过在每条 auxiliary trace 前统一 prepend 此短语来保证一致性。del_cursors)del_cursors 不可逆(KV cache 物理清除)