Skip to main content

citadeldb-openai-agents

An OpenAI Agents SDK Session backed by Citadel. Encrypted at rest, embedded in your process, and deletes that destroy the key, not just the row.

pip install citadeldb-openai-agents

Requires citadeldb>=2.2,<3 and openai-agents>=0.20.0,<1. Set OPENAI_API_KEY for the SDK's default model before running the agent example.

This example uses local e5-large and requires the Candle source build and model setup. The default wheel accepts a bring-your-own semantic embedder.

import citadeldb
from agents import Agent, Runner
from citadeldb_openai_agents import CitadelSession

embedder = citadeldb.CandleEmbedder("/path/to/e5-large", preset="e5-large")
session = CitadelSession(
    "user-123",
    "agent.cdl",
    key="your-passphrase",
    embedder=embedder,
)

agent = Agent(name="assistant", instructions="Be brief.")
result = await Runner.run(agent, "remember my dog is called Mochi", session=session)
result = await Runner.run(agent, "what is my dog called?", session=session)

Transcripts persist across processes and are read by session id.

Many sessions, one file

Create multiple sessions through one store:

import citadeldb
from citadeldb_openai_agents import CitadelSessionStore

store = CitadelSessionStore(
    "agent.cdl",
    key="your-passphrase",
    embedder=embedder,
)
alice = store.session("user-alice")
bob = store.session("user-bob")

Sessions constructed on the same thread can share a database path and passphrase.

Deletes destroy the key

Every item is sealed under its own key. clear_session erases non-expired items in the session. Pre-erasure backups, copied keys, and exported plaintext are outside that erasure.

await session.clear_session()

pop_item erases and returns the latest non-expired item.

Search the transcript

search uses Citadel's hybrid recall over a session's text. Call it explicitly; the SDK session protocol loads transcripts by id.

semantic_store = CitadelSessionStore(
    "semantic-sessions.cdl",
    key="your-passphrase",
    embedder=embedder,
)
semantic_session = semantic_store.session("user-123")
await semantic_session.add_items(
    [
        {"role": "user", "content": "the deployment failed because the disk was full"},
        {"role": "user", "content": "lunch plans for friday"},
    ]
)

print(await semantic_session.search("why did the release break?", limit=1))

TTL

import citadeldb

store = CitadelSessionStore(
    "agent.cdl",
    key="your-passphrase",
    embedder=embedder,
    ttl=86400,  # seconds
)

Expired items are excluded from reads. Expiration alone does not destroy their keys; clear_session and pop_item do not include them. Core Memory.evict(region, EvictionPolicy.expired()) erases expired, non-immutable atoms across the region, not just one session.

Notes

Items are stored as opaque JSON, including function calls, reasoning items, and multi-part content. A text projection of content is used for search ranking.

embedder= is required. A bring-your-own object exposes dim, metric, model_id, and embed_with_cancel(texts, cancel_token); asymmetric models may also provide embed_queries_with_cancel. Accept None as the token; otherwise poll cancel_token.check() between bounded batches.

A session created with store= inherits that store's database, region, embedder, and TTL; passing any of those options alongside store= is rejected instead of silently ignoring it.

License

Apache-2.0

Release files for citadeldb-openai-agents 2.6.1

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

Source distribution (sdist)

Source distribution for citadeldb-openai-agents 2.6.1
File Size Uploaded
citadeldb_openai_agents-2.6.1.tar.gz 10.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for citadeldb-openai-agents 2.6.1
File Interpreter ABI Platform
citadeldb_openai_agents-2.6.1-py3-none-any.whl Python 3 none any Details

Total release size: 17.9 kB

Release files / citadeldb_openai_agents-2.6.1.tar.gz

Download URL citadeldb_openai_agents-2.6.1.tar.gz
Size 10.6 kB
Tags Source
SHA-256 checksum
How to use checksums
05c9e16b55b6b3b4f21f189e3821b30583a377843b76f61ee969fdaa32c8d93c
BLAKE2b-256 checksum
How to use checksums
f136001fe604bdaca7a2945529b143ebe1599c8825773e27d4b5d449f9a9ca6e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 25, 2026.

Transparency log

Release files / citadeldb_openai_agents-2.6.1-py3-none-any.whl

Download URL citadeldb_openai_agents-2.6.1-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bc778a4f5098d8bfe1d60da7db94e62b20ccc1c94b130b5ac55509effac33fe9
BLAKE2b-256 checksum
How to use checksums
9661bc4b02f8d40967262b55a3a6877db353b49197576cf6d26ad5966b07c1f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 25, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

2.6.1 This release

2 release files

2.6.0

2 release files

2.5.0

2 release files

2.4.0

2 release files

2.3.0

2 release files

2.2.0

2 release files

2.1.0

2 release files

2.0.0

2 release files

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