Skip to main content

xtr-ai-orm-conversation-store

Agent conversations kept in two tables on an xtr-orm connection, for xtr-ai.

Install

uv add "xtr-ai[orm]"

The orm extra installs this package.

Use

OrmConversationStore is a pydantic-ai ConversationStore. Give it the connection's primary engine:

from pydantic_ai.conversation import Conversation

from xtr_ai_orm_conversation_store import OrmConversationStore

store = OrmConversationStore(engine)
conversation = await store.load(conversation_id) or Conversation(conversation_id=conversation_id)
result = await agent.run(prompt, conversation=conversation)
await store.save(result)

In an application, configure it in xtr-ai instead, as conversation_stores={"default": OrmConversationStoreConfig(connection="default")}, and inject ConversationStore. See xtr-ai's Use in an application.

Tables

Table Holds
ai_conversation One row per conversation: where its history ends, usage, pending tool calls, scope, branches, fork origin, revision
ai_conversation_entry One row per message, pointing at the one before it; shared by a conversation and its forks

table_prefix changes ai_. ConversationMappingDriver adds the tables to a connection's definitions, so orm:migrations:diff writes them. xtr-ai registers it when the store is configured.

Behaviour

  • Own transactions. Every call runs in a short transaction of its own and commits before it returns. A store never joins the caller's unit of work.
    • A long model call holds no database connection.
    • Rolling back the caller's work never undoes a saved turn.
    • A conversation cannot be saved atomically with the application's own rows.
  • Conflicts. A record and the messages it adds are written in one transaction. A save over a newer revision raises ConversationConflict and leaves neither behind.
  • History. A conversation's history is read in one recursive query.
  • Deleting. Deleting a conversation deletes the messages only it reaches. Messages a fork, or its origin, still reaches stay until the last of them is deleted.
    • A delete locks the conversation and its family first, and a fork's save holds its origin locked until it commits: a delete racing a fork waits for it and keeps what the fork shares, and a fork of an origin deleted meanwhile raises ConversationConflict.
  • Databases. It runs on PostgreSQL, MySQL 8 and SQLite, through their async drivers.
  • Scopes. read_records(scope=...) reads one scope's conversations; with no scope it reads every scope's — every tenant's, when scopes are tenants. Pass the caller's.

Development

uv sync
uv run ruff check && uv run ruff format --check && uv run basedpyright && uv run ty check && uv run pytest

License

MIT

Metadata

Release files for xtr-ai-orm-conversation-store 7.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xtr-ai-orm-conversation-store 7.1.0
File Size Uploaded Provenance Actions
xtr_ai_orm_conversation_store-7.1.0.tar.gz 9.9 kB With provenance Details for xtr_ai_orm_conversation_store-7.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for xtr-ai-orm-conversation-store 7.1.0
File Interpreter ABI Platform Actions
xtr_ai_orm_conversation_store-7.1.0-py3-none-any.whl Python 3 none any Details for xtr_ai_orm_conversation_store-7.1.0-py3-none-any.whl

Total release size: 21.2 kB

Release files / xtr_ai_orm_conversation_store-7.1.0.tar.gz

Download URL xtr_ai_orm_conversation_store-7.1.0.tar.gz
Size 9.9 kB
Tags Source
SHA-256 checksum
How to use checksums
131955000446adc74a40c8eb614effc2acf6684a1bb66cb4fb3b52e7f6df2729
BLAKE2b-256 checksum
How to use checksums
6f96ae6d5d006e9cb6a77092b5fdb839858c009c3b855ec7f261e6953a15f111
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Release files / xtr_ai_orm_conversation_store-7.1.0-py3-none-any.whl

Download URL xtr_ai_orm_conversation_store-7.1.0-py3-none-any.whl
Size 11.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8352f48fee7f22fe5404f21c8b7996ca11c7da50d731faabb299eabef2f16ba9
BLAKE2b-256 checksum
How to use checksums
fa04a9a68caa778fd965d2a69a9c599f109bcf5e1d4d6a7c998b785d4e16b2b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Security for xtr-ai-orm-conversation-store 7.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for xtr_ai_orm_conversation_store-7.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page