Alpha · Open source · Apache-2.0

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/threads

Not 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);
thread.timeline()append-only
  1. 1thread_starteda new thread
  2. 2user_inputWhat is the weather in Paris?
  3. 3model_requestthe exact request sent
  4. 4model_responsecalls get_weather
  5. 5tool_callget_weather {"city": "Paris"}
  6. 6permission_decisionread_only: no approval needed
  7. 7tool_resultIt is sunny in Paris.
  8. 8model_requestthe exact request sent
  9. 9model_responseIt is sunny in Paris.
  10. 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.

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.

Every run is a log: thread_started, user_input, model_request, model_response, tool_call, permission_decision, tool_result, turn_completed. Replay (timeline), resume (run again), fork and evals (saveCase) are all read from it.

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.