Deterministic Replay for AI Agent Systems
Deterministic Replay for AI Agent Systems
AI 智能体系统的确定性重放
Abstract: AI agent systems that couple large language models (LLMs) with external tools and APIs are inherently non-deterministic: LLM sampling variance, external API state, CDN infrastructure headers, and execution-environment noise collectively prevent any prior agent run from being faithfully re-executed.
摘要: 将大语言模型(LLM)与外部工具和 API 相结合的 AI 智能体系统本质上是非确定性的:LLM 的采样方差、外部 API 的状态、CDN 基础设施标头以及执行环境中的噪声,共同导致了之前的任何智能体运行过程都无法被忠实地重新执行。
Existing observability platforms capture execution logs but cannot reproduce a run in isolation. We present agrepl, a developer-first CLI framework for deterministic replay of agent executions. agrepl intercepts all external interactions at the transport layer via a man-in-the-middle (MITM) proxy, serialises them as structured execution traces, and replays them in a strictly isolated environment with zero outbound network access.
现有的可观测性平台虽然可以捕获执行日志,但无法在隔离状态下重现运行过程。我们提出了 agrepl,这是一个面向开发者的命令行(CLI)框架,用于实现智能体执行的确定性重放。agrepl 通过中间人(MITM)代理在传输层拦截所有外部交互,将其序列化为结构化的执行追踪记录,并在零出站网络访问的严格隔离环境中进行重放。
We formalise the agent execution model, define the request-key matching function K(s), and prove the determinism invariant. We introduce a noise-aware diff algorithm classifying HTTP header divergence into signal and noise tiers. Empirical evaluation across five workloads (n = 250 replay instances) demonstrates replay fidelity F = 1.0 and a median per-step latency reduction of 98.3%. agrepl is implemented in Go, ships as a single static binary, and is released under the MIT licence.
我们对智能体执行模型进行了形式化定义,定义了请求键匹配函数 K(s),并证明了确定性不变性。我们引入了一种感知噪声的差异算法,将 HTTP 标头的差异分类为“信号”和“噪声”层级。在五个工作负载(n = 250 次重放实例)上的实证评估表明,重放保真度 F = 1.0,且每步延迟的中位数降低了 98.3%。agrepl 使用 Go 语言编写,以单一静态二进制文件形式发布,并采用 MIT 许可证开源。
Keywords: AI agents, deterministic replay, LLM debugging, reproducibility, MITM proxy, execution tracing, record/replay systems.
关键词: AI 智能体,确定性重放,LLM 调试,可复现性,MITM 代理,执行追踪,记录/重放系统。