Agents you can replay, fork and trust.
An agent framework for TypeScript and Python, built on an append-only event log. Sandboxes, channels, memory, hooks and evals come built in. You write what your agent does and add your API keys.
git clone https://github.com/useagenthq/threadsNot on npm or PyPI yet. Install from source.
import { agent, sqlite, tool } from "@threads/core";
import { anthropic } from "@threads/anthropic";
import { z } from "zod";
const getWeather = tool({
name: "get_weather",
description: "Get the weather for a city.",
input: z.object({ city: z.string() }),
runs: "host",
effect: "read_only",
execute: async ({ city }) => `It is sunny in ${city}.`,
});
const weather = agent({
name: "weather",
instructions: "Answer questions about the weather.",
model: anthropic({
model: "claude-sonnet-5",
maxTokens: 8192,
contextWindow: 200_000,
maxOutputTokens: 8192,
}),
tools: [getWeather],
});
const result = await weather.run("What is the weather in Paris?", {
store: sqlite(".threads"),
});
if (result.status === "completed") console.log(result.output);- 1thread_starteda new thread
- 2user_inputWhat is the weather in Paris?
- 3model_requestthe exact request sent
- 4model_responsecalls get_weather
- 5tool_callget_weather {"city": "Paris"}
- 6permission_decisionread_only: no approval needed
- 7tool_resultIt is sunny in Paris.
- 8model_requestthe exact request sent
- 9model_responseIt is sunny in Paris.
- 10turn_completedcompleted
Every run is a log you can read, resume and fork. The right side is what thread.timeline() returns for this agent.
Built in
What you can build
Each piece is one option on your agent or host. Bring your API keys; threads does the plumbing.
- Evals & testingSave a real run as a regression case and replay it with a scripted model: no API keys, no network.saveCaseScripted modelFake sandbox
- SandboxesRun code in an isolated machine with no internet by default. Your keys never enter it.E2BDaytonaModal · Python
- Agents & toolsA model, instructions and tools. Built-in shell, file, web, git and code tools, plus any MCP server.agent()tool()MCP
- Multi-agentLet an agent start helpers, hand the conversation to a specialist, or share a task board.SubagentsHandoffsTeams
- ChannelsPut an agent in Slack, WhatsApp or GitHub, on a cron schedule, or behind an HTTP API.SlackWhatsAppGitHubHTTP
- Memory & knowledgeRemember across runs and search your own documents, scoped per tenant.LocalSupermemoryZep
- DurabilityResume after a crash without repeating an action. Park risky steps for a human to decide.Crash-safeApprovalsBudgets
- Hooks & permissionsGate tools, inject context, and decide who can approve what.HooksRulesPlan mode
- API referenceEvery public function and type, side by side in both languages.TypeScriptPythonHTTP
Why threads
One record makes the hard parts simple
Every run is an append-only log of what the agent saw and did. That one record is what makes these work.
Auditable
Every input, every exact model request, every tool call and result. Read it with timeline() or threads timeline.
Crash-safe
After a crash, an action that may already have happened is checked or handed to you, never blindly retried.
Easy evals
Fork any past step into its own sandbox, test with a scripted model, and save real threads as regression cases.
Run your first agent with no API key
An agent framework for TypeScript and Python, built on an append-only event log.