pydantic-ai-cosmosdb-memory
An Azure Cosmos DB (NoSQL) MemoryStore for the PydanticAI harness Memory capability — the per-user Markdown notebook the harness injects before every model call and lets the model write through write_memory, on a shared, durable container.
pip install pydantic-ai-cosmosdb-memory
from pydantic_ai import Agent
from pydantic_ai_harness.memory import Memory
from pydantic_ai_cosmosdb_memory import CosmosDBMemoryStore
store = CosmosDBMemoryStore(endpoint="https://<acct>.documents.azure.com:443/", key="<key>",
database_name="agents", container_name="memory")
agent = Agent("anthropic:claude-sonnet-5", deps_type=Deps,
capabilities=[Memory(store=store, namespace=lambda ctx: ctx.deps.user_id)])
How it works
- One container partitioned by
/id: a document per memory file (kind: "file",path,content,version,operation_id) and per operation receipt (kind: "op"). Database and container are auto-created under key-based auth. - Compare-and-swap: create uses
create_item(fails if the id exists); replace and delete re-read the document, check the harnessversion, then write withIf-Matchon the Cosmos ETag, so a concurrent change between read and write is rejected. A stale version raisesMemoryConflictError. - Operation receipts are reserved with
create_item, completed after the mutation, dropped if it fails — durable-execution replays return the original result; a reused id with different arguments raisesMemoryOperationConflictError. searchis the harness's bounded lexical search (SearchableMemoryStore);list_pathsis aSTARTSWITHquery onpath.
Docs: https://skamalj.github.io/agentstate-reducer/ · part of pydantic-ai-memory
License
MIT
Metadata
Release files for pydantic-ai-cosmosdb-memory 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pydantic_ai_cosmosdb_memory-0.1.0.tar.gz | 3.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pydantic_ai_cosmosdb_memory-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.1 kB
Release files / pydantic_ai_cosmosdb_memory-0.1.0.tar.gz
| Download URL | pydantic_ai_cosmosdb_memory-0.1.0.tar.gz |
|---|---|
| Size | 3.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8376f072848f6a3f8b8a8885fb16fd87524504bfe95f782071ee22edabfaef07
|
|
BLAKE2b-256 checksum How to use checksums |
88218ae4ceee7c125d98544d8eeb49d237c74ea4c95fc1226a9ffd86cbc7c618
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / pydantic_ai_cosmosdb_memory-0.1.0-py3-none-any.whl
| Download URL | pydantic_ai_cosmosdb_memory-0.1.0-py3-none-any.whl |
|---|---|
| Size | 4.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9bc4fe4d684480f7d3f227ac4a0a6d3e3019e82abc11d053a498f5489954f00a
|
|
BLAKE2b-256 checksum How to use checksums |
817ae6ff56fb6ab2dfc83b91355a146f9c06961fce261065fc437d89a7ea53a1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|