purra-sqlite · Python
English | 简体中文
SQLite persistence for PurrA Runs, events, operations, budgets, checkpoints, and tool receipts. Uses Python's standard library and requires Python 3.11+.
Install
From the repository root:
python -m pip install . ./integrations/sqlite/python
Configure
Given your model gateway and Agent preset:
from purra.api import AgentCore
from purra_sqlite import SqliteAgentAdapters
storage = SqliteAgentAdapters("agent.db", scope="user-1/project-1")
core = AgentCore(
model_gateway=gateway,
preset=preset,
run_repository=storage.runs,
output_repository=storage.outputs,
output_publisher=storage.publisher,
execution_lease_store=storage.leases,
)
Select scope from the application's authenticated user/project binding.
The bundle also exposes idempotency, run_tree, artifacts,
and long_tasks for the corresponding Core ports.
Recovery
Use storage.list_running() to find interrupted Runs and
core.resume(run_id, request, options=...) to resume an eligible checkpoint.
Restore the original Agent configuration. Execution leases prevent concurrent owners.
An interrupted external tool call may already have taken effect. Use
storage.reconcile_tool(...) with its result or evidence that it did not execute
before retrying. For persisted questions and answers, use
SqliteClarification.
Storage and shutdown
Canonical output events are appended as rows with Run and Root sequence indexes.
Event additions and the execution snapshot commit in one transaction. Output
pagination and subscription polling neither load the execution snapshot nor
acquire a writer lock. Run queries, lease lookup and list_running() remain
read-only. Tool receipts, lease renewal/release, cancellation requests, Agent
tree, Artifact and Long Task repository operations skip journal hydration and
flushing. Writes with an identifiable Run or output stream validate the Root
tree's sequence counts in SQL and buffer new events without decoding its history.
Core rules that inspect history (including planning projections and terminal
operation settlement) load the required Run's original events on demand.
Shared budgets still use all sibling Run counters; event-key replay uses indexed
lookups. Run reads retain complete Root journal hydration.
Cross-Root event keys use an index; Python SQLite requires json_extract, and
opening an existing v3 database creates this index on first use. Lease acquisition,
public transaction() and operations without an identifiable Run still validate
the full scope. Execution snapshots retain Run history,
checkpoints and receipts and are still loaded and saved at scope granularity.
This adapter therefore still suits bounded local workloads.
Storage v3 rejects v1/v2 data without automatic migration; existing databases
cannot be resumed directly.
Python and TypeScript execution snapshots are not interchangeable.
Both SDKs defer history loading for Run-scoped writes. SQL sequence checks scan the
selected Root's covering index without fetching event body rows or sorting by
Run. Root headers also have a covering index. Existing v3 databases build these
indexes on opening; this takes time and disk space, and inserts maintain them.
Metadata snapshots remain scope-sized, so these writes are
not constant-cost. Event bodies are validated when read; lease acquisition and
public transactions continue to decode the full journal.
Body Run/Root ids and sequence values must match their SQL columns on every
event read, including indexed replay and pagination. Inconsistent rows raise
ValueError and roll back the current transaction; they are not automatically
repaired. Unread event bodies remain deferred.
From the repository root, measure empty output polling and tail pagination with 100, 1,000 and 5,000 historical events:
PYTHONPATH=src:integrations/sqlite/python/src .venv/bin/python integrations/sqlite/python/scripts/benchmark_reads.py
This temporary-database benchmark reports warm median read latency, not concurrent throughput or real-model end-to-end performance.
Measure tool receipt writes at the same journal sizes, including both claim and result-commit transactions:
PYTHONPATH=src:integrations/sqlite/python/src .venv/bin/python integrations/sqlite/python/scripts/benchmark_writes.py
The tool callback is local and has no external side effect; this excludes real business-tool and model latency.
Measure active Run event writes beside a growing unrelated Root:
PYTHONPATH=src:integrations/sqlite/python/src .venv/bin/python integrations/sqlite/python/scripts/benchmark_run_writes.py
This measures isolation from other Roots, not scaling within a single growing Root.
Measure appends, model-attempt reservations and checkpoint commits within the same growing Root (two warmups and ten measured writes per operation):
PYTHONPATH=src:integrations/sqlite/python/src .venv/bin/python integrations/sqlite/python/scripts/benchmark_execution_writes.py
The history consists of private domain events. This excludes planning evidence
replay, concurrent throughput and real Provider latency.
Add --profile to report journal preparation, execution-state encoding/decoding
and the remaining transaction time separately. Phase medians are calculated
independently and need not sum to the total median.
The application owns database access, backups, and retention. Checkpoints contain
private model data. Call await core.close() before storage.close().
Opt-in closeout verification
After building TypeScript Core and SQLite, run both SDKs through separate writer processes, transaction termination, tool-receipt reconciliation and checkpoint reopening. The default fixture has 20 Roots, 60 Runs, 20,000 events and 64 KiB checkpoint messages per Root; all databases and effect markers are temporary.
PYTHONPATH=src:integrations/sqlite/python/src .venv/bin/python integrations/sqlite/python/scripts/verify_load.py --output /tmp/purra-load.json
scripts/verify_provider.py additionally runs a synthetic lookup task against a
user-selected DeepSeek configuration in a PurrTypos settings database. It requires
network access and consumes real API tokens. Supply --config-db, --config-id
and --output; add .:integrations/openai/python/src to PYTHONPATH and install
the OpenAI SDK. Credentials are read in memory, never written to the report.
Its explicit test transport maps max_completion_tokens to max_tokens, disables
thinking, drops OpenAI-only options, and maps developer messages to system.
This does not certify unmodified OpenAI transport compatibility with DeepSeek.
The eager reference is current code with deferred hydration disabled, not a
historical release. One paired run is functional evidence, not a latency SLA.
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 purra_sqlite-0.5.0.tar.gz.
File metadata
- Download URL: purra_sqlite-0.5.0.tar.gz
- Upload date:
- Size: 22.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2416cccc2627e87bfcbe944983bf66ec8c1a67abe4266aedd544f320a8642df
|
|
| MD5 |
b2dcde0b567c288c298bbef2132ad442
|
|
| BLAKE2b-256 |
5dfa66a9e3e7c47133fd6f328eea9011ed64ac297950f94e6b23bfac77a4629e
|
Provenance
The following attestation bundles were made for purra_sqlite-0.5.0.tar.gz:
Publisher:
release.yml on Lybrands/purra
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
purra_sqlite-0.5.0.tar.gz -
Subject digest:
d2416cccc2627e87bfcbe944983bf66ec8c1a67abe4266aedd544f320a8642df - Sigstore transparency entry: 2728713116
- Sigstore integration time:
-
Permalink:
Lybrands/purra@cd1a2fd6206999edf98a1a5b2047cca47517a64a -
Branch / Tag:
refs/tags/v0.5.0 - Owner: https://github.com/Lybrands
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@cd1a2fd6206999edf98a1a5b2047cca47517a64a -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file purra_sqlite-0.5.0-py3-none-any.whl.
File metadata
- Download URL: purra_sqlite-0.5.0-py3-none-any.whl
- Upload date:
- Size: 13.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7fbbedccec45e2dcc134a1251a0e2d50c681e7953c0dafb626874d2c782ab11a
|
|
| MD5 |
050f2f0ae345415e4cfa2ed09e63622d
|
|
| BLAKE2b-256 |
6b3ba74bd52f8ddc08cb099f95877b251099183fee2f67513abc570b3e1d7da3
|
Provenance
The following attestation bundles were made for purra_sqlite-0.5.0-py3-none-any.whl:
Publisher:
release.yml on Lybrands/purra
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
purra_sqlite-0.5.0-py3-none-any.whl -
Subject digest:
7fbbedccec45e2dcc134a1251a0e2d50c681e7953c0dafb626874d2c782ab11a - Sigstore transparency entry: 2728713748
- Sigstore integration time:
-
Permalink:
Lybrands/purra@cd1a2fd6206999edf98a1a5b2047cca47517a64a -
Branch / Tag:
refs/tags/v0.5.0 - Owner: https://github.com/Lybrands
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@cd1a2fd6206999edf98a1a5b2047cca47517a64a -
Trigger Event:
workflow_dispatch
-
Statement type: