Skip to main content

Long-term memory for LLM agents: the typed, sync and async Python client for the Tessera memory service.

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, then recall ranked hits or a prompt-ready context block. Sync and async clients, fully typed against the server's OpenAPI 3.1 contract (Pydantic v2 models).

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>. For timeouts, custom transport, logging, and raw responses, see 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

The SDK retries failed requests with jittered exponential backoff (default max_retries=2, honoring Retry-After). It retries 429/502/503 for any call. It retries an ambiguous 500, timeout, or connection error only for idempotent requests: GET/DELETE and memories.add, which mints a client-side ULID turn_id to stay ON CONFLICT-safe. It does not retry other writes on ambiguous failures, so they can't be double-applied. Override the budget per call with client.with_options(max_retries=0). See 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"]

Use with MCP covers full setup for Claude Code, Codex, Cursor, and other MCP clients, plus the privacy notes on transcript consolidation.

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.1.tar.gz (175.1 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.1-py3-none-any.whl (35.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tessera_memory-0.1.1.tar.gz
  • Upload date:
  • Size: 175.1 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.1.tar.gz
Algorithm Hash digest
SHA256 303b3904754aa2f650eebef67baaba12c3acc795f5be0d68c69fa38bcc4e40d5
MD5 01fb505d2d4b1506b632df0a2f1d312d
BLAKE2b-256 2b0de585f81f56b7342710445be3c684b48e94c29f9701f67df6da82d9ab73b4

See more details on using hashes here.

Provenance

The following attestation bundles were made for tessera_memory-0.1.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: tessera_memory-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6aefc7d097baddcef70fab205f9c7f03ea8efcf7c639bb24dbe0ffa8f7e24606
MD5 3aedb3b2776e9d2567ff363be245f1c3
BLAKE2b-256 a203af608abbeb795087b319ab4cfd330df4f4c3892d85445ad4f4070cb2a0f4

See more details on using hashes here.

Provenance

The following attestation bundles were made for tessera_memory-0.1.1-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