Welcome to Yoke
Primitives for building complex agentic systems.
What is Yoke?
Yoke is a TypeScript framework for building complex agentic systems — runtime, actors, event stream, toolchains, tools, agents, inference, and a pluggable store. It runs on Bun.
Yoke gives you the building blocks and the rules for how they interact, without being opinionated about what your agents actually do. It is stateful by design: the runtime keeps running, agents persist state across messages, and everything communicates over a single event stream.
The idea in one screen
import { Runtime, inferenceStack, userMessage } from "yoke";
import { openaiProvider } from "@yoke/provider-openai";
const runtime = Runtime({
inference: inferenceStack({
providers: [openaiProvider({ apiKey: process.env.OPENAI_API_KEY })],
models: [{ id: "gpt-4o", provider: "openai", model: "gpt-4o" }],
}),
})
.agent({
name: "assistant",
initialState: {},
async run(ctx, input) {
const reply = await ctx.inference.chat({
model: "gpt-4o",
messages: [userMessage(input.text)],
});
return { answer: reply.message.content };
},
})
.actor({
name: "message-forwarder",
topics: ["messages.incoming"],
act: async (env, ctx) => {
await ctx.agents.assistant("default").sendMessage(env.payload);
},
});
const server = await runtime.serve({ port: 3000 });Core concepts
- Runtime — the long-lived process hosting everything.
Runtime(...)+.agent(...)/.toolchain(...)/.actor(...)+.serve(). - Event stream — the central nervous system. One
EventBusinterface with in-memory, Redis Streams, NATS JetStream, and Nano adapters. - Actors — if-this-then-that entry points. Subscribe, filter, act.
- Agents — stateful code.
Agent({ name, model, instructions, tools, persist })wraps the agent-owned tool loop and can persist its thread + state across restarts.Promptis the single-turn variant. - Inference — provider-agnostic
Provider/Model/InferenceStackover the Vercel AI SDK (hidden behind a translator). Model calls are stateless; agents own the tool loop. - Tools & toolchains — any set of tools: MCP, CLI (
usagespecs), HTTP API, OpenAPI specs, or custom. - Plugins — provide middleware, providers, models, storage, tools, agents, actors, and events.
- Telemetry — tracing, spans, events, and logs to any number of
ObservabilityConnectors; official OpenTelemetry connector included. - Store — pluggable
StorageBackend(memory + SQLite) with stable data structures for chats, principals, personas, turns, messages, and more.
The primitives
| Primitive | What it does |
|---|---|
Runtime() | The "app" — hosts agents, actors, tools, the bus, the store |
.agent() / .toolchain() / .tool() / .event() | Registration surface |
.actor() | Entry points that subscribe → filter → act |
ctx.agents / ctx.tools / ctx.inference | Typed handles injected into actors & agents |
Agent() / Prompt() | High-level agents with tool loops and structured IO |
.serve() | Start listening over HTTP, Express-style |
Getting started
The fastest path is the getting started guide. To jump straight to a concept, pick a page from the sidebar.