The Turn Book
The complete guide to Turn v1.0.0: from installation to building production-grade multi-agent systems with full ecosystem integration.
Part 0 · Getting Started
Why Turn was built, how to install it, and your first program.
Why Turn
The five failure modes of every agent framework, and how Turn solves them at the language level.
Installation
Install the Turn binary, configure an inference provider, and run your first intelligent program.
Hello Turn
A step-by-step trace of your first Turn program: env, memory, context, call, and return.
Part 1 · The Language
Core syntax, types, error handling, modules, and the standard library.
Grammar
Formal syntax: statements, expressions, blocks, and type annotations.
Types and Errors
Every type in Turn: Num, Str, Bool, Struct, List, Map, Pid, Vec, Identity, and Uncertain.
Error Handling
Structured error handling with try/catch/throw and actor-level fault propagation via spawn_link.
Modules
Import local files, HTTPS URLs, API schemas, and WebAssembly binaries with use.
Standard Library
Seven pure Turn modules for networking, filesystem, JSON, time, environment, regex, and math.
Part 2 · The Runtime
The VM execution model, durable state, concurrency, and resource budgets.
Runtime Model
VM execution model, actor scheduler, suspension and resumption, and durable state.
State & Persistence
How Turn agents achieve durable state using remember/recall, struct spread, and execution suspension.
Concurrency and Actors
spawn, spawn_link, spawn_each, send, receive, and self: Erlang-style actors for agent orchestration.
Budget Guardrails
The VM gas meter that bounds every process by construction, preventing runaway agents and surprise API bills.
Part 3 · Intelligence
Typed inference, confidence routing, context management, and provider architecture.
The infer Primitive
Cognitive Type Safety: how infer generates schemas at compile time and validates LLM output.
Struct Inference
The simplest demonstration of Cognitive Type Safety: infer populates a strictly typed struct at runtime.
Probabilistic Routing
Confidence thresholds and deterministic fallbacks for stochastic inference results.
Context Window
Per-process context window management with context.append and context.system.
Memory & Recall
Persistent key-value memory across sessions and restarts using remember and recall.
Inference Providers
The Wasm sandbox architecture, official providers, and how to write your own driver.
Part 4 · Security & Ecosystem
Zero-trust authentication and integration with external APIs and services.
Part 5 · Examples
Real-world autonomous applications built natively with Turn.
Boardroom Agent
A full multi-agent boardroom simulation with live data, actor coordination, and confidence gating.
Investment Committee
Three specialist agents evaluate a live NVDA equity position using Yahoo Finance data.
Marketing Agency
SEO, Copywriter, and Creative Director agents collaborate to generate high-converting ad copy.
Algorithmic Trading Syndicate
A concurrent multi-agent quantitative hedge fund. Technical, Sentiment, and Chairman agents debate an asset and produce a trade signal.
Web Search Agent
An autonomous web search agent combining Wikipedia inference, concurrent HTTP, and stochastic context synthesis.
Persistent Agent
Shows how remember and recall survive process restarts, incrementing state across runs.
Appendix
Philosophy, internals, and tooling for contributors and the deeply curious.
Quick Reference
A cheat sheet for Turn's core primitives, syntax, built-in tools, and standard library.
Design Mandate
The philosophy, constraints, and design principles locked into the Turn language.
Implementation
Compiler pipeline, schema compiler, bytecode instruction set, and VM internals.
LSP
Language Server Protocol integration and editor support.