Skip to main content

tantra logo

tantra

The agent actor runtime as a Python library. Install name tantra-harness, import name tantra.

Tantra gives each agent a durable FIFO inbox, an independent event journal, and one active turn. A process-wide Runtime owns providers, stores, tools, hooks, permissions, skills, memory, compaction, telemetry, actor tasks, and writer connections.

Install

Command Adds
pip install tantra-harness Core runtime and shell tools
pip install "tantra-harness[web]" Brave web search and web fetch
pip install "tantra-harness[doc]" PDF and Word document reading
pip install "tantra-harness[postgres]" PostgreSQL storage
pip install "tantra-harness[telemetry]" OpenTelemetry tracing

The unrelated PyPI project tantra installs the same import name. Do not install both projects in one environment.

Basic usage

import asyncio
from uuid import uuid4

from tantra import Agent, OpenAICompatible, Runtime, SQLiteStore
from tantra.extratools.web import web_search


class Researcher(Agent):
    model = "gpt-5"
    prompt = "Answer with current, sourced information."
    tools = [web_search(api_key=BRAVE_API_KEY)]


async def main() -> None:
    store = SQLiteStore("sessions.db")
    await store.setup()
    runtime = Runtime(
        OpenAICompatible("https://api.openai.com/v1", OPENAI_API_KEY),
        store,
        [Researcher],
    )
    root_id = await runtime.create(Researcher)
    async with runtime.connect(root_id, writable=True) as connection:
        result = await connection.prompt(
            "What changed in Python 3.13?",
            command_id=uuid4(),
        )
    print(result.text)
    await runtime.aclose()


asyncio.run(main())

Connection.prompt() accepts a durable command and waits for its terminal result. For streaming, call send() and iterate the connection. Reconnect with the last scalar seq as after; use Runtime.events() for a child journal. Command IDs are UUIDs and make acceptance idempotent.

Subagents are independent actors. Models use the injected spawn, status, send, and finish tools; no parent stream merges child events. Plain completion leaves a child reusable and notifies its parent with status only, while finish delivers the final result. Human asks and approval-gated tools are root-only.

Compaction is opt-in with Runtime(compactor=PruneThenSummarize()). Configured runtimes budget the complete provider request, preserve system and tool definitions, and compact each actor independently.

For multi-process deployments, pair PostgresStore with the optional PostgresCoordinator for leased execution ownership, fenced writes, command forwarding, and takeover recovery. The default remains single-process.

Tantra 1.3 adds indexed command lookup, operational checkpoints, pooled PostgreSQL access, shared observer catch-up, and safe root-tree deletion with scoped cleanup and read-only dry runs. Runtime(history_mode="compacted") can load the latest summary and retained history; full history remains the default, and public replay stays complete. Stop PostgreSQL writers before upgrading an existing database.

See the documentation, the 1.3 upgrade guide, and the coordinator setup guide.

Reference app

apps/sarathi is the repository's interactive web application.

License

Apache-2.0

Metadata

Release files for tantra-harness 1.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tantra-harness 1.3.0
File Size Uploaded
tantra_harness-1.3.0.tar.gz 276.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tantra-harness 1.3.0
File Interpreter ABI Platform
tantra_harness-1.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 405.8 kB

Release files / tantra_harness-1.3.0.tar.gz

Download URL tantra_harness-1.3.0.tar.gz
Size 276.4 kB
Tags Source
SHA-256 checksum
How to use checksums
d8845f9c8efe07d6cde13fab015e5cd1d34aa39f646752694507d5fd3de1a9ad
BLAKE2b-256 checksum
How to use checksums
67d1503fa06b199263936b16482e15115e98625f64710d82d55c0097449d1d50
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 4, 2026.

Transparency log

Release files / tantra_harness-1.3.0-py3-none-any.whl

Download URL tantra_harness-1.3.0-py3-none-any.whl
Size 129.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4f9745c5d6111af9c06c4bb1d930050936696d78711b76b0f1adc50ebee6db27
BLAKE2b-256 checksum
How to use checksums
fa736a70aa48abc92740d441744a7ac1fc7e1f49a09f685894f69702a4c3c409
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 4, 2026.

Transparency log

Release history Release notifications | RSS feed

2.0.0

2 release files

1.4.0

2 release files

This release

1.3.0 This release

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page