Skip to content

Add agent session store protocols - #1686

Open
theomonnom wants to merge 10 commits into
mainfrom
theo/agent-session-protos
Open

Add agent session store protocols#1686
theomonnom wants to merge 10 commits into
mainfrom
theo/agent-session-protos

Conversation

@theomonnom

Copy link
Copy Markdown
Member

Adds the two protocols the agent session store speaks. Both are new files; nothing existing changes shape.

livekit_agent_session_store.proto is the management API (Twirp AgentSessionStore): CreateSession, GetSession, ListSessions, DeleteSession, and Dump for a pre-authenticated download URL of a session consistent at a commit sequence.

livekit_agent_session_db.proto is the data plane: one SessionStoreRequest / SessionStoreResponse frame pair over a single WebSocket per session, correlated by a client-chosen request_id. It carries exec, query, atomic batch, interactive transactions (begin/commit/rollback), cancel, and ping. Query results stream as SessionRowBatch frames paced by credits the client advertises, so any result size streams with bounded memory at every hop. SessionValue mirrors SQLite's five storage classes exactly.

Why the other files changed

protoc-gen-twirp numbers file descriptors by position within a single protoc invocation, so inserting one service shifts every file after it. The eight *.twirp.go diffs are exactly that rename, two lines each, and magefile.go adds the two protos to the generation lists. Generated with the repo's own mage proto.

Context

This unblocks the session store service, which currently cannot build outside a local checkout of this repo.

livekit_agent_session_store.proto is the management API (Twirp): create, get,
list and delete a session, plus Dump for a consistent download URL.

livekit_agent_session_db.proto is the data plane: a request/response frame pair
over one WebSocket per session, correlated by client-chosen request_id, with
exec, query, atomic batch, interactive transactions, and credit-paced row
batches so any result size streams with bounded memory at every hop.
SessionValue mirrors SQLite's five storage classes.

The other twirp files change only because protoc-gen-twirp numbers file
descriptors by position in the invocation, so inserting one service shifts the
ones after it.
@changeset-bot

changeset-bot Bot commented Jul 27, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 17bed51

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

github-actions Bot and others added 2 commits July 27, 2026 17:41
Regenerated, so the same lines leave the Go doc comments.
theomonnom and others added 7 commits July 28, 2026 13:19
Gates the agent session store: creating, reading, querying, exporting and
deleting a project's session databases, on both the management API and the
data-plane connection. Without it that service could only verify that a token
was signed by a key belonging to the project, not what it was allowed to do.
Query results were row-oriented: a SessionValue message per cell plus its oneof
wrapper, which cost two allocations per cell on the server, the same again as
the client unmarshalled, and left the garbage collector walking pointer-dense
batches. A SessionColumnBatch carries a type tag per value (SQLite types values
individually, not by column) plus one packed array per storage class, with text
and blob bytes concatenated and addressed by exclusive end offsets rather than
repeated string, which is what lets a decoder hand out subslices of one buffer.

Measured end to end in the service, an 8000-row scan went from 47,819
allocations to 63, and a scalar-heavy batch is 43% smaller on the wire so more
rows fit per credit.

ListSessions now returns SessionSummary rather than GetSessionResponse, which
drops tip from listings. tip advances on every commit, so a listing index cannot
carry it without putting a write on the commit path, which means listing has to
read every session's metadata row to fill it in. It is also stale on arrival,
since anything acting on it must re-read. Everything else listing returns is
immutable, so a summary can be served straight from an index. GetSession still
returns tip for a single session.

A separate message rather than leaving the field unset: 0 is a valid tip, for a
session with no commits, so an unset field would be genuinely ambiguous.
An agent session is already a running conversation in this package's vocabulary
(agent/livekit_agent_session.proto carries chat messages, function calls and
handoffs), so agent.sessionAdmin read as authority over those rather than over
the session store's databases, which is what it gates. The store's service is
AgentSessionStore, so the grant now matches it.
They carried rationale from the implementation that motivated them, including Go
allocation counts, which does not belong in a protocol every SDK reads. What is
left states the contract: that values are typed per value rather than per column,
how the text and blob offsets address a value, and that a summary has no tip.
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.

2 participants