← 返回 2026-08-27

交接税:LLM 智能体延续非原生轨迹的代价 The Handoff Tax: Continuing Non-Native Trajectories in LLM Agents

Roy Ganz, Mor Shpigel Nacson, Adi Kalyanpur, Ron Litman 📅 2026-08-25 👍 14 2026-09-01 18:30
LLM智能体 SWE-bench 实证研究 成本-质量权衡 模型切换与交接 编码智能体

编码智能体中途换模需缴交接税:升级收不回一半质量差距且常不如重启,降档反而划算

前置知识

编码智能体与智能体轨迹

编码智能体在循环中反复执行「推理→工具调用→观察」步骤来完成软件任务,全过程产生的消息序列称为轨迹(trajectory)。长程任务可能包含几十到上百次模型调用,轨迹里既有有效推理,也有模型特有的措辞、假设、工具使用习惯和死胡同。

本文研究的核心对象正是这条轨迹:当另一个模型中途接手时,它继承的是一条自己没有生成的「非原生轨迹」,理解轨迹的构成才能理解交接税从何而来。

工作树(Working Tree)

指智能体运行过程中在磁盘上持续修改的代码仓库状态(被编辑的文件),论文记作 $W_K$。与对话轨迹 $T_{1:K}$ 不同,它是持久化的文件系统状态,模型切换后依然存在,代表已落盘的实际工作成果。

本文所有交接接口都保留 $W_K$、只改变传递的轨迹信息,这是把「工作成果」与「推理痕迹」分开、隔离轨迹本身影响的关键实验设计。

SWE-bench Verified

基于 500 个真实 GitHub issue 的代码修复基准,每个任务带可执行的通过/失败测试与人工校验,并有难度标注(<15 分钟、15–60 分钟、>1 小时三档),是编码智能体评测的事实标准。

论文的主实验全部在 SWE-bench Verified 上进行,难度分桶还被用来校准切换时机,读懂实验设置和难度分析都依赖对这个基准的理解。

模型升级与降档(Escalation / Downshift)

在同一模型家族内选一对低成本低能力(LC)与高成本高能力(HC)模型。升级指 LC 卡住时中途切到 HC 救场;降档指艰难推理完成后切回 LC 省钱。Kiro、Codex、Claude Code 等产品已用 /model 命令支持这种操作。

交接方向是本文第一自变量:升级呈现有限救援+高成本溢价,降档反而是划算的中间点,两个方向表现出方向对偶性,是全文最重要的发现。

QRec 与 CSRet 归一化指标

$Q_{Rec}=100\dfrac{R_m-R_{LC}}{R_{HC}-R_{LC}}$ 衡量某策略找回多少 HC 相对 LC 的质量优势;$CS_{Ret}$ 同理(分子换成本差)衡量保住多少 LC 的成本优势。二者均以匹配子集上的单模型基线为锚点,零与一百分别对应 LC 与 HC 的水平,负值表示比只用 HC 还要贵。

论文所有结果都用这两个归一化指标报告;不理解锚点定义,就无法跨切换点、跨模型对比较数字,也读不懂负值(如 CSRet=-285% 表示比只用 HC 还贵近 3 倍差距)的含义。

LLM API 定价与提示缓存

LLM API 按 token 计费,缓存读取与写入价格不同;智能体轨迹越长,每步重复送入的输入 token 越多,缓存策略显著影响实际美元成本。供应商价格卡(含跨区域溢价)决定最终账单。

论文的成本结论(如 Claude 上 Raw 交接 $1.61 是 HC-only $0.72 的两倍多)依赖具体定价与缓存费率,作者也明示美元结论会随价格变化,复现时需注意。

研究动机

编码智能体现在会在单个任务上链式调用几十到上百次模型调用,模型选择因此既是技术决策也是经济决策:高能力模型能解决更多 issue 但贵得多,便宜模型便宜但能力弱。麻烦在于,用户在任务开始时并不知道任务实际需要多强的能力。产品层面(Kiro、Codex、Claude Code 的 /model 命令)已经支持中途切换模型——LC 挣扎时升级到 HC 救场,或硬推理完成后降档回 LC 省钱——但这种切换的成本-质量后果此前从未被系统测量。一次中途交接把模型置于不寻常的处境:它必须延续另一模型生成的长轨迹,继承自己不会生成的推理和自己不会犯的错误。HC 可能被 LC 的错误回合锚定,LC 也可能躺在 HC 的铺垫上轻松收尾、或在超出自身能力的地方继续推理时崩溃。另外,接力式延续与「推倒重启」谁更划算,也没有人回答过。

本文的目标是本文要建立第一个针对长程编码智能体「中途能力交接」的系统实证研究,回答两个问题:继承一条非原生轨迹是否、以及如何改变成本-质量权衡;交接时传递的轨迹信息如何塑造这一效应。为此作者沿三个轴做扫描:交接方向(LC→HC 升级与 HC→LC 降档)、切换时机(在难度校准的步数分布百分位上扫 7 个切换点)、交接接口(全轨迹原样传递、压缩成摘要、丢弃轨迹但保留仓库编辑)。最终产出可操作的结论:升级时该用什么接口、什么条件下升级才值得、降档是否总是划算、以及成本惩罚通过什么机制产生。

与已有工作不同的是,已有工作的焦点都是「下一个该用哪个模型」:级联(cascade)在便宜模型不够时调用更强模型,路由器在模型池上分发请求,近年扩展到多轮场景;SWE-Router 用 LC 的部分轨迹决定继续还是让 HC 重启,但根本不传递轨迹;Khraishi 等只研究对话最后一轮的方向性漂移;KC & Budathoki 把模型当作接管中断任务的继任者,而非成本画像不同的 LC-HC 替代对。本文的独特切入是把「交接接口」(什么信息跨越模型边界)从「路由」(谁下一步行动)中解耦为独立的设计变量,并固定工作树 $W_K$ 不变、只操纵轨迹传递方式,从而第一次把「非原生轨迹本身是资产还是负债」变成可测量的命题,同时用重启对照检验「继续接手」是否根本优于「放弃重来」。

核心方法

先说直觉:中途换模时,接收方拿到两样东西——磁盘上已改好的工作树 $W_K$(几乎确定有用)和前一模型的对话轨迹 $T_{1:K}$(可能有用也可能有害)。本文固定 $W_K$,系统地改变传递的轨迹信息(全给/压缩/不给),在 SWE-bench Verified 全部 500 题上用统一的 mini-swe-agent 脚手架评测两个模型家族(Claude:Haiku 4.5 为 LC、Opus 4.7 为 HC;GPT:GPT-5.6 Luna 为 LC、Sol 为 HC)、两个方向、7 个切换点和 4 种接口。由于起始模型可能在切换点之前就完成任务,公平比较要求只在「四种接口下都真正发生切换的任务交集」上评估,并用同一子集上的单模型基线归一化出 QRec/CSRet 两个指标。总规模为每家族 58 种配置,共 58,000 次智能体运行、200 万次 API 调用、360 亿 token。

核心创新是把 handoff(交接)从 routing(路由)中剥离:路由决定「谁下一步行动」,接口决定「接收方继承什么」。通过保持工作树、只变轨迹信息,作者能直接回答「非原生轨迹本身是资产还是负债」,而答案具有方向对偶性——LC 轨迹对 HC 接收者是负担(丢弃反而提质),HC 轨迹对 LC 接收者是资产(丢弃大幅掉质量)。第二个关键设计是两个重启对照:Abort + HC fresh(为 LC 到切换点为止的工作付费后从原始任务状态重启 HC)和 LC-full + HC-full(付费完整跑一遍 LC 再完整跑一遍 HC)。它们按构造达到 HC-only 的质量,却为 LC 的工作计了费,从而把「继续接手 vs 推倒重来」变成可检验命题——对 Claude 升级,答案是推倒重来更便宜也更准,Raw 交接被严格支配。

方法步骤详情

第一步,环境与模型:全部条件共用 mini-swe-agent 脚手架与 Bash 工具,输入 SWE-bench 任务、输出补丁由官方评测器打分,150 步上限。第二步,切换点校准:按难度桶(<15 分钟/15–60 分钟/>1 小时)在前缀模型终止步数分布上取百分位 $p\in\{5,10,15,25,35,45,50\}$ 为切换步 $s_b$:调用 $q<s_b$ 用前缀模型、$q=s_b$ 起用后缀模型,避免「简单任务更早完成」的分布偏移。第三步,四种接口:Raw 原样传全轨迹 $T_{1:K}$;Compactpre/Compactsuf 分别由前缀/后缀模型把轨迹压缩成续作摘要;Traj-drop 不传轨迹,只给系统提示、原任务、固定续作消息与工作树 $W_K$。第四步,评估集:取四接口都发生切换的任务交集,单模型基线在同一子集上算锚点。第五步,指标与成本:$Q_{Rec}=100(R_m-R_{LC})/(R_{HC}-R_{LC})$,$CS_{Ret}=100(C_{HC}-C_m)/(C_{HC}-C_{LC})$;成本按含缓存价格卡重建并审计对账。第六步,重启对照:Abort+HC fresh 与 LC-full+HC-full 为 LC 工作付费但丢弃轨迹与工作树,质量按构造取 HC-only。第七步,机制分解:交接后成本拆成接收方步数×每步成本。第八步,扩展:LiC(535 题、确定性分片)与 BrowseComp(200 题)只测 Raw 交接。

技术新颖性

技术新颖性主要在实验设计与度量体系而非新算法。其一,这是首个对长程智能体中途交接的系统测量(58 配置/家族、58,000 次运行、36B token),远超此前只看最终一轮漂移或继任成本的工作。其二,接口×方向×时机的因子化设计加上「匹配切换子集」交集评估,解决了切换内生于任务难度的选择偏差;切换点按难度桶分别校准百分位也是对「简单任务更早完成」这一混淆的细致处理。其三,重启对照把「继续 vs 重来」形式化为可检验命题,并给出升级 Raw 被 strictly dominated 的干净结论。其四,机制分解把两个方向的成本惩罚归因到不同通道:升级税来自更贵的接收方调用(Raw 使每个 HC 步成本为 Compactpre 的 2.2×/1.6×),Traj-drop 降档税来自更多接收方步数(1.6×/2.0×),而步数/每步成本的另一半保持不变。其五,用信息动态(规格 upfront vs 需求渐进揭示 vs 证据渐进累积)解释交接价值何时为正,把结论从编码推广到一般智能体场景。

Handoff interfaces. All strategies preserve the prefix model's edited working tree at the switch but vary the trajectory information transferred to the suffix: the full trajectory (Raw), a summary written by the prefix or suffix model (Compactpre/Compactsuf), or none (Traj-drop).
Figure 2: Handoff interfaces. All strategies preserve the prefix model's edited working tree at the switch but vary the trajectory information transferred to the suffix: the full trajectory (Raw), a summary written by the prefix or suffix model (Compactpre/Compactsuf), or none (Traj-drop).
Task-relevant information evolves differently across settings. SWE-bench provides the specification upfront, followed by rapid repository scoping; LiC reveals user requirements over turns; BrowseComp accumulates evidence through web search.
Figure 5: Task-relevant information evolves differently across settings. SWE-bench provides the specification upfront, followed by rapid repository scoping; LiC reveals user requirements over turns; BrowseComp accumulates evidence through web search.

实验结果

升级(Tab.1):Raw 只收回不到一半质量差距(QRec 47%/36%),成本约为 LC-only 的 4.0×/6.1×;Claude 上 Raw $1.61 是 HC-only($0.72)的两倍多,而 Abort+HC fresh($0.90)与 LC-full+HC-full($1.12)更便宜且同为 79.2% 通过率——Raw 升级被重启严格支配。降档相反:Raw 把 Claude 通过率从 54.6% 提到 65.6%,成本仅 $0.41→$0.51(QRec 50%、CSRet 80%);GPT QRec 79% 但 CSRet 仅 14%。接口效应呈方向对偶:升级时减少 LC 轨迹更好——Traj-drop 把 QRec 提到 64%/84%,Compactpre 把 Claude 的 CSRet 从 −285% 改善到 −11%;降档时去掉 HC 轨迹有害——Traj-drop 的 QRec 只剩 28%/53%。难度分析(Fig.3/4):易/中任务所有升级接口都比 HC-only 贵(CSRet 低至 −982%),难任务上减上下文接口变得比 HC-only 便宜且找回 65–74% 差距,Raw 未跨过这条线(难桶 N̄≈24,探索性)。机制(Fig.4/6):Raw 升级使每个交接后 HC 步成本为 Compactpre 的 2.2×/1.6× 而步数相近;Traj-drop 降档需 1.6×/2.0× 的 LC 步数而每步成本相近。LiC 上晚期需求使升级 QRec 86%、降档 31%;BrowseComp 上 GPT 升级 QRec 95.8% 但 CSRet −30%。统计(Tab.8):bootstrap 确认 Traj-drop−Raw 升级 +3.1pp(CI [1.3,5.0])/+12.2pp([9.2,15.4])、降档 −4.7pp/−5.6pp,均不含零。

Aggregate coding-agent handoffs across model pairs. Raw escalation recovers less than half of HC's quality advantage, whereas downshift offers a favorable intermediate cost–quality point. Reducing inherited LC context improves escalation, while preserving HC context improves downshift.
Table 1: Aggregate coding-agent handoffs across model pairs. Raw escalation recovers less than half of HC's quality advantage, whereas downshift offers a favorable intermediate cost–quality point. Reducing inherited LC context improves escalation, while preserving HC context improves downshift.
Late-arriving requirements favor an HC suffix. Raw-handoff results on LiC, averaged across five task families and early, middle, and late structural switch positions for Claude.
Table 2: Late-arriving requirements favor an HC suffix. Raw-handoff results on LiC, averaged across five task families and early, middle, and late structural switch positions for Claude.
Under progressive search, escalation recovers quality but not savings. GPT Raw-handoff results on BrowseComp, averaged across switch points.
Table 3: Under progressive search, escalation recovers quality but not savings. GPT Raw-handoff results on BrowseComp, averaged across switch points.
Difficulty-conditioned handoff results. Claude intersection-only results averaged uniformly over switch points p5–p50, split by SWE-bench Verified difficulty.
Table 4: Difficulty-conditioned handoff results. Claude intersection-only results averaged uniformly over switch points p5–p50, split by SWE-bench Verified difficulty.
Coding-agent escalation by switch-timing window. Columns compare model families. All averages p5–p50, Early averages {p5,p10,p15}, and Late averages {p25,p35,p45,p50}.
Table 5: Coding-agent escalation by switch-timing window. Columns compare model families. All averages p5–p50, Early averages {p5,p10,p15}, and Late averages {p25,p35,p45,p50}.
Coding-agent downshift by switch-timing window. Columns compare model families. All averages p5–p50, Early averages {p5,p10,p15}, and Late averages {p25,p35,p45,p50}.
Table 6: Coding-agent downshift by switch-timing window. Columns compare model families. All averages p5–p50, Early averages {p5,p10,p15}, and Late averages {p25,p35,p45,p50}.
Escalation (LC→HC), averaged over all switch points. Intersection-only results average p5–p50 unweighted. Raw + disclosure retains the full trajectory and appends one model-change notice at the first HC call.
Table 7: Escalation (LC→HC), averaged over all switch points. Intersection-only results average p5–p50 unweighted. Raw + disclosure retains the full trajectory and appends one model-change notice at the first HC call.
Pairwise interface pass-rate differences by model family. ∆Pass is the first strategy minus the second, in percentage points. Intervals are pointwise 95% task-clustered bootstrap confidence intervals from 10,000 resamples.
Table 8: Pairwise interface pass-rate differences by model family. ∆Pass is the first strategy minus the second, in percentage points. Intervals are pointwise 95% task-clustered bootstrap confidence intervals from 10,000 resamples.
Raw handoff by switch position in sharded, underspecified conversations, Claude pair. Early, middle, and late are structural switch positions.
Table 9: Raw handoff by switch position in sharded, underspecified conversations, Claude pair. Early, middle, and late are structural switch positions.
Raw handoff by switch position in sharded, underspecified conversations, GPT pair. Early, middle, and late are structural switch positions.
Table 10: Raw handoff by switch position in sharded, underspecified conversations, GPT pair. Early, middle, and late are structural switch positions.
Difficulty-calibrated switch steps by prefix model. Steps are agent turns, corresponding to model API calls. Each threshold is the specified percentile of the prefix model's single-model termination-step distribution within the given difficulty bucket.
Table 11: Difficulty-calibrated switch steps by prefix model. Steps are agent turns, corresponding to model API calls. Each threshold is the specified percentile of the prefix model's single-model termination-step distribution within the given difficulty bucket.
Handoff effects vary with task difficulty. For Claude, all escalation interfaces are unfavorable on easy and medium tasks, but on hard tasks reduced-context interfaces become cheaper than HC-only while recovering 65–74% of HC's quality advantage; Raw does not make this transition. In downshift, dropping the HC trajectory yields the worst cost–quality trade-off among tested interfaces in every difficulty bucket.
Figure 3: Handoff effects vary with task difficulty. For Claude, all escalation interfaces are unfavorable on easy and medium tasks, but on hard tasks reduced-context interfaces become cheaper than HC-only while recovering 65–74% of HC's quality advantage; Raw does not make this transition. In downshift, dropping the HC trajectory yields the worst cost–quality trade-off among tested interfaces in every difficulty bucket.
The handoff tax arises through different computational mechanisms. In Claude escalation, Raw makes each post-handoff HC step 2.2× costlier than Compactpre; in downshift, Traj-drop makes LC take 1.6× more steps. Full LC context inflates HC calls, whereas missing HC context forces LC rework.
Figure 4: The handoff tax arises through different computational mechanisms. In Claude escalation, Raw makes each post-handoff HC step 2.2× costlier than Compactpre; in downshift, Traj-drop makes LC take 1.6× more steps. Full LC context inflates HC calls, whereas missing HC context forces LC rework.
GPT exhibits the same handoff-cost accounting pattern as Claude. Relative to Compactpre, each post-handoff HC step under Raw costs 1.6× as much, while Traj-drop downshift takes 2.0× as many post-handoff LC steps.
Figure 6: GPT exhibits the same handoff-cost accounting pattern as Claude. Relative to Compactpre, each post-handoff HC step under Raw costs 1.6× as much, while Traj-drop downshift takes 2.0× as many post-handoff LC steps.
查看结构化数据
任务指标本文基线提升
SWE-bench Verified 升级(Claude Haiku 4.5→Opus 4.7,7 切换点平均) Pass / QRec Traj-drop:72.4%,QRec 64% Raw(默认接口):69.2%,QRec 47% +3.2pp / +17pp(丢弃 LC 轨迹、保留工作树显著提质)
SWE-bench Verified 升级(GPT-5.6 Luna→Sol) Pass / QRec Traj-drop:79.7%,QRec 84% Raw:67.5%,QRec 36% +12.2pp / +48pp(bootstrap 95% CI [9.2, 15.4])
SWE-bench Verified 升级 vs 重启(Claude) Pass / 成本 Abort + HC fresh:79.2% / $0.90 Raw handoff:69.2% / $1.61 +10pp 且省 $0.71——Raw 被 strictly dominated
SWE-bench Verified 降档(Opus 4.7→Haiku 4.5) Pass / CSRet Raw handoff:65.6%,CSRet 80% LC-only:54.6%(HC-only 75.8%,成本 $0.85) +11.0pp,成本仅 $0.51,保留 80% 的成本优势
LiC 分片对话(Claude,535 题 5 任务族) QRec / CSRet 升级:86% / 36% 降档:31% / 53% 晚期到达的需求逆转方向排序:解出完整规格任务的第一模型是后缀,利好 HC 接手
BrowseComp 渐进搜索(GPT,200 题) QRec / CSRet 升级:95.8% / −30.0% 降档:56.7% / 76.8%;Abort+fresh HC:CSRet −8.5% 升级几乎追平质量却比重启更贵;降档是良好的中间点

局限与改进

作者承认的局限:只研究了两个模型对(Haiku 4.5/Opus 4.7 与 GPT-5.6 Luna/Sol);主研究只用 SWE-bench Verified 一个基准;每任务每配置只跑一次 episode,不估计同配置重复运行的方差,靠交集子集与任务聚类 bootstrap 弥补;难任务桶匹配子集很小(每格 N̄≈24–27),难度结论标注为探索性;LiC 与 BrowseComp 只测 Raw,接口结论主要限于编码场景;切换点固定先验设定而非自适应触发;美元结论依赖供应商定价与缓存费率。我的补充观察:第一,「重启被支配」只在 Claude 成立——GPT 上 Raw($0.36)仍比 HC-only($0.47)便宜,根源是两家族 HC/LC 单任务成本比不同(约 8× vs 2×),结论对定价高度敏感;第二,压缩接口的摘要质量依赖模型总结能力,论文未分析摘要内容或失败模式;第三,mini-swe-agent 单智能体加单一 Bash 工具较简,与生产级多工具智能体的交接税可能不同;第四,未研究多次交接或来回切换的复合效应;第五,「LC 轨迹锚定 HC」「缺 HC 上下文迫使返工」是描述性解释,缺少干预实验定位因果通道。

独立分析的弱点

第一,单次采样噪声:每格只跑一个 episode,SWE-bench 通过/失败对采样敏感,几个百分点的接口差异(如 Claude 升级上 Compactpre 与 Compactsuf 的 2.2pp)可能被运行间方差淹没,应每格重复 3–5 次并报告实例级方差。第二,固定切换点:真实用户不会按预设百分位切换,缺少「何时触发升级/降档」的策略研究,可把切换触发(LC 自估置信度、测试失败信号)与接口选择联合建模成在线决策问题。第三,接口粗糙:Raw/压缩/丢弃是三个极端,选择性保留(如保留工具调用与文件编辑、丢弃失败假设)、结构化交接 schema、学习式压缩等中间地带空白。第四,成本结论定价敏感:CSRet 对价格线性,两家族 HC/LC 成本比不同导致「重启优于继续」只在 Claude 成立,应给出价格比相图与升级划算边界。第五,披露消融仅 Claude 且只有一条固定消息,未测试更强的接收侧指令(如先运行测试验证前任声明)。第六,跨家族交接(如 Haiku→Sol)未研究,方向对偶性暗示税可能更大。第七,论文未提供公开代码仓库链接(仅提随附 artifact),第三方需自行重建 58,000 次运行流水线。

未来方向

作者明确提出四个方向:研究自适应、感知进度的切换策略,联合决定何时切换与哪个模型接续;开发结构化交接,选择性保留、总结或丢弃特定轨迹成分;把交接接口纳入路由策略的一等公民,而非假设全轨迹天然前传;扩展到更多模型家族、能力差距、定价 regime、重复 rollout 与单轨迹多次交接。基于本文成果还可延伸:一是用释放的 58,000 条轨迹训练「交接感知」的压缩模型或接收方 warm-up 程序,把减税从提示工程变成学习问题;二是把 QRec/CSRet 作为目标函数做切换时机优化,例如用 LC 的自估置信度或沙盒测试信号作触发器,验证难任务上「减上下文升级变划算」的边界;三是理论化「非原生锚定」,如通过 counterfactual 重采样测量轨迹依赖度,解释为何 LC 轨迹伤 HC 而 HC 轨迹助 LC;四是研究跨家族与多轮交替交接的税累积;五是把信息动态假说推广到计算机使用、深度研究类智能体,检验「交接价值取决于交接时刻可用的任务相关状态」这一论断的普适性。

复现评估

数据与脚手架基础公开:SWE-bench Verified 500 题与 mini-swe-agent、LiC、BrowseComp 均公开,LiC 采用确定性分片协议(用户轮字节级一致),协议可复现性好。主要门槛是预算与模型版本:实验基于商业 API(Claude 经 LiteLLM、GPT-5.6 经 Bedrock OpenAI 兼容端点),总量 58,000 次运行、200 万次调用、360 亿 token;按 Table 1 单任务成本(约 $0.05–1.61/任务×配置)粗估,全量复现需数万美元级预算。论文提及随附 artifact 记录精确调用标识、价格卡条目与实现/评测器版本,成本可审计。风险点:GPT-5.6/Opus 4.7 快照可能下线或改价;缓存费率与跨区域溢价随时间变化,美元结论需固定价格卡;采样设置(Haiku 温度 0,Opus/GPT 用 provider 默认加 medium/high 推理档)引入非确定性,单 episode 结果有小幅波动。工程难度低(接口以提示替换实现),总体属「资源门槛中高、工程门槛低」:预算有限的团队可只跑 2–3 个切换点×两方向×四接口验证核心结论。