From a82e8884fe16be152eca67dd82b29e8657517971 Mon Sep 17 00:00:00 2001 From: A Vertex SDK engineer Date: Mon, 30 Mar 2026 14:42:06 -0700 Subject: [PATCH] feat: Add custom session id functionality to vertex ai session service PiperOrigin-RevId: 891919371 --- src/genai/converters/_sessions_converters.ts | 10 ++++++++++ src/genai/types/common.ts | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/src/genai/converters/_sessions_converters.ts b/src/genai/converters/_sessions_converters.ts index 05040e32..ddce8c31 100644 --- a/src/genai/converters/_sessions_converters.ts +++ b/src/genai/converters/_sessions_converters.ts @@ -41,6 +41,11 @@ export function createAgentEngineSessionConfigToVertex( common.setValueByPath(parentObject, ['labels'], fromLabels); } + const fromSessionId = common.getValueByPath(fromObject, ['sessionId']); + if (parentObject !== undefined && fromSessionId != null) { + common.setValueByPath(parentObject, ['_query', 'sessionId'], fromSessionId); + } + return toObject; } @@ -185,6 +190,11 @@ export function updateAgentEngineSessionConfigToVertex( common.setValueByPath(parentObject, ['labels'], fromLabels); } + const fromSessionId = common.getValueByPath(fromObject, ['sessionId']); + if (parentObject !== undefined && fromSessionId != null) { + common.setValueByPath(parentObject, ['_query', 'sessionId'], fromSessionId); + } + const fromUpdateMask = common.getValueByPath(fromObject, ['updateMask']); if (parentObject !== undefined && fromUpdateMask != null) { common.setValueByPath( diff --git a/src/genai/types/common.ts b/src/genai/types/common.ts index 7abd97d1..8d223f48 100644 --- a/src/genai/types/common.ts +++ b/src/genai/types/common.ts @@ -1865,6 +1865,8 @@ export declare interface CreateAgentEngineSessionConfig { expireTime?: string; /** Optional. The labels with user-defined metadata to organize your Sessions. Label keys and values can be no longer than 64 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. See https://goo.gl/xmQnxf for more information and examples of labels. */ labels?: Record; + /** Optional. The user defined ID to use for session, which will become the final component of the session resource name. If not provided, Vertex AI will generate a value for this ID. This value may be up to 63 characters, and valid characters are `[a-z0-9-]`. The first character must be a letter, and the last character must be a letter or number. */ + sessionId?: string; } /** Parameters for creating Agent Engine Sessions. */ @@ -2031,6 +2033,8 @@ export declare interface UpdateAgentEngineSessionConfig { expireTime?: string; /** Optional. The labels with user-defined metadata to organize your Sessions. Label keys and values can be no longer than 64 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. See https://goo.gl/xmQnxf for more information and examples of labels. */ labels?: Record; + /** Optional. The user defined ID to use for session, which will become the final component of the session resource name. If not provided, Vertex AI will generate a value for this ID. This value may be up to 63 characters, and valid characters are `[a-z0-9-]`. The first character must be a letter, and the last character must be a letter or number. */ + sessionId?: string; /** The update mask to apply. For the `FieldMask` definition, see https://protobuf.dev/reference/protobuf/google.protobuf/#field-mask. */ updateMask?: string;