TensorSketch docs pre-1.0

TensorSketch

A code-first, visually-editable, durable agentic framework.

TensorSketch is a framework for building AI agents and agentic workflows where:

  • Code is the single ground truth. A visual canvas — TensorSketch Studio — is a losslessly-synced projection of your code, never a second, competing source of truth. Edits on the canvas write straight back into the source.
  • One type abstraction runs through everything. The same Schema describes tool inputs, structured LLM output, your graph's state, and every node's ports.
  • Execution is durable and parallel by construction. A BSP (bulk-synchronous parallel) runtime gives you cycles, deterministic fan-out, dynamic fan-out (Send), and clean checkpoint boundaries — so a run resumes exactly where it left off.
  • The core knows interfaces, never implementations. Every provider, tool, database backend, and protocol is chosen by name or passed in, so TensorSketch absorbs new research without a rewrite.
Status: Phases 0, 2, and 3 complete; Phase 1 (code⇄canvas) in progress. Built and tested: the type spine and BSP runtime; durable execution (checkpoints, resume/fork, exactly-once effects); streaming; the full agent layer (tools, three providers, the durable agent loop, structured output, dynamic fan-out); interop and observability (MCP, middleware, tracing + exporters, a name registry, OpenAI/A2A/AG-UI serving, an eval harness with drift detection); and TensorSketch Studio — the visual canvas with a live trace overlay. The public API is pre-1.0 and may still change. See the roadmap and build status.

Install (development)

cd tensorsketch
uv sync
uv run pytest        # the test suite (green on 3.11 + 3.12)

See Installation for details.

Hello, graph

A graph is typed nodes wired over typed state. Here's a two-step pipeline:

import asyncio
from tensorsketch import Schema, Node, Graph, Context, START, END


class State(Schema):        # the shared, typed state — each field is a channel
    text: str
    shout: str = ""


class Shout(Node):
    class In(Schema):       # this node reads state.text ...
        text: str
    class Out(Schema):      # ... and writes state.shout
        shout: str

    async def run(self, ctx: Context, inp: In) -> Out:
        return self.Out(shout=inp.text.upper() + "!")


app = (
    Graph(State)
    .add(Shout)
    .edge(START, "Shout")
    .edge("Shout", END)
).compile()

out = asyncio.run(app.invoke({"text": "hello"}))
print(out.shout)   # HELLO!

out is a fully-typed State, so out.shout is known to be a str.

Next: Getting started builds a routing agent step by step.

Learn the model

Design