From 2beb6a359d9df6062d009684b255b52dfaa06e3a Mon Sep 17 00:00:00 2001 From: chrischristiansen-glitch Date: Sun, 24 May 2026 19:04:31 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20drop=20backend=5Fconfig=20from=20create?= =?UTF-8?q?=5Fcorpus=20=E2=80=94=20rely=20on=20pre-flight=20PATCH=20alone?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SDK 1.153.1 has a bug in set_backend_config where it calls .CopyFrom() on RagManagedDb which is not a real protobuf message. The project-level ragEngineConfig PATCH already sets basic tier, so passing backend_config is unnecessary and breaks corpus creation. --- agents/rag/setup_corpus.py | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/agents/rag/setup_corpus.py b/agents/rag/setup_corpus.py index 7142201..d64f130 100644 --- a/agents/rag/setup_corpus.py +++ b/agents/rag/setup_corpus.py @@ -3,12 +3,9 @@ setup_corpus.py — Create a Vertex AI RAG Engine corpus and import documents. Project: propane-will-491900-m5 -Explicitly uses Serverless (RagManagedDb) to avoid Spanner allowlist -restrictions on new projects in us-central1. - -Tested against vertexai SDK 1.153.1: - RagVectorDbConfig(vector_db=RagManagedDb()) - RagManagedDb is a no-arg marker class — selecting it is sufficient for serverless. +Serverless mode is controlled via the project-level ragEngineConfig PATCH +(ensure_serverless_engine_config). Passing backend_config to create_corpus +triggers a SDK 1.153.1 bug and must be omitted. """ import os @@ -31,7 +28,8 @@ GCS_SOURCE = os.environ.get( def ensure_serverless_engine_config() -> None: """ Pre-flight: set project-level RAG Engine Config to basic (serverless) tier. - Idempotent — safe to re-run. + This is what actually controls the backend — backend_config in create_corpus + is intentionally omitted due to SDK bug in 1.153.1. """ print("Ensuring RAG Engine Config is set to serverless (basic) tier...") endpoint = ( @@ -71,21 +69,17 @@ def ensure_serverless_engine_config() -> None: def get_or_create_corpus() -> RagCorpus: - """Return existing corpus by display name, or create a new serverless one.""" + """Return existing corpus by display name, or create a new one.""" for c in rag.list_corpora(): if c.display_name == CORPUS_DISPLAY_NAME: print(f"Corpus '{CORPUS_DISPLAY_NAME}' already exists: {c.name}") return c - print(f"Creating corpus '{CORPUS_DISPLAY_NAME}' in {LOCATION} (serverless)...") - corpus = rag.create_corpus( - display_name=CORPUS_DISPLAY_NAME, - # RagManagedDb() is a no-arg marker class in SDK 1.153.1 - # Selecting it routes to serverless managed DB (basic tier) - backend_config=rag.RagVectorDbConfig( - vector_db=rag.RagManagedDb() - ), - ) + print(f"Creating corpus '{CORPUS_DISPLAY_NAME}' in {LOCATION}...") + # NOTE: backend_config is intentionally omitted. + # SDK 1.153.1 has a bug where passing any backend_config crashes. + # Serverless mode is already guaranteed by ensure_serverless_engine_config(). + corpus = rag.create_corpus(display_name=CORPUS_DISPLAY_NAME) print(f"✓ Corpus created: {corpus.name}") return corpus