feat(sessions): add a client-set title to sessions - #6501
Open
answersamir wants to merge 1 commit into
Open
Conversation
Adds an optional, client-set title to the Session model and threads it
through every built-in session service and the web server, addressing the
long-standing request for readable titles in session/chat-history lists.
- Session.title (nullable, defaults to None); surfaced by get_session and
list_sessions.
- BaseSessionService.update_session_title is a concrete method that raises
NotImplementedError by default (mirrors get_user_state), so existing
third-party subclasses keep working without changes.
- InMemory, Database (SQLAlchemy) and Sqlite services implement it;
VertexAiSessionService raises NotImplementedError because the managed
Agent Engine Session API exposes no client-set title.
- DatabaseSessionService adds a nullable title column to the v1 schema and
reconciles it onto pre-existing databases in place via a new additive
column healer (_ensure_schema_columns_exist), mirroring the existing index
healer. SqliteSessionService does the same via ALTER TABLE ADD COLUMN. No
schema-version bump is needed for a nullable, additive column.
- Setting a title preserves the session's update_time so a rename does not
invalidate an in-flight session copy (which would trip the stale-writer
check on the next append_event).
- The existing PATCH .../sessions/{session_id} endpoint accepts an optional
title (state_delta is now optional as well).
Adds unit tests across all backends, the web server endpoint, and the
database column healer.
Builds on the approach in google#3703 (closed). Addresses google#1340.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an optional, client-set
titleto theSessionmodel and threads it through every built-in session service and the web server, so frontends can show readable titles in session/chat-history lists instead of UUIDs.This is the manual / client-set variant of #1340 (the service stores a title the caller provides; ADK does not auto-generate it), and builds on the approach of the closed #3703.
What's included
Session.title(nullable, defaults toNone); surfaced byget_sessionandlist_sessions.BaseSessionService.update_session_title(...)as a concrete method that raisesNotImplementedErrorby default — mirroringget_user_state, so existing third-partyBaseSessionServicesubclasses keep working without changes (no new abstract method).InMemorySessionService,DatabaseSessionServiceandSqliteSessionServiceimplement it.VertexAiSessionServiceraisesNotImplementedError, because the managed Agent Engine Session API exposes no client-set title (same precedent as itsget_user_state).PATCH /apps/{app_name}/users/{user_id}/sessions/{session_id}endpoint accepts an optionaltitle(andstate_deltais now optional), so a title can be set with or without a state change — no new route.Existing-database handling (no schema-version bump)
titleis a nullable, additive column, so this does not bump the DB schema version. Becausemetadata.create_all()never adds a column to an existing table,DatabaseSessionServicegains a small additive column reconciler,_ensure_schema_columns_exist, that mirrors the existing_ensure_schema_indexes_existindex healer — an existing database gains thetitlecolumn in place on the next connect (eachALTERguarded by a SAVEPOINT so concurrent instances don't poison the setup transaction).SqliteSessionServicedoes the same viaALTER TABLE ... ADD COLUMN. Legacy v0 databases are left untouched.Behavior note
Setting a title preserves the session's
update_time— a title is display metadata and must not invalidate an in-flight copy of the session, which would otherwise trip the stale-writer check on the nextappend_event.Tests
update_session_titleround-trip, not-found, and "preserves update_time" tests across all fourSessionServiceTypes (in-memory, in-memory light-copy, database, sqlite).VertexAiSessionServiceraisesNotImplementedError.titlegains the column; a v0 DB is untouched).The full
tests/unittestssuite passes locally (9567 passed);pyink/isort/ruff/ compliance pre-commit checks are clean.Related
title#1340.