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.4 reduces active PostgreSQL runtime CPU with bounded durable delta batching, terminal-aware result checks, shared recent event pages, and focused actor observation. Full history remains the default, and public replay stays complete. Stop PostgreSQL writers before upgrading an existing database; the root-key migration rewrites session rows.

See the documentation, the 1.4 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.4.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.4.0
File Size Uploaded
tantra_harness-1.4.0.tar.gz 302.4 kB Details

Built distribution (wheel)

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

Total release size: 437.1 kB

Release files / tantra_harness-1.4.0.tar.gz

Download URL tantra_harness-1.4.0.tar.gz
Size 302.4 kB
Tags Source
SHA-256 checksum
How to use checksums
bad4833e4737d00c5c7010dc623be8d1e71374da5d9f7aa63bd6e9b220c7c8af
BLAKE2b-256 checksum
How to use checksums
d9007099158e1ef49375d97baf05837038178101bcbd8e1fc83cfe503f6bdce0
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.4.0-py3-none-any.whl

Download URL tantra_harness-1.4.0-py3-none-any.whl
Size 134.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e96c2b3674e06c5dbb4bcec7a6b1c30b04bcbe0826007dd52eae30ca171c3867
BLAKE2b-256 checksum
How to use checksums
b4829bb6170c983554269ff7074b98c354b60d768744f68038f20939bf3ff177
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

This release

1.4.0 This release

2 release files

1.3.0

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