SQLite-backed context store for Axio
Project description
axio-context-sqlite
SQLite-backed persistent context store for axio.
Installation
pip install axio-context-sqlite
Usage
Open a connection with connect(), then create a SQLiteContextStore bound to a
session. The caller owns the connection and is responsible for closing it.
import asyncio
import tempfile
import pathlib
from axio_context_sqlite import connect, SQLiteContextStore
from axio.messages import Message
from axio.blocks import TextBlock
async def main() -> None:
conn = await connect(pathlib.Path(tempfile.mkdtemp()) / "chat.db")
try:
store = SQLiteContextStore(conn, session_id="my-session")
await store.append(Message(role="user", content=[TextBlock(text="Hello")]))
history = await store.get_history()
assert len(history) == 1
finally:
await conn.close()
asyncio.run(main())
SQLiteContextStore implements the axio.context.ContextStore ABC and persists
conversation history across process restarts. Multiple sessions can coexist in
the same database file, isolated by session_id and project.
Agent integration
import asyncio
import tempfile
import pathlib
from axio.agent import Agent
from axio_context_sqlite import connect, SQLiteContextStore
async def main() -> None:
conn = await connect(pathlib.Path(tempfile.mkdtemp()) / "chat.db")
try:
ctx = SQLiteContextStore(conn, session_id="main")
agent = Agent(system="You are helpful.", tools=[], transport=transport)
result = await agent.run("Hello!", ctx)
assert result == "Hi!"
finally:
await conn.close()
asyncio.run(main())
Listing sessions
import asyncio
import tempfile
import pathlib
from axio_context_sqlite import connect, SQLiteContextStore
from axio.messages import Message
from axio.blocks import TextBlock
async def main() -> None:
conn = await connect(pathlib.Path(tempfile.mkdtemp()) / "chat.db")
try:
store = SQLiteContextStore(conn, session_id="main", project="/myproject")
await store.append(Message(role="user", content=[TextBlock(text="hi")]))
sessions = await store.list_sessions()
for s in sessions:
print(s.session_id, s.preview, s.message_count)
assert len(sessions) == 1
finally:
await conn.close()
asyncio.run(main())
Forking
fork() copies the current session's messages into a new session — useful for
branching conversations without affecting the original:
import asyncio
import tempfile
import pathlib
from axio_context_sqlite import connect, SQLiteContextStore
from axio.messages import Message
from axio.blocks import TextBlock
async def main() -> None:
conn = await connect(pathlib.Path(tempfile.mkdtemp()) / "chat.db")
try:
store = SQLiteContextStore(conn, session_id="main")
await store.append(Message(role="user", content=[TextBlock(text="original")]))
branch = await store.fork()
assert branch.session_id != store.session_id
assert len(await branch.get_history()) == 1
finally:
await conn.close()
asyncio.run(main())
License
MIT
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 axio_context_sqlite-0.6.1.tar.gz.
File metadata
- Download URL: axio_context_sqlite-0.6.1.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
806dde375765206f29018f883c71e53daa41c4f222b87eac5cd8d1f8fa711138
|
|
| MD5 |
700066a99f3dc7a54c1b348a5d0ca7e4
|
|
| BLAKE2b-256 |
47ca70dc9ea9d2f42569e4fababda420fdb0142ab79b255d3066e898c8e11d2c
|
Provenance
The following attestation bundles were made for axio_context_sqlite-0.6.1.tar.gz:
Publisher:
publish.yml on axio-agent/monorepo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
axio_context_sqlite-0.6.1.tar.gz -
Subject digest:
806dde375765206f29018f883c71e53daa41c4f222b87eac5cd8d1f8fa711138 - Sigstore transparency entry: 1322349969
- Sigstore integration time:
-
Permalink:
axio-agent/monorepo@75f5370c1a335ea44786686398159dddb8772b3f -
Branch / Tag:
refs/tags/0.6.1 - Owner: https://github.com/axio-agent
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@75f5370c1a335ea44786686398159dddb8772b3f -
Trigger Event:
release
-
Statement type:
File details
Details for the file axio_context_sqlite-0.6.1-py3-none-any.whl.
File metadata
- Download URL: axio_context_sqlite-0.6.1-py3-none-any.whl
- Upload date:
- Size: 5.0 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 |
a2273183f84240ea18f7ca284d1fd14d755f0407a72367ea409db0e19e1efbf3
|
|
| MD5 |
d3d88bc7c9a6678e3a7fd4126c9c4d00
|
|
| BLAKE2b-256 |
33910525f4ee73cd4300df9a7361a8a0befab7f0ca5b8bf4d044e7acac4d6577
|
Provenance
The following attestation bundles were made for axio_context_sqlite-0.6.1-py3-none-any.whl:
Publisher:
publish.yml on axio-agent/monorepo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
axio_context_sqlite-0.6.1-py3-none-any.whl -
Subject digest:
a2273183f84240ea18f7ca284d1fd14d755f0407a72367ea409db0e19e1efbf3 - Sigstore transparency entry: 1322350391
- Sigstore integration time:
-
Permalink:
axio-agent/monorepo@75f5370c1a335ea44786686398159dddb8772b3f -
Branch / Tag:
refs/tags/0.6.1 - Owner: https://github.com/axio-agent
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@75f5370c1a335ea44786686398159dddb8772b3f -
Trigger Event:
release
-
Statement type: