Skip to main content

Official Python SDK for the Tessera memory service (sync + async).

Project description

tessera-memory

PyPI version Python versions License CI

Long-term memory for LLM agents. The official Python SDK for the Tessera memory service — write conversational turns, and recall ranked hits or a prompt-ready context block. Sync and async clients, fully typed (Pydantic v2 models generated from the server's OpenAPI 3.1 contract).

Getting started · Concepts · API reference · Use with MCP

Installation

pip install tessera-memory
# or
uv add tessera-memory

Requires Python 3.10+.

Quickstart

from tessera_memory import Tessera

# Reads TESSERA_API_KEY from the environment,
# or pass it: Tessera(api_key="tsk_live_...").
client = Tessera()

# Write a memory.
client.memories.add(content="Ada prefers dark roast coffee.", role="user", user_id="ada")

# Retrieve ranked, typed hits (no LLM).
hits = client.search(query="what coffee does Ada like?", top_k=5, user_id="ada")

# Or compose a prompt-ready context block (may call an LLM server-side).
answer = client.query(query="what coffee does Ada like?", mode="chat", user_id="ada")
print(answer.context)

See Getting started for a guided walkthrough and Concepts for how memory is structured.

Async

Every method exists on AsyncTessera with await:

import asyncio
from tessera_memory import AsyncTessera


async def main() -> None:
    async with AsyncTessera() as client:
        await client.memories.add(content="Ada prefers dark roast coffee.", role="user", user_id="ada")
        async for item in client.memories.list(user_id="ada"):
            print(item.text)


asyncio.run(main())

Configuration

Setting Argument Environment variable Default
API key Tessera(api_key=) TESSERA_API_KEY required

Auth is sent as Authorization: Bearer <key>. Full options — timeouts, custom transport, logging, raw responses — are in Configuration.

Pagination

memories.list returns a cursor page that auto-follows the cursor when you iterate it:

for item in client.memories.list(user_id="ada"):   # iterates across all pages
    print(item.id, item.text)

Page manually with page.has_next_page() / page.get_next_page(). See the reference.

Handling errors

Every error derives from TesseraError. HTTP errors carry the parsed RFC 9457 problem body and the request id.

from tessera_memory import NotFoundError, RateLimitError, TesseraError

try:
    client.memories.get("ep_missing", user_id="ada")
except NotFoundError:
    ...
except RateLimitError as exc:
    print(exc.request_id)
except TesseraError:
    ...
Status Exception Status Exception
401 AuthenticationError 429 RateLimitError
403 PermissionDeniedError ≥ 500 InternalServerError
404 NotFoundError timeout APITimeoutError
409 ConflictError network APIConnectionError
422 UnprocessableEntityError

See Error handling.

Retries

Failed requests are retried with jittered exponential backoff (default max_retries=2, honoring Retry-After). 429/502/503 are retried for any call; an ambiguous 500/timeout/connection error is retried only for idempotent requests — GET/DELETE and memories.add, which mints a client-side ULID turn_id to stay ON CONFLICT-safe. Other writes are not retried on ambiguous failures, so they can't be double-applied. Override per call with client.with_options(max_retries=0). Details in Configuration.

Logging

Set TESSERA_LOG=debug (or info) to log request/response lines to stderr. The Authorization header, the API key, and request bodies are never logged.

Use with MCP (Claude Code, Codex)

Expose memory to a coding agent with the tessera-mcp server. You don't install this SDK separately — uvx fetches the server (and the SDK with it) on first run. Set TESSERA_API_KEY and TESSERA_REPO in your shell first.

Claude Code — install the plugin:

/plugin marketplace add harshkedia177/tessera-python
/plugin install tessera-memory@tessera

Codex — add to ~/.codex/config.toml:

[mcp_servers.tessera_memory]
command = "uvx"
args = ["--from", "tessera-mcp", "tessera-mcp"]
env_vars = ["TESSERA_API_KEY", "TESSERA_REPO"]

Full setup for Claude Code, Codex, Cursor, and other MCP clients — plus the privacy notes on transcript consolidation — is in Use with MCP.

Documentation

Development

make sync-spec    # copy openapi.json from the server checkout
make generate     # regenerate src/tessera_memory/models.py from openapi.json
make lint         # ruff check + format --check
make typecheck    # mypy --strict
make test         # pytest (respx-mocked)

License

Apache-2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tessera_memory-0.1.0.tar.gz (175.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tessera_memory-0.1.0-py3-none-any.whl (35.5 kB view details)

Uploaded Python 3

File details

Details for the file tessera_memory-0.1.0.tar.gz.

File metadata

  • Download URL: tessera_memory-0.1.0.tar.gz
  • Upload date:
  • Size: 175.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tessera_memory-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c8881553957f32fdaff72290ade6fd9e38c38ae5f390eb20b91ccf0431cfe369
MD5 c335c1a62b441c4337bf910a57632706
BLAKE2b-256 13d3bbe7503beac36c08b2b7143603c5ca6b820af984401c6d59904eb7e07103

See more details on using hashes here.

Provenance

The following attestation bundles were made for tessera_memory-0.1.0.tar.gz:

Publisher: ci.yml on harshkedia177/tessera-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tessera_memory-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: tessera_memory-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 35.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tessera_memory-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c85897b445ab8fc692e364ede0aeb7d6c211cb0571ada8c5a6ee3a72f37e5c91
MD5 bcd23098e565085d51da4754f94b082e
BLAKE2b-256 c536954550a7fe6a68639358253eeaa88f4256907b1ef906daef57908c94f18f

See more details on using hashes here.

Provenance

The following attestation bundles were made for tessera_memory-0.1.0-py3-none-any.whl:

Publisher: ci.yml on harshkedia177/tessera-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page