Turn: A Language for Agentic Computation
Organizations: Turn Lang · Prescott Data
Abstract
We present 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. 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 confidence operator enables deterministic control flow gated on model certainty. Turn's actor-based process model, derived from Erlang, gives each agent an isolated context window, persistent memory, and mailbox. A capability-based identity system returns opaque, unforgeable handles from the VM host, ensuring raw credentials never enter agent memory. Finally, compile-time schema absorption (use schema::<protocol>) synthesizes typed API bindings from external specifications at compile time; the openapi adapter is shipped with graphql, fhir, and 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.
Figures & tables
| Type | Description |
|---|---|
| Num | IEEE 754 double |
| Str | UTF-8 string |
| Bool | true / false |
| List | Heterogeneous sequence |
| Map | String-keyed dictionary |
| Struct | Named product type |
| Module | API | Identity |
|---|---|---|
| std/net | get, post | network |
| std/fs | read, write | filesys. |
| std/json | parse, stringify | — |
| std/time | now, sleep | — |
| std/env | get, set | environ. |
| std/regex | matches, replace | — |
| Opcode | Semantics |
|---|---|
| Infer(Type) | Suspend, delegate, validate, bind |
| Confidence | Extract certainty scalar |
| Spawn / SpawnLink | Create actor process |
| SpawnEach | Scatter to micro-actors |
| Send / Receive | Async mailbox I/O |
| Remember / Recall | Persistent memory ops |
| Write | Read | B/entry | Note | |
|---|---|---|---|---|
| ns/op | ns/op | |||
| 1 K | 519 | 574 | 76.8 | baseline |
| 10 K | 1021 | 867 | — | |
| 100 K | 594 | 430 | — |
| Entries | Size | RT (µs) | Fidelity |
|---|---|---|---|
| 10 | 0.9 KB | 211 | exact |
| 500 | 19.8 KB | 1,340 | exact |
| 5 000 | 203.4 KB | 6,828 | exact |
| Property | Enforcement | Failure mode | Exp. |
|---|---|---|---|
| Struct. conf. | Schema + VM | Untyped inference | Thm. 1 |
| Primacy-rec. | P0/P1/P2 | Lost-in-Middle | E3 |
| Memory isol. | Per-proc. HashMap | Cross-agent leak | E4 |
| Durable exec. | VmState serde | State loss | E5 |
| Credential op. | Identity + host | Credential exfil. | E1 |
| Confidence | Uncertain T | Unchecked cert. | E2 |
LLM Agents
Large language model agents use language models to plan, use tools, and act across multi-step tasks and environments.
See all 705 papers