[论文解读] Turn: A Language for Agentic Computation
Turn 是一个经过编译的、基于 actor 的语言,使基于大模型的推断成为一个有类型的原语,提供概率控制,并为具代理性的软件强制安全性和持久性保障。
We present extbf{Turn}, a compiled, actor-based programming language -- statically typed for schema inference, dynamically typed at the value level -- for agentic software: programs that reason and act autonomously by delegating inference to large language models (LLMs). Existing approaches augment general-purpose languages with frameworks, encoding critical invariants (bounded context, typed inference output, credential isolation, durable state) as application-level conventions rather than language guarantees. Turn introduces five language-level constructs that address this gap. \emph{Cognitive Type Safety} makes LLM inference a typed primitive: the compiler generates a JSON Schema from a struct definition and the VM validates model output before binding. The \emph{confidence operator} enables deterministic control flow gated on model certainty. Turn's \emph{actor-based process model}, derived from Erlang, gives each agent an isolated context window, persistent memory, and mailbox. A \emph{capability-based identity system} returns opaque, unforgeable handles from the VM host, ensuring raw credentials never enter agent memory. Finally, \emph{compile-time schema absorption} ( exttt{use schema::}) synthesizes typed API bindings from external specifications at compile time; the exttt{openapi} adapter is shipped with exttt{graphql}, exttt{fhir}, and exttt{mcp} in active development. We describe the language design, type rules, schema semantics, and a Rust-based bytecode VM, and evaluate Turn against representative agentic workloads. Turn is open source at https://github.com/ekizito96/Turn.
研究动机与目标
- 在代理性软件中建立语言级不变量的必要性,以防止常见的失败模式(上下文无限制、未类型化推理、状态碎片化、无耐久执行、凭证泄漏)。
- 在语言层面引入 Turn 的五个核心语言原语,以强制实现这些不变量。
- 呈现认知类型安全、概率控制流、基于 actor 的进程、基于能力的身份认证,以及编译时模式吸收。
- 描述 Turn 的设计、语义和实现,包括其 Rust 虚拟机以及与大模型推理的端到端工作流。
提出的方法
- 定义一个带类型的推理原语 infer T { … },其中从 Turn 结构体在编译时生成一个 JSON Schema,VM 在绑定前验证 LLM 输出。
- 引入置信度操作符以提取模型确定性并在随机输出上实现确定性控制流。
- 采用类似 Erlang 的 actor 模型,具每个进程的上下文窗口、持久内存,以及通过挂起/恢复检查点实现耐久执行。
- 实现 grant identity 作为不透明、不可伪造的 Identity 能力,防止凭证泄漏进入代理记忆。
- 提供 use schema::<protocol>("url") 宏在编译时获取 API 规范,并为 API 绑定综合原生结构体和闭包。
实验结果
研究问题
- RQ1能否在语言层面实现 LLM 推理的类型安全,以保证响应的结构符合性?
- RQ2如何将概率模型确定性整合到编程语言中的确定性控制流?
- RQ3基于 actor 的、每进程上下文的架构是否能提升代理性计算中的回忆与隔离性?
- RQ4能否在不牺牲工具访问的前提下安全地管理凭证以防止泄漏?
- RQ5编译时模式吸收是否能从外部 API 规范综合出安全的原生绑定?
主要发现
| K | Write | Read | B/entry | Note | |
|---|---|---|---|---|---|
| 1 K | 519 | 574 | 76.8 | baseline | |
| 10 K | 1021 | 867 | — | $10\times$ | |
| 100 K | 594 | 430 | — | $100\times$ |
- 推理表达式 infer T { … } 在成功时会产生结构上符合 T 的值,具备编译时模式生成和运行时验证。
- 置信度操作符使基于模型确定性的分支成为可能,并定义了确定性传播的代数。
- Turn 的代理进程具有隔离的上下文和持久内存,通过链路进程实现容错监督。
- 身份能力防止原始凭证进入代理记忆,确保凭证不透明。
- 编译时模式吸收从外部规范综合出类型化的 API 绑定,使具大模型驱动的代理能够安全地使用 API。
- 实验表明在五个测试套件中共通过 105/105 测试,且对凭证不透明、置信语义、上下文优先/最新、内存隔离以及真正的耐久执行等进行逐案评估。
更好的研究,从现在开始
从论文设计到论文写作,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。