Metadata-Version: 2.5
Name: pydantic-ai-firestore-memory
Version: 0.1.0
Summary: Google Firestore MemoryStore for the PydanticAI harness Memory capability — CAS versions via transactions and idempotent operation receipts
Project-URL: Homepage, https://github.com/skamalj/pydantic-ai-memory
Project-URL: Repository, https://github.com/skamalj/pydantic-ai-memory.git
Project-URL: Documentation, https://skamalj.github.io/agentstate-reducer/
Author-email: Kamal <skamalj@gmail.com>
Keywords: agent-memory,firestore,gcp,long-term-memory,memory,memorystore,pydantic-ai,pydantic-ai-harness
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.10
Requires-Dist: google-cloud-firestore>=2.16
Requires-Dist: pydantic-ai-memory-core>=0.1.0
Description-Content-Type: text/markdown

# pydantic-ai-firestore-memory

A **Google Firestore** `MemoryStore` for the [PydanticAI harness](https://pydantic.dev/docs/ai/harness/memory/) `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 collection.

```bash
pip install pydantic-ai-firestore-memory
```

```python
from pydantic_ai import Agent
from pydantic_ai_harness.memory import Memory
from pydantic_ai_firestore_memory import FirestoreMemoryStore

store = FirestoreMemoryStore(project_id="my-project", collection="agent_memory")
agent = Agent("anthropic:claude-sonnet-5", deps_type=Deps,
              capabilities=[Memory(store=store, namespace=lambda ctx: ctx.deps.user_id)])
```

Authentication uses Application Default Credentials (`gcloud auth application-default login`).

## How it works

- One collection: a document per memory file (`kind: "file"`, `path`, `content`, `version`, `operation_id`) and per operation receipt (`kind: "op"`). No index setup needed.
- **Compare-and-swap**: create, replace and delete each run in a Firestore **transaction** that reads the document, checks the harness `version`, then writes; Firestore aborts and retries on contention, so a stale version raises `MemoryConflictError` and never overwrites.
- **Operation receipts** are reserved transactionally, completed after the mutation, dropped if it fails — durable-execution replays return the original result; a reused id with different arguments raises `MemoryOperationConflictError`.
- `search` is the harness's bounded lexical search (`SearchableMemoryStore`); `list_paths` is a range query on `path`.

Docs: <https://skamalj.github.io/agentstate-reducer/> · part of [pydantic-ai-memory](https://github.com/skamalj/pydantic-ai-memory)

## License

MIT
