Agent Platform RAG Engine Management
GoogleOfficialPublished by Google
- Skill
- Tool integration
- Data and AI
- Apache-2.0
- Low risk
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides a structured approach to interacting with the Agent Platform RAG Engine. It enables users to list, inspect, and query RAG corpora, as well as generate grounded responses using the Google GenAI SDK. The skill includes specific safety protocols for read-only operations versus resource-intensive content generation, ensuring proper handling of Google Cloud resources.
What it does
- Lists available RAG corpora and files within a project.
- Retrieves metadata and details for specific RAG corpora.
- Performs similarity-based context retrieval from RAG corpora.
- Generates grounded content using the Google GenAI SDK and RAG tools.
- Provides templates for Python-based interaction with the RAG Engine.
- Enforces safety and confirmation tiers for resource-consuming operations.
When to use it
- When you need to discover or list RAG corpora and files in your Google Cloud project.
- When you need to inspect the configuration or contents of a specific RAG corpus.
- When you need to retrieve relevant context snippets for a specific query.
- When you need to generate AI responses grounded in your own RAG-indexed data.
Advantages
- Standardizes interaction with the Agent Platform RAG Engine.
- Provides clear safety guidelines for read-only versus compute-heavy tasks.
- Includes built-in support for pagination when listing large datasets.
- Facilitates grounded AI responses by integrating directly with the GenAI SDK.
Usage examples
- “List all RAG corpora in my project.”
- The agent executes a Python script using the vertexai SDK to retrieve and display all available RAG corpora names and display names.
- “What files are inside the corpus named 'my-knowledge-base'?”
- The agent lists the files within the specified corpus, identifying their types based on file extensions.
- “Search for information about 'remote work policy' in my RAG corpus.”
- The agent performs a retrieval query against the corpus and returns the relevant context text and source URIs.
- “Generate a summary of the company's remote work policy using my RAG corpus.”
- The agent presents a confirmation prompt detailing the target corpus and model before proceeding to generate the grounded response.
Install
Download the skill as a ZIP:
https://mp-staging.autogineer.com/agent-skills/google/agent-platform-rag-engine-management/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip agent-platform-rag-engine-management.zip -d .agents/skills
Documentation by Google
Agent Platform RAG Engine Management
This skill provides instructions on how to interact with Agent Platform RAG
Engine using the Agent Platform Python SDK. You MUST use the vertexai Python
SDK to perform RAG Engine operations, rather than raw REST calls or MCP tools,
because this code is intended to be run by external clients.
Attribution
MUST READ: Before executing any gcloud, REST API, or MCP command, you MUST
read Usage Attribution. For commands executed
directly in the terminal (never in generated scripts, Terraform, or user code),
prefix gcloud with CLOUDSDK_METRICS_REQUEST_ATTRIBUTION and append the
attribution suffix to User-Agent headers:
CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:agent-platform-rag-engine-management)"
User-Agent: <existing_user_agent> agent-skills/1.0 (skill:agent-platform-rag-engine-management)Safety & Confirmation Tiers (CRITICAL)
Before executing any commands or scripts on behalf of the user, you must adhere to the following safety tiers based on the action requested:
Tier R: Read-only (
list_corpora,list_files,get_corpus,retrieval_query)No confirmation needed. Execute immediately to gather information or retrieve grounded contexts.
Tier RC: Read-only but consumes Compute Resources (
client.models.generate_content)Requires interactive confirmation with 'Yes'/'No' options before executing grounded content generation. The confirmation prompt MUST clearly explain the proposed generation execution and its key parameters (e.g., target corpus ID, query text, target model). Natural-language paraphrases without specifying exact parameters are insufficient, as explicit parameter listing is required to ensure unambiguous user approval of the specific resource and configuration.
Same-turn restriction: Do not execute the generation code in the same turn as presenting the confirmation prompt. Stop and wait for the user's reply; only execute after explicit 'Yes' / approval.
Gold Standard Example:
I will perform grounded content generation with the following parameters. Please confirm this information before I proceed:
Target Corpus ID:
projects/123/locations/us/ragCorpora/abcTarget Model:
gemini-2.5-proQuery Text: "What are the company policies on remote work?"
Do you confirm? [Yes/No]
Phase 0: Environment Setup
CRITICAL: Before running any of the Python snippets below, you must ensure the environment is correctly initialized by following these steps:
Google Cloud Authentication: Authenticate with your Google Cloud credentials and configure active Application Default Credentials (ADC) for Agent Platform access:
gcloud auth login gcloud auth application-default loginPython Dependencies: This skill needs
google-cloud-aiplatformandgoogle-genai, which the sandbox already provides. Do not create a virtual environment — it starts empty and hides packages the environment already provides, forcing a redundant install. Do not spend a separate command checking for them: run the snippet directly, and only if it fails withModuleNotFoundError, install in the same command as the retry:pip install -q google-cloud-aiplatform google-genai && python3 - <<'PY' ... PYExecution: Run each snippet as a quoted heredoc,
python3 - <<'PY'...PY, rather thanpython3 -c '...', whose nested quotes break easily. There is no environment to activate first. When one step needs several of the snippets below (for example, list the corpora and then the files in each), combine them into one script and one command. Thevertexai.preview.ragdeprecation warning printed on stderr is expected; keep using these snippets rather than switching clients because of it.
Workflow Decision Tree
Information Gathering: Has the user provided the Project ID, Region, and Corpus ID?
No -> Proceed to [1. Listing Corpora and Files] to discover the necessary Resource Names and IDs. Only ask the user if discovery fails.
Yes -> Proceed.
Task Type: What does the user want to do?
List Corpora and Files -> Proceed to [1. Listing Corpora and Files].
Inspect a Corpus -> Proceed to [2. Getting / Inspecting a RAG Engine Corpus].
Search for Contexts -> Proceed to [3. Retrieving Contexts].
Answer questions using RAG Engine -> Proceed to [4. Answering the User with Retrieved Context].
[!TIP]
Placeholder Parameter Replacement: The Python scripts below use bracketed string placeholders (like
"{project_id}","{region}", and"{corpus_id}"). You MUST dynamically replace these placeholders with the actual Project ID, Region, and Corpus ID values provided in the user's prompt (or active context) before generating, providing, or executing the scripts.
1. Listing Corpora and Files (Discovery)
If you do not know the Resource Name of the corpus or file, you MUST list them first to discover them. The SDK handles pagination automatically when converted to a list, but you can also use manual pagination for large sets.
1.1 Listing and Discovering Corpora
import vertexai
from vertexai.preview import rag
vertexai.init(project="{project_id}", location="{region}")
# Approach A: List ALL (Automatic Pagination)
# The SDK's Pager iterates through all pages for you.
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}")
# Approach B: Manual Pagination (for very large projects)
pager = rag.list_corpora(page_size=10)
# Process first page
for c in pager:
print(f"Corpus: {c.display_name}")
# Get next page if needed
if pager.next_page_token:
second_page = rag.list_corpora(
page_size=10, page_token=pager.next_page_token
)1.2 Listing and Discovering Files
To understand what files (and types) are in a corpus, list them and inspect the
display_name (usually includes the extension).
import vertexai
from vertexai.preview import rag
vertexai.init(project="{project_id}", location="{region}")
corpus_name = (
"projects/{project_id}/locations/{region}/ragCorpora/{corpus_id}"
)
# List files with automatic pagination
files = list(rag.list_files(corpus_name=corpus_name))
print(f"Found {len(files)} files.")
for f in files:
# High-level SDK RagFile objects usually have name, display_name,
# description
print(f"File: {f.display_name} | Resource: {f.name}")
# Tip: Check extension to understand file type (PDF, TXT, etc.)
if f.display_name.lower().endswith(".pdf"):
print(" Type: PDF")
elif f.display_name.lower().endswith(".txt"):
print(" Type: Plain Text")2. Getting / Inspecting an Agent Platform RAG Engine Corpus
To retrieve details about an existing Agent Platform RAG Engine corpus:
import vertexai
from vertexai.preview import rag
vertexai.init(project="{project_id}", location="{region}")
# To get details of a specific corpus
corpus_name = (
"projects/{project_id}/locations/{region}/ragCorpora/{corpus_id}"
)
corpus = rag.get_corpus(name=corpus_name)
print(f"Corpus Name: {corpus.name}")
print(f"Display Name: {corpus.display_name}")3. Retrieving Contexts
To retrieve relevant contexts from a RAG Engine corpus based on a query. If no
contexts come back, that is a valid answer: report it with the corpus and query
you used. If a broader search is reasonable, try it in the same script (for
example a larger similarity_top_k) rather than as a separate command.
import vertexai
from vertexai.preview import rag
vertexai.init(project="{project_id}", location="{region}")
corpus_name = (
"projects/{project_id}/locations/{region}/ragCorpora/{corpus_id}"
)
query = "What is the speed of light?"
# Retrieve contexts
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. Answering the User with Retrieved Context
To use the retrieved context alongside an Agent Platform model to generate a grounded response:
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}"
)
# Define the Agent Platform RAG Engine tool pointing to the corpus
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,
),
),
)
)
)
# Generate content using the RAG Engine tool
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)Files
- ATTRIBUTION.mdAdded by AutoGineer890 B
- LICENSELicence file added by AutoGineer11.1 KiB
- SKILL.md10.0 KiB
- references/attribution.md1.9 KiB
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs a command-line tool, Needs Python
Security
What our scanner noticed· Low risk
- Instructions that use the network
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Published by
- Publisher
- Google (Official)
- Source
- google/skills · skills/cloud/agent-platform-rag-engine-management · commit 2194d3b
- Licence
- Apache License 2.0 (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by Google.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download agent-platform-rag-engine-management.zip