feat: add a Vertex AI-backed SessionService#211
Open
copybara-service[bot] wants to merge 1 commit into
Open
Conversation
Implement `SessionService` against the managed Vertex AI Session Service so agent sessions and events persist in Vertex AI. This ports the Java ADK `VertexAiSessionService` and preserves its observable behavior, so callers can switch session backends without code changes.
- Transport: use a small custom OkHttp-based client instead of a generated SDK client. The service needs only a few REST calls (create/get/list/delete session, list/append events) plus long-running-operation polling on create, so a dedicated client keeps the dependency surface small and the request/response mapping explicit.
- Wire format: map payloads with `@Serializable` DTOs and mapper extensions rather than serializing the domain `Event`/`Content` directly, keeping the domain model decoupled from the wire. The mappers flatten streaming/turn signaling onto `Event` and encode the `State.REMOVED` sentinel as JSON null, which is the state-delta representation the service expects.
- Encode byte fields (`Part.thoughtSignature`, `Blob.data`) as base64 strings to match the proto3-JSON representation of `bytes`. The kotlinx default serializes a `ByteArray` as an array of ints, which the service rejects ("Proto field is not repeating, cannot start list."); that silently dropped model events carrying a thought signature and corrupted session history.
- Follow the Java ADK's semantics: update the in-memory session before the remote append, persist every event (including partial ones), and return list results in server order. Append failures are logged and skipped so one bad event does not abort a run, while read errors (5xx) are surfaced instead of masked as empty results.
- Add unit tests for the service (mocked client) and the mappers (including a base64 wire-format regression test), plus transport tests driving a real client against a `MockWebServer`.
PiperOrigin-RevId: 947644188
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.
feat: add a Vertex AI-backed
SessionServiceImplement
SessionServiceagainst the managed Vertex AI Session Service so agent sessions and events persist in Vertex AI. This ports the Java ADKVertexAiSessionServiceand preserves its observable behavior, so callers can switch session backends without code changes.@SerializableDTOs and mapper extensions rather than serializing the domainEvent/Contentdirectly, keeping the domain model decoupled from the wire. The mappers flatten streaming/turn signaling ontoEventand encode theState.REMOVEDsentinel as JSON null, which is the state-delta representation the service expects.Part.thoughtSignature,Blob.data) as base64 strings to match the proto3-JSON representation ofbytes. The kotlinx default serializes aByteArrayas an array of ints, which the service rejects ("Proto field is not repeating, cannot start list."); that silently dropped model events carrying a thought signature and corrupted session history.MockWebServer.