pip install tensorsketch-core

The code-first
agentic framework.

Build durable AI agents in plain, typed Python — and get a visual canvas for free, because the graph is the code. Tools, three providers, multi-agent orchestration, tracing, and evaluation, on a runtime that survives restarts.

Apache-2.0 Python 3.11+ mypy --strict pydantic v2

A tool-using agent in a dozen lines

Decorate a function to make a tool, hand it to create_agent, and every model and tool call in the loop is a durable step — crash halfway and it resumes without re-calling the model.

$pip install "tensorsketch-core[anthropic]"
calculator_agent.py
from tensorsketch import create_agent, tool
from tensorsketch.providers.anthropic import AnthropicProvider


@tool
def multiply(a: float, b: float) -> float:
    """Multiply two numbers."""
    return a * b


agent = create_agent(
    AnthropicProvider(model="claude-sonnet-4-6"),
    tools=[multiply],
    system="You are a helpful calculator.",
)

result = await agent.invoke({"query": "what is 6 * 7?"})
print(result.output)   # -> "6 times 7 is 42."

Everything in the box

A slim core (pydantic + typing, nothing else) with model SDKs, the canvas, storage, and serving as opt-in extras.

Runtime

A BSP superstep engine with native cycles, durable checkpoints, resume/fork, exactly-once effects, and live streaming.

Agents

@tool, a durable agent loop, structured output, dynamic fan-out, and multi-agent coordination via as_tool.

Providers

Anthropic, OpenAI (+ OpenAI-compatible), and Google behind a zero-SDK interface — the core imports no LLM SDK.

Code ⇄ Canvas

Extract a graph from source and write edits back in your own style, guarded by a round-trip invariant. This is what powers TensorStudio.

Interop

Consume and expose MCP tool servers; serve one agent over the OpenAI, A2A, and AG-UI protocols.

Observability

Vendor-neutral tracing with tokens and cost, file/OTel exporters, and onion-style middleware for retries.

Evaluation

Trajectory-aware graders, pass@k / pass^k, a CI gate, plus online scoring and drift detection.

Storage

Bring-your-own-database: Postgres and Redis backends behind one interface — the framework stays stateless.


Ready to build?

The full documentation covers getting started, every concept, and the design.