Official Python SDK for Statewave — Memory OS for AI agents
Project description
statewave-py
Official Python SDK for Statewave — memory runtime for AI agents and applications.
Install
pip install statewave-py
Quick start
from statewave import StatewaveClient
# Basic (no auth)
with StatewaveClient("http://localhost:8100") as sw:
...
# With authentication and tenant
with StatewaveClient(
"http://localhost:8100",
api_key="your-key",
tenant_id="acme",
) as sw:
# Record an episode
sw.create_episode(
subject_id="user-42",
source="support-chat",
type="conversation",
payload={
"messages": [
{"role": "user", "content": "My name is Alice and I work at Globex."},
{"role": "assistant", "content": "Welcome Alice!"},
]
},
)
# Compile memories (idempotent)
result = sw.compile_memories("user-42")
print(f"Created {result.memories_created} memories")
# Retrieve ranked, token-bounded context
ctx = sw.get_context("user-42", task="Help with billing", max_tokens=300)
print(ctx.assembled_context)
# Batch ingestion (up to 100)
sw.create_episodes_batch([
{"subject_id": "user-42", "source": "crm", "type": "note", "payload": {"text": "Prefers email"}},
{"subject_id": "user-42", "source": "crm", "type": "note", "payload": {"text": "Enterprise plan"}},
])
# Search memories by kind
facts = sw.search_memories("user-42", kind="profile_fact")
for m in facts.memories:
print(f" [{m.kind}] {m.content}")
# Semantic search (requires embeddings)
results = sw.search_memories("user-42", query="billing", semantic=True)
# List all known subjects
subjects = sw.list_subjects()
for s in subjects.subjects:
print(f" {s.subject_id}: {s.episode_count} episodes, {s.memory_count} memories")
# Get timeline
timeline = sw.get_timeline("user-42")
print(f"{len(timeline.episodes)} episodes, {len(timeline.memories)} memories")
# Delete all subject data
sw.delete_subject("user-42")
Async client
from statewave import AsyncStatewaveClient
async with AsyncStatewaveClient("http://localhost:8100") as sw:
ctx = await sw.get_context("user-42", task="Help with billing")
print(ctx.assembled_context)
Error handling
from statewave import StatewaveClient, StatewaveAPIError, StatewaveConnectionError
try:
sw = StatewaveClient("http://localhost:8100")
sw.compile_memories("user-42")
except StatewaveAPIError as e:
print(f"API error [{e.status_code}]: {e.code} — {e.message}")
print(f"Request ID: {e.request_id}")
except StatewaveConnectionError:
print("Cannot connect to Statewave server")
Models
All response types are Pydantic models with full type hints:
Episode— raw interaction recordMemory— compiled memory with provenanceCompileResult— compilation responseSearchResult— search responseContextBundle— assembled context with facts, episodes, provenanceTimeline— chronological subject historyDeleteResult— deletion confirmationBatchCreateResult— batch ingestion responseSubjectSummary— subject with episode/memory countsListSubjectsResult— paginated subject listing
Running tests
pip install -e ".[dev]"
pytest tests/ -v
License
Apache-2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file statewave_py-0.5.0.tar.gz.
File metadata
- Download URL: statewave_py-0.5.0.tar.gz
- Upload date:
- Size: 14.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
585c0fc5f2e5bfa11518cd587937e3b910cc8a0940d2ef2da5c46641853f1186
|
|
| MD5 |
7abc4b383bf712a3d7dc1928f0f94f27
|
|
| BLAKE2b-256 |
19b19879503fd860af1b1d6c8d809cec04aaff3f64e057b13c65f91adbe0ca59
|
Provenance
The following attestation bundles were made for statewave_py-0.5.0.tar.gz:
Publisher:
release.yml on smaramwbc/statewave-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
statewave_py-0.5.0.tar.gz -
Subject digest:
585c0fc5f2e5bfa11518cd587937e3b910cc8a0940d2ef2da5c46641853f1186 - Sigstore transparency entry: 1398370074
- Sigstore integration time:
-
Permalink:
smaramwbc/statewave-py@351b9e0ff6ce374d89561d64da7f8afb570b01bc -
Branch / Tag:
refs/tags/v0.5.0 - Owner: https://github.com/smaramwbc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@351b9e0ff6ce374d89561d64da7f8afb570b01bc -
Trigger Event:
push
-
Statement type:
File details
Details for the file statewave_py-0.5.0-py3-none-any.whl.
File metadata
- Download URL: statewave_py-0.5.0-py3-none-any.whl
- Upload date:
- Size: 12.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4df4b6caefe0c70209cbe342bd8e742a84413e24b29cf5b9db82a1d366fab149
|
|
| MD5 |
eb2d7e58de677c0784c10a50e83ebee9
|
|
| BLAKE2b-256 |
8abdc15601f06e973f0b09a2212db0cc000a0037ae0f2628e657453e64912e19
|
Provenance
The following attestation bundles were made for statewave_py-0.5.0-py3-none-any.whl:
Publisher:
release.yml on smaramwbc/statewave-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
statewave_py-0.5.0-py3-none-any.whl -
Subject digest:
4df4b6caefe0c70209cbe342bd8e742a84413e24b29cf5b9db82a1d366fab149 - Sigstore transparency entry: 1398370174
- Sigstore integration time:
-
Permalink:
smaramwbc/statewave-py@351b9e0ff6ce374d89561d64da7f8afb570b01bc -
Branch / Tag:
refs/tags/v0.5.0 - Owner: https://github.com/smaramwbc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@351b9e0ff6ce374d89561d64da7f8afb570b01bc -
Trigger Event:
push
-
Statement type: