Turn: A Language for Agentic Computation
We present Turn, a compiled, actor-based programming language -- statically typed for schema inference, dynamically typed at the value level -- designed specifically for agentic software: programs that reason and act autonomously by delegating inference to large language models (LLMs).
Existing approaches augment general-purpose languages with wrapper 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 obliterate this gap.
Cognitive Type Safety makes LLM inference a typed primitive, while an actor-based process model grants each agent an isolated memory mailbox. A capability-based identity system ensures raw credentials never enter agent memory, and compile-time schema absorption synthesizes typed API bindings from external specifications (GraphQL, FHIR, MCP) at compile time.
1. The Threat of the Wrapper Abstraction
Currently, the entire ecosystem of multi-agent software is built on precarious foundations. Frameworks written in standard general-purpose languages attempt to retrofit reasoning LLMs into imperative codebases. Because traditional languages lack foundational guarantees around model stochasticity, engineers are forced to enforce context limits, validate JSON schema output, and map API constraints continuously using unreliable wrapper conventions.
When an agent's reasoning bounds are not physically enforced by the compiler and the VM, the inevitable outcome is hallucination, unverified state execution, and credential leakage. We posited that agentic computation is no longer an application-layer problem—it requires a profound shift down to the compiler grammar.
2. Cognitive Type Safety
In standard frameworks, extracting structured data from an LLM relies on raw string parsing and brittle prompting. Turn elevates LLM inference to a typed, first-class language primitive. During syntax lowering, the Turn compiler automatically synthesizes strict JSON Schemas from internal `struct` definitions.
code: string,
confidence: float
}
// The LLM boundary is strictly typed by the VM.
let diagnosis = infer<Diagnosis>(patient_symptoms);
The VM intersects the returned representation and cryptographically validates the model output before the variable is ever bound to memory. If the model strays, the VM traps the failure synchronously, allowing the engine to retry or fallback using deterministic control flow mechanisms, including the novel "confidence operator."
3. The Erlang-Derived Actor Model
Borrowing from the extreme resilience of Erlang, Turn’s execution environment implements an isolated actor model. Each individual agent is spawned as an isolated process with its own dedicated context window, persistent memory map, and isolated mailbox. Message passing is the sole mechanism of interaction.
Capability-based Identity Management
Tying into the theoretical architectures of zero-trust enterprise deployments (e.g., Nexus), Turn explicitly prohibits secret credential loading into the agent context tree. A completely opaque, unforgeable handle is returned from the VM Host upon executing an outbound API capability. Because credentials physically do not exist in the agent's memory graph, prompt-injection data exfiltration becomes a mathematical impossibility.
4. Compile-Time Schema Absorption
To execute effectively, agents require vast libraries of tools. Rather than manually writing boilerplate tool definitions to pass to OpenAI's function calling API, Turn implements compile-time schema absorption. By declaring `use schema::openapi("api.json")`, the Rust-based Turn bytecode compiler autonomously downloads the specification, flattens the endpoints, and injects strongly-typed functional stubs into the actor’s namespace.
This effectively turns any standard enterprise protocol (REST, GraphQL, FHIR, MCP) into native language vocabulary for the agent to express intent. We have released Turn as fully open source, running on a highly-optimized Rust VM, redefining what is possible inside autonomous perimeters.

