Skip to content

storage: pick agent-db on Cloud and SQLite elsewhere by default - #8675

Open
longcw wants to merge 1 commit into
v2.0from
longc/auto-storage
Open

longcw wants to merge 1 commit into
v2.0from
longc/auto-storage

Conversation

@longcw

@longcw longcw commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

A server needs storage for its threads, and which one fits depends on where it runs: agent-db exists only on LiveKit Cloud, and a self-hosted server has none. AgentServer(storage=None) always took a local SQLiteStorage, so the examples passed AgentDBStorage() and failed on a self-hosted server.

AgentServer(storage=None) now picks the storage when the server runs: AgentDBStorage in the server's own project for a LiveKit Cloud URL, and SQLiteStorage on any other server or for a console call. An explicit storage= is used as given, and the server logs the storage it uses at startup:

INFO livekit.agents thread storage {"storage": "AgentDBStorage", "location": "https://beta-api.livekit.cloud"}

Why the choice is made this way:

  • One place. AgentServer._ensure_storage holds the whole rule. Doors bind the server's storage when it runs, not when they are added, so console can ask for its local choice before anything binds.
  • Console stays local. A console call is one simulated call on this machine with no thread, so it never needs the project's agent-db, its feature flag or the network, whatever project LIVEKIT_URL names.
  • The server's own project. The default agent-db storage takes the server's resolved URL and key pair, so a server configured only through ws_url=, api_key= and api_secret= works without the environment.

The voice examples no longer name a storage, so they run on Cloud and on a self-hosted server as they are.

Stacked on #8602.

Context for reviewing and coding agents

Where it comes from

Theo's review on #8602 suggested picking the storage automatically, skipping the choice for console, and logging the active storage at startup.

Why _rebuild builds the default agent-db storage

AgentDBStorage takes no URL: its native constructor reads LIVEKIT_URL when none is given, and AgentDBStorage() passes none. _rebuild is the existing path that unpickles a storage in a job process from its arguments, and it passes the server's URL through to the native constructor without a new public argument. The URL stays in the arguments, so job processes rebuild the same storage.

What changes for a console run

Before, an app without storage= got SQLite in console, and the examples got agent-db because they named it. Now both get SQLite in console unless the app names a storage.

@longcw
longcw requested a review from a team as a code owner November 19, 2026 12:32

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Devin Review: 1 flag

Not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)

Devin Review

@longcw
longcw added this pull request to stack #8676 November 19, 2026 12:35
Base automatically changed from longc/self-hosted-delegation to v2.0 November 20, 2026 04:56
…ewhere

AgentServer(storage=None) always took a local SQLiteStorage, so the
examples passed AgentDBStorage() and could not run on a self-hosted
server, which has no agent-db. AgentServer._ensure_storage now picks,
in one place, when the server runs: AgentDBStorage in the server's own
project (its resolved URL and key pair, so options alone configure it)
for a LiveKit Cloud URL, and SQLiteStorage on any other server or for a
console call, which stays local whatever project LIVEKIT_URL names. The
server logs the storage it uses at startup, and the voice examples no
longer name one.
@longcw
longcw force-pushed the longc/auto-storage branch from 7da3386 to 0df5e4d Compare November 20, 2026 04:56

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant