Speculative Interaction Agents: Building Real-Time Agents with Asynchronous I/O and Speculative Tool Calling

agent 2605.13360
speculative-executiontool-callingreal-time-agentasync-iovoice-agentedge-inference

§1 TL;DR #

借鉴硬件投机执行思想,将 agent 的推理-行动循环与用户输入流、工具执行流解耦(Asynchronous I/O),并允许在信息不完整时投机发起工具调用、事后修正(Speculative Tool Calling),配合 clock-based SFT 训练将 3B 边缘模型的端到端延迟降低 1.6–2.2×,同时保持接近非流式基线的准确率。

§2 Q1 / Q2 / Q3 #

Q1 痛点 #

实时 voice agent 需要 <1s 响应延迟,但标准 agentic workflow 中模型必须:(1) 等待用户完整输入后才开始推理;(2) 每次 tool call 后阻塞等待返回结果才能继续。两者叠加导致多步工具调用场景下延迟达数秒,无法满足实时交互体验。

Q2 方法 #

Asynchronous I/O: 将 agent 的 think-act 循环与用户输入流、环境响应流解耦。用户输入以 流式注入,工具结果以 异步回写,模型可在等待期间持续推理和发起新动作。

Speculative Tool Calling: 在信息不完整时投机发起 tool call,通过 DAG 依赖追踪管理 in-flight 调用。工具按副作用分为 safe(只读,可投机执行)和 unsafe(写操作,缓存直到 commit point)。模型可通过相同 ID 修改或 取消已发起的调用。Commit point 在收到 final query update 且模型不再编辑时触发——直接类比 MIPS R10000 的 store buffer commit 机制。

核心技术壁垒: Safe/unsafe 分类 + DAG 依赖追踪 + commit-point 语义的组合设计。这是本文最难复现的 insight:必须同时正确处理投机执行、依赖传播取消、不可逆操作的原子提交,且不引入正确性回归。该设计从硬件投机执行(Yeager, 2002)迁移到 agent 工具调用领域,是一个非显然的跨域类比。

Q3 结果 #

§3 架构 / 方法图 #

Figure 1: Speculative Interaction Agent workflow vs standard agentic workflow

Paper Figure 1: 标准 agentic workflow(上)必须串行等待完整用户输入和每次工具返回;Speculative Interaction Agent(下)将推理与 I/O 重叠,大幅降低 time-to-first-token。

该图直观展示了延迟优化的核心机制:agent 不再阻塞于用户输入完成或工具执行返回,而是在等待期间持续产生推理和新的工具调用。

Figure 3: System architecture — core agent loop + task manager

Paper Figure 3: 系统实现的两层架构。上层为 core agent loop(event-driven,接收流式用户输入和工具响应,发起工具调用);下层为 task execution manager(管理 in-flight 调用的 DAG 依赖、safe/unsafe 分类、并行执行)。

架构解耦使得 agent 推理逻辑与工具执行管理独立演进。Core agent loop 基于 vLLM 的 interruptible streaming 实现,收到新事件时中断当前生成、注入新 context 后继续。Task manager 借鉴 LLMCompiler 的 DAG 执行但增加了动态修改/移除、投机保持和 commit-point 逻辑。

Figure 4: Clock-based training infrastructure

Paper Figure 4: 训练基础设施。Central update queue 按 token 计数(clock)缓冲事件,到达时机时中断模型生成并注入新信息,模拟推理时的异步交互行为。

Clock-based 训练将 wall-clock 时间映射为 token 数量(基于假设的 tokens-per-second 速率),使得离线 SFT 可以忠实模拟在线流式交互行为,无需真实实时系统支持。

stateDiagram-v2 [*] --> Reasoning Reasoning --> ToolCall: enough info for action Reasoning --> Pause: no info, has outstanding calls Reasoning --> Answer: final query received + all tools done ToolCall --> TaskManager: emit to DAG TaskManager --> SafeExec: tool is read-only TaskManager --> HoldBuffer: tool is unsafe HoldBuffer --> SafeExec: commit point reached SafeExec --> ObservationReady: execution completes ObservationReady --> Reasoning: inject state "External Events" as ext { QueryUpdate --> Reasoning: inject FinalQuery --> Reasoning: inject } Reasoning --> ModifyCall: new info invalidates prior call ModifyCall --> TaskManager: re-emit with same ID Reasoning --> RemoveCall: call no longer needed RemoveCall --> TaskManager: cancel + propagate

§4 作者证明 #

无形式化作者证明 — 仅实证。

本文无数学收敛证明或理论 bound。所有声称基于实验验证。以下为关键实证 check:

#Check结果
1延迟降低单调性 vs. 基线✓ 所有 clean benchmark 配置下 SI-SFT 延迟 < baseline SFT
2准确率损失可控✓ Cloud: -0.6/-1.7pp; Edge: -1.1/-1.6pp (HotpotQA/TinyAgent)
3SI-SFT vs. normal SFT 的必要性✓ Normal SFT 用于 SI format 时准确率崩溃(33.4% vs 67.5% Qwen HotpotQA)
4Safe/unsafe 分类正确性隐含验证:state-based evaluation 通过意味着 unsafe 工具未被错误执行
5跨模型泛化✓ Qwen2.5-3B 和 Llama-3.2-3B 均有效
6失败模式识别✓ Human Instructions 暴露了 degenerative 行为,作者诚实报告

可被 bound 但未被 bound 的量: 给定 tool latency 分布和用户输入速率,最优延迟下界可通过排队论模型建立(M/G/1 with preemption),但作者未做此分析。

§5 实验与数据 #

主结果:Cloud API(Table 1) #

Table 1: OpenAI Realtime API evaluation results

Paper Table 1: 在 openai-realtime-1.5 上的评估(500 samples/dataset)。Speculative Interaction 以轻微准确率损失换取 1.3×/1.7× 延迟降低。

Cloud 模型无需微调,仅靠 in-context examples 引导行为。1.7× 在 TinyAgent(多步工具调用更多)上的加速大于 HotpotQA(仅搜索工具)的 1.3×,印证了工具调用越密集、异步重叠收益越大。

主结果:Edge 模型(Table 2) #

Table 2: Open-source edge model evaluation results

Paper Table 2: Qwen2.5-3B 和 Llama-3.2-3B 在 HotpotQA/TinyAgent 上的评估。SI-SFT 实现 2.2×/2.1×/2.0×/1.6× 加速,准确率接近非流式 SFT。

关键对照实验:

自然语音评估(Table 3) #

Table 3: Human Instructions naturalistic evaluation

Paper Table 3: 在 177 条真实语音指令上的评估。SI-SFT 准确率和延迟均劣于 baseline SFT,暴露方法对自然语音 disfluency 的脆弱性。

Human Instructions 数据集包含填充词(um, yeah)、在线纠正、意图变更等自然语音特征。SI-SFT 在此场景下产生 degenerative repeated-action 行为,导致延迟反而增加。这表明 clean benchmark 上的加速无法直接推广到 production voice agent 场景,需要更鲁棒的训练策略。

关键实验设置 #

§6 论证链 #

Step论证支撑
1实时 voice agent 需要 <1s 延迟,但标准 agent loop 因串行等待 user input + tool execution 导致多秒延迟Miller 1968 (1s threshold); 实测 baseline 4.5–7.6s (Table 1)
2将 agent reasoning 与 I/O 解耦(Async I/O)允许重叠处理,类比 CPU pipeline 的 memory-level parallelismGim et al. 2024 (async tool call); Chiang et al. 2025a (streaming input)
3投机执行 tool call 可进一步隐藏延迟,但需解决正确性:safe/unsafe 分类 + commit-point 语义类比 MIPS R10000 store buffer (Yeager 2002); DAG 依赖追踪 (Kim et al. 2024 LLMCompiler)
43B 边缘模型无法 zero-shot 理解异步格式,需 clock-based SI-SFT 训练Table 2: no-SFT 20.1%, normal-SFT 33.4%, SI-SFT 67.5%
5在 clean benchmark 上实现 1.6–2.2× 加速且准确率损失 <2ppTable 1 + Table 2
6在自然语音上方法退化,表明 training distribution 与真实分布的 gap 是当前主要限制Table 3: 延迟增加,准确率下降

§7 实现 cross-reference #

[实现未公开] — 作者未开源代码仓库。

核心技术壁垒: Safe/unsafe 工具分类 + DAG commit-point 投机执行语义。复现难点在于:(1) 正确传播取消到依赖链;(2) commit-point 的触发条件判定(final query received + no further edits);(3) 中断-注入-恢复的 generation 状态管理需要 serving framework 层支持(vLLM interruptible streaming)。

关键实现细节:

  1. Interrupt masking in training: SFT loss 不计算被中断时模型生成的最后一个 token。这避免模型学习到在任意位置提前停止的 spurious pattern,是保证训练与推理行为一致性的关键细节。
    1. Token-clock 时间转换: 将 wall-clock delay(用户说话时间、工具执行时间)统一转换为 token 计数(基于采样的 100–200 tok/s),使得离线 SFT 数据生成可以忠实模拟在线异步行为。训练和评估使用相同的转换参数确保分布一致。