agent-platform-rag-engine-management: Manage Google Agent Platform RAG Engine with Agent Skill

Introduction

Building Q&A and knowledge base assistants in enterprises typically involves ingesting documents into a RAG corpus, checking available corpora, listing files within them, verifying if retrieval snippets match, and finally using a model for grounded generation. These steps are often scattered across the Vertex AI SDK, resource name rules, and GenAI calls, making it easy for Agents to mistype projects/.../ragCorpora/... or mix up inappropriate APIs.

Below is an introduction to the agent-platform-rag-engine-management Skill (current metadata version 1.0.1) from Google’s official repository. It defines a fixed workflow for “discovering corpora → viewing details → retrieving context → optional grounded generation” and mandates the use of the vertexai Python SDK instead of raw REST or MCP.

What is this

  • Positioning: Manages and queries Agent Platform RAG Engine Corpora, retrieves grounding content using the Google GenAI SDK, and generates grounded answers on specified corpora.
  • Maintainer: Google, included in the AI/ML category of Skills in the google/skills repository.
  • Target Audience: Developers already using Agent Platform RAG Engine on Google Cloud who want coding Agents to perform operations and retrieval according to official steps.
  • Explicitly Not Covered: Standard database queries (should use SQL/Spanner related Skills), Google Workspace RAG, and other RAG products like gRAG.

The Skill description states: Operations should be performed by external clients; therefore, RAG Engine related calls must be completed via the Agent Platform Python SDK (vertexai).

Core Functions

The Skill organizes capabilities by task type, consistent with the official description:

Capability Typical SDK Entry Point Description
List Corpora rag.list_corpora() Supports auto-pagination or manual page_token
List Files in Corpus rag.list_files(corpus_name=...) Can identify PDF, TXT, etc. via display_name
View Corpus Details rag.get_corpus(name=...) Requires the full corpus resource name
Retrieve Context rag.retrieval_query(...) Read-only; must truthfully report corpus and query even if no results
Grounded Generation client.models.generate_content + RAG Tool Consumes compute; Skill requires user confirmation first

Workflow decision: If the user does not provide Project ID, Region, or Corpus ID, perform “list corpora / files” for discovery first; if IDs are known, proceed directly to the corresponding section based on the task. The placeholders {project_id}, {region}, and {corpus_id} in the scripts must be replaced with real values before execution.

Security & Confirmation Tiers (Mandatory for Agents)

The official documentation divides operations into two tiers, which the Agent must align with before execution:

  1. Tier R (Read-only): list_corpora, list_files, get_corpus, retrieval_query — No confirmation needed, can be executed directly.
  2. Tier RC (Read-only but consumes compute): Grounded generation via client.models.generate_content — Must perform interactive confirmation (Yes/No) first. Must list exact parameters such as Target Corpus ID, Target Model, Query Text; must not pop a confirmation and execute immediately in the same turn; must wait for explicit user consent before running the code.

Installation & Activation

The Skill is distributed via the official Google Skills repository. Installation follows the repository README:

npx skills add google/skills

Follow the prompts to select the Skill to install (can select only Agent Platform RAG Engine Management), the target Agent, and the scope (project or global). If npx is not available in the environment, Node.js must be installed first. To update installed Skills:

npx skills update

Skill source directory:

https://github.com/google/skills/tree/main/skills/cloud/agent-platform-rag-engine-management

This article does not verify the specific Skill mounting differences for Cursor, Codex CLI, or Claude Code; it relies solely on npx skills add.

Environment Preparation (Phase 0)

Before running the Python snippets in the Skill, prepare authentication and dependencies.

1. Google Cloud Authentication (Configure Application Default Credentials):

gcloud auth login
gcloud auth application-default login

2. Python Dependencies: Requires google-cloud-aiplatform and google-genai. The Skill suggests running scripts directly; if a ModuleNotFoundError occurs, install and retry in the same command:

pip install -q google-cloud-aiplatform google-genai && python3 - <<'PY'
# Your script
PY

3. Execution Method: Recommended to use python3 - <<'PY' ... PY heredoc to avoid python3 -c quote nesting issues. Multi-step operations (e.g., listing corpora then listing files) should be combined into a single script and a single command. Deprecation warnings for vertexai.preview.rag on stderr can be ignored; continue using the preview API as shown in the Skill.

Typical Usage

Initialization & Corpus Resource Names

All examples start with vertexai.init(project="{project_id}", location="{region}"). The resource name format for a single corpus is:

projects/{project_id}/locations/{region}/ragCorpora/{corpus_id}

1. Discover Corpora and Files

When the Resource Name of a corpus or file is unknown, listing must be performed first. Auto-pagination example:

import vertexai
from vertexai.preview import rag

vertexai.init(project="{project_id}", location="{region}")

all_corpora = list(rag.list_corpora())
print(f"Found {len(all_corpora)} corpora in total.")
for c in all_corpora:
    print(f"Corpus Name: {c.name} | Display Name: {c.display_name}")

Listing files for a specific corpus:

corpus_name = (
    "projects/{project_id}/locations/{region}/ragCorpora/{corpus_id}"
)
files = list(rag.list_files(corpus_name=corpus_name))
for f in files:
    print(f"File: {f.display_name} | Resource: {f.name}")

2. View Corpus Details

corpus = rag.get_corpus(name=corpus_name)
print(f"Corpus Name: {corpus.name}")
print(f"Display Name: {corpus.display_name}")

3. Retrieve Context (Do not call generation model)

Retrieve relevant snippets from the corpus based on a natural language query; if there are no matches, explain the corpus and query used to the user. You can try increasing similarity_top_k within the same script:

response = rag.retrieval_query(
    rag_corpora=[corpus_name],
    text=query,
    similarity_top_k=3,
)

for context in response.contexts.contexts:
    print(f"Context text: {context.text}")
    print(f"Source: {context.source_uri}")

4. Grounded Generation based on Corpus

Use the google.genai client, configure the RAG Engine corpus as a VertexRagStore tool, and then call generate_content. This step belongs to Tier RC; the Agent must complete parameter confirmation according to the Skill requirements before executing in the next turn:

from google import genai
from google.genai import types

client = genai.Client(enterprise=True, project="{project_id}", location="{region}")
corpus_name = (
    "projects/{project_id}/locations/{region}/ragCorpora/{corpus_id}"
)

rag_tool = types.Tool(
    retrieval=types.Retrieval(
        vertex_rag_store=types.VertexRagStore(
            rag_resources=[types.VertexRagStoreRagResource(rag_corpus=corpus_name)],
            rag_retrieval_config=types.RagRetrievalConfig(
                top_k=3,
                filter=types.RagRetrievalConfigFilter(
                    vector_similarity_threshold=0.5,
                ),
            ),
        )
    )
)

response = client.models.generate_content(
    model="gemini-2.5-flash",
    contents="What is the speed of light?",
    config=types.GenerateContentConfig(tools=[rag_tool]),
)
print(response.text)

The model name in the official example is gemini-2.5-flash; the Skill example uses gemini-2.5-pro as an instruction template for generation confirmation, but the actual model depends on your confirmation.

Scenarios & Notes

Who is it for

  • Those who have created RAG Engine corpora on Agent Platform and need Agents to assist with resource discovery, file inventory, retrieval spot-checks, and grounded Q&A prototyping.
  • Those who want to unify the workflow via vertexai.preview.rag + GenAI SDK to prevent Agents from piecing together REST calls or misusing Skills for other RAG products.

Limitations & Pitfalls

  • Depends on a valid GCP project, region, and IAM; scripts will fail authentication if ADC is not configured.
  • Grounded generation incurs inference costs; the Skill enforces double confirmation, and humans should also verify the corpus and query to avoid misusing production corpora.
  • Do not use this Skill to replace Spanner/SQL, Workspace RAG, or gRAG scenarios.
  • If the Sandbox comes with the above Python packages, the Skill explicitly suggests not creating a new empty virtual environment to ensure pre-installed dependencies are visible.

Conclusion

agent-platform-rag-engine-management converges the listing, inspection, retrieval, and grounded generation of Agent Platform RAG Engine into reproducible SDK steps, distinguishing between read-only and compute-consuming operations. If you are using Google Cloud Enterprise Agents and RAG Engine, you can install it via the official Skills and let the Agent execute according to the instructions.

Official URL: https://github.com/google/skills/tree/main/skills/cloud/agent-platform-rag-engine-management

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye