Skip to content

aiplatform: GenerateMemories with vertex ai session source fails for hyphenated session IDs #14656

@newtonnthiga

Description

@newtonnthiga

Client

cloud.google.com/go/aiplatform v1.125.0 — SessionClient and MemoryBankClient (google.cloud.aiplatform.v1beta1).

APIs involved:

  • SessionService: CreateSession, GetSession, AppendEvent
  • MemoryBankService: GenerateMemories (VertexSessionSource.session)

Environment

  • Region: europe-west1
  • Endpoint: europe-west1-aiplatform.googleapis.com:443
  • Auth: Application Default Credentials / gcloud auth application-default login
  • Reasoning engine with Memory Bank enabled
$ go version
go version go1.26.1 darwin/arm64

Code and Dependencies

op, err := sessionsClient.CreateSession(ctx, &aiplatformpb.CreateSessionRequest{
	Parent: engine,
	Session: &aiplatformpb.Session{
		DisplayName:  "...",
		UserId:       "...",
	},
	// FAILS at GenerateMemories when SessionId contains "-":
	SessionId: "1241-5274-1831-5378",
	// SUCCEEDS with dash-free id, e.g. SessionId: "7255567233196042880",
	// or omit SessionId to let Vertex assign an id.
})
session, _ := op.Wait(ctx)

_, err = sessionsClient.AppendEvent(ctx, &aiplatformpb.AppendEventRequest{
	Name: session.GetName(),
	Event: &aiplatformpb.SessionEvent{ /* user/model turn */ },
})
// AppendEvent succeeds.

memoryOp, err := memoriesClient.GenerateMemories(ctx, &aiplatformpb.GenerateMemoriesRequest{
	Parent: engine,
	Source: &aiplatformpb.GenerateMemoriesRequest_VertexSessionSource_{
		VertexSessionSource: &aiplatformpb.GenerateMemoriesRequest_VertexSessionSource{
			Session: session.GetName(), // exact name from CreateSession response
		},
	},
})
// GenerateMemories fails when SessionId contained hyphens (see Actual behavior).
go.mod
module my.module.name

go 1.26.1

require (
	cloud.google.com/go/aiplatform v1.125.0
	google.golang.org/api v0.274.0
	google.golang.org/grpc v1.81.1
	google.golang.org/protobuf v1.36.11
)

Expected behavior

CreateSessionRequest documents that a client-supplied session_id may include hyphens:

// 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

(Source: cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb/session_service.pb.go, CreateSessionRequest.)

Given a valid session_id, GetSession, AppendEvent, and GenerateMemories should all resolve the same session.name, including when the final path segment contains hyphens (e.g. a standard UUID from uuid.NewString()).

GenerateMemoriesRequest.VertexSessionSource documents the session field as:

// Format:
// `projects/{project}/locations/{location}/reasoningEngines/{reasoning_engine}/sessions/{session}`
Session string

(Source: memory_bank_service.pb.go, GenerateMemoriesRequest_VertexSessionSource.)

Actual behavior

session_id on CreateSession GetSession / AppendEvent GenerateMemories
Omitted (Vertex auto-assign) OK OK
Client id without hyphens (e.g. 7255567233196042880) OK OK
Client id with hyphens (e.g. 1241-5274-1831-5378 or 10559c82-418d-43fc-8a89-1515fea4837a) OK NOT_FOUND

When GenerateMemories fails, the error reports sessionId: 0 even though the request used the full session.name from the create response (non-zero, hyphenated final segment), for example:

rpc error: code = NotFound desc = Session (projectNumber: 111111111111, reasoningEngineId: 2222222222222222222, sessionId: 0) not found.

Example session.name after create with session_id = "1241-5274-1831-5378":

projects/111111111111/locations/europe-west1/reasoningEngines/2222222222222222222/sessions/1241-5274-1831-5378

Screenshots

Not applicable.

Additional context

Steps to reproduce

  1. CreateSession with session_id containing - (see Code).
  2. AppendEvent on returned session.name — succeeds.
  3. GenerateMemories with vertex_session_source.session = session.name — fails as above.

Workarounds

  1. Omit session_id on create; persist Vertex-assigned id (often numeric, no hyphens).
  2. Use dash-free client ids, e.g. strings.ReplaceAll(uuid.NewString(), "-", "").

Impact

Apps using hyphenated session ids with AddSessionToMemory / GenerateMemories after agent turns see successful runs but memory generation fails.

Metadata

Metadata

Assignees

No one assigned

    Labels

    api: aiplatformIssues related to the AI Platform API.triage meI really want to be triaged.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions