1
---
2
name: agent-platform-prompt-management
3
metadata:
4
version: "1.0.2"
5
category: AiAndMachineLearning
6
description: >-
7
Manages and orchestrates prompts in Agent Platform. Use when you need to create,
8
list, retrieve, version, or delete managed prompts in Agent Platform. Don't use
9
for model training, model deployment to endpoints, or managing non-Agent Platform
10
prompts.
11
---
12
13
## Attribution
14
15
**MUST READ**: Before executing any `gcloud`, REST API, or MCP command, you MUST
16
read [Usage Attribution](references/attribution.md). For commands executed
17
directly in the terminal (never in generated scripts, Terraform, or user code),
18
prefix `gcloud` with `CLOUDSDK_METRICS_REQUEST_ATTRIBUTION` and append the
19
attribution suffix to `User-Agent` headers:
20
21
```text
22
CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:agent-platform-prompt-management)"
23
User-Agent: <existing_user_agent> agent-skills/1.0 (skill:agent-platform-prompt-management)
24
```
25
26
## Usage Guide
27
28
To use this skill effectively:
29
30
1. **Execute Operations via Python**: Run the Python snippets below using
31
`run_command` in the execution environment to manage prompts in Agent
32
Platform on behalf of the user. Do not delegate execution to the user or
33
claim lack of access once approved.
34
35
2. **No File System Search**: Do not try to find Python files or scripts on the
36
file system for these operations.
37
38
## Safety & Confirmation Tiers (CRITICAL)
39
40
Before executing any commands or scripts on behalf of the user, you must adhere
41
to the following safety tiers based on the action requested, to prevent
42
accidental mutation or permanent deletion of prompt resources:
43
44
1. **Tier R: Read-only (`list`, `get`)**
45
* No confirmation needed. Execute immediately to gather information.
46
2. **Tier M: Mutating & Reversible (`create`)**
47
48
* Requires **interactive confirmation** with 'Yes'/'No' options before
49
executing prompt creation, to prevent unintended resource proliferation
50
or misconfiguration. The confirmation prompt must clearly explain the
51
proposed prompt creation and its key parameters (e.g., display name,
52
template text, target model). Natural-language paraphrases without
53
specifying the parameters are not sufficient.
54
* **Same-turn restriction**: Do not execute the creation code in the same
55
turn as presenting the confirmation prompt. Stop and wait for the user's
56
reply; only execute after explicit 'Yes' / approval.
57
* Every parameter in the card must trace back to something the user said.
58
The target model is a user choice, not a default: if the user did not
59
name one, ASK before building the card. Do not carry over the model that
60
appears in the examples here or in `references/create.md`.
61
* **Gold Standard Example** — for a user who said "create a prompt called
62
Customer Support Greeting for gemini-4-argon with the template Hello
63
{{user_name}}, how can I help...":
64
65
> I will create a prompt in Agent Platform with the following
66
> parameters. Please confirm this information before I proceed:
67
>
68
> * **Display Name**: `Customer Support Greeting`
69
> * **Target Model**: `gemini-4-argon`
70
> * **Template Text**: "Hello {{user_name}}, how can I help..."
71
>
72
> ```python
73
> import vertexai
74
> from google.genai import types as genai_types
75
> from vertexai import types
76
> client = vertexai.Client(project="<PROJECT_ID>", location="<LOCATION_ID>")
77
> prompt = types.Prompt(
78
> prompt_data=types.PromptData(
79
> model="gemini-4-argon",
80
> contents=[
81
> genai_types.Content(
82
> parts=[genai_types.Part(text="Hello {user_name}, how can I help...")],
83
> )
84
> ],
85
> ),
86
> )
87
> created_prompt = client.prompts.create_version(
88
> prompt=prompt,
89
> config=types.CreatePromptVersionConfig(prompt_display_name="Customer Support Greeting"),
90
> )
91
> ```
92
>
93
> Do you confirm? [Yes/No]
94
95
3. **Tier D: Destructive & Irreversible (`delete`)**
96
97
* Requires **explicit typed confirmation** (e.g. "I confirm" or "Yes,
98
delete it") before executing prompt deletion, to prevent accidental
99
permanent loss of production prompt assets. Ask for confirmation before
100
any pre-flight checks.
101
* **Same-turn restriction**: NEVER execute in the same turn as asking for
102
typed confirmation. Wait for the user to reply in a new turn.
103
* **Gold Standard Example**:
104
105
> I will permanently delete the following prompt from Agent Platform.
106
> This action is irreversible. Please explicitly type your confirmation
107
> (e.g., "I confirm") before I proceed:
108
>
109
> * **Prompt ID**: `prompt_12345abc`
110
> * **Display Name**: `Legacy Outdated Prompt`
111
>
112
> Please type your confirmation to proceed.
113
114
## Phase 0: Environment Setup
115
116
**CRITICAL**: Before the user runs any of the Python snippets below, you MUST
117
advise them to ensure the environment is correctly initialized by following
118
these steps:
119
120
1. **Google Cloud Authentication**: Authenticate with your Google Cloud account
121
and configure active Application Default Credentials (ADC) for Agent
122
Platform access:
123
124
```bash
125
gcloud auth login
126
gcloud auth application-default login
127
```
128
129
2. **Python Dependencies**: This skill needs `google-cloud-aiplatform` and
130
`google-genai`. Do **not** create a virtual environment — it starts empty
131
and hides packages the environment already provides, forcing a redundant
132
install. Probe, and install only what is missing:
133
134
```bash
135
python3 -c "import vertexai, google.genai" \
136
|| pip install google-cloud-aiplatform google-genai
137
```
138
139
3. **Execution**: Run Python snippets with a plain `python3`. There is no
140
environment to activate first.
141
142
> [!TIP]
143
>
144
> **Placeholder Parameter Replacement:** The Python scripts below use uppercase
145
> string placeholders (like `"PROJECT_ID"`, `"LOCATION_ID"`, `"PROMPT_ID"`, and
146
> `"MODEL_ID"`). You **MUST** dynamically replace these placeholders with the
147
> actual Project ID, Region, Prompt ID, and target model values provided in the
148
> user's prompt (or discovered context) before generating or providing the
149
> scripts. If the user did not supply one of these, ask -- a placeholder is
150
> never satisfied by guessing a plausible value.
151
152
## 1. Managing Prompts via Agent Platform SDK
153
154
The SDK manages prompts via `client.prompts` on `vertexai.Client` and
155
`vertexai.types.Prompt`.
156
157
### Create a Prompt (Tier M)
158
159
Use when you need to create a new managed prompt in Agent Platform.
160
161
* **Reference**: See [create.md](references/create.md) for detailed
162
instructions and Python snippets.
163
164
### List Prompts (Tier R)
165
166
```python
167
import vertexai
168
169
client = vertexai.Client(project="PROJECT_ID", location="LOCATION_ID")
170
171
all_prompts = list(client.prompts.list())
172
for p in all_prompts:
173
prompt_res = client.prompts.get(prompt_id=p.prompt_id)
174
display_name = prompt_res.dataset.display_name if prompt_res.dataset else None
175
print(f"Name: {display_name}, Model: {p.model}, ID: {p.prompt_id}")
176
```
177
178
### Retrieve and Use a Prompt (Tier R)
179
180
```python
181
import vertexai
182
from google.genai import types as genai_types
183
184
client = vertexai.Client(project="PROJECT_ID", location="LOCATION_ID")
185
186
retrieved_prompt = client.prompts.get(prompt_id="PROMPT_ID")
187
# Versions are supported via: client.prompts.get_version(prompt_id="PROMPT_ID", version_id="2")
188
189
# Populate template variables (if any) via prompt_data.variables before assembling
190
retrieved_prompt.prompt_data.variables = [
191
{"text": genai_types.Part(text="The quick brown fox...")}
192
]
193
assembled = retrieved_prompt.assemble_contents()
194
print(assembled)
195
```
196
197
### Delete a Prompt (Tier D)
198
199
**CRITICAL**: You must pass the numeric prompt ID (e.g.,
200
`"1234567890123456789"`) to `client.prompts.delete()`.
201
202
**Confirmation Required**: As a Tier D (Destructive) operation, the agent MUST
203
pause and request explicit, high-friction typed re-confirmation of the prompt ID
204
from the user before executing the deletion code. The action is irreversible.
205
Once the user replies with typed confirmation (e.g., "I confirm"), proceed
206
immediately to execute the deletion code via `run_command`.
207
208
> [!IMPORTANT]
209
>
210
> **NEVER pre-emptively execute any deletion code before receiving the user's
211
> response in a new turn.** You must never speculate or assume that confirmation
212
> will be given. Asking for confirmation and running the code in a single
213
> parallel turn is a severe safety violation.
214
215
```python
216
import vertexai
217
218
client = vertexai.Client(project="PROJECT_ID", location="LOCATION_ID")
219
220
client.prompts.delete(prompt_id="PROMPT_ID")
221
```
222
223
### Verification After Deletion
224
225
Whenever listing prompts or verifying state after deleting a prompt in the same
226
conversation, you **MUST**:
227
228
1. Check in Python whether the deleted `prompt_id` appears in
229
`client.prompts.list()`.
230
2. In your prose reply (even when the list is also shown as a card):
231
* If it is not found, explicitly confirm: *"I have verified that the
232
deleted prompt (ID: `<PROMPT_ID>`) is no longer present in project
233
`<PROJECT_ID>` (`<LOCATION_ID>`)."*
234
* If it is still listed, report its current presence and ID to the user.
235
236
## 2. Best Practices
237
238
- **Idempotency**:
239
* **Tier R** (List, Get): Inherently idempotent.
240
* **Tier D** (Delete): Re-running a delete on a non-existent or already
241
deleted resource returns NOT_FOUND. Treat this as success.
242
- **Placeholders**: Use the standard placeholder syntax (variable name
243
enclosed in double curly braces) in your prompt templates.
244
- **Versioning**: Always tag or record version IDs when making updates to
245
production prompts.
246
- **Model Reference**: A prompt is created against a target model ID, which
247
the snippets carry as the `"MODEL_ID"` placeholder. Like the other
248
placeholders it is MUST-replace, and it is replaced from what the user
249
said -- if they named no model, ask. Do not substitute a plausible current
250
model such as `gemini-4-argon`.
251
- **Underlying Schema**: When using the Dataset API, always use the correct
252
`metadata_schema_uri` and nested `metadata` structure to ensure the prompt
253
is recognized by Agent Platform Studio and the Prompts SDK.
254