Tool: update_guardrail
Updates the specified guardrail. Make sure to always pass an update mask in the input.
The following sample demonstrate how to use curl to invoke the update_guardrail MCP tool.
| Curl Request |
|---|
curl --location 'https://ces.[REGION].rep.googleapis.com/mcp' \ --header 'content-type: application/json' \ --header 'accept: application/json, text/event-stream' \ --data '{ "method": "tools/call", "params": { "name": "update_guardrail", "arguments": { // provide these details according to the tool's MCP specification } }, "jsonrpc": "2.0", "id": 1 }' |
Input Schema
Request message for AgentService.UpdateGuardrail.
UpdateGuardrailRequest
| JSON representation |
|---|
{
"guardrail": {
object ( |
| Fields | |
|---|---|
guardrail |
Required. The guardrail to update. |
updateMask |
Optional. Field mask is used to control which fields get updated. If the mask is not present, all fields will be updated. This is a comma-separated list of fully qualified names of fields. Example: |
Guardrail
| JSON representation |
|---|
{ "name": string, "displayName": string, "description": string, "enabled": boolean, "action": { object ( |
| Fields | |
|---|---|
name |
Identifier. The unique identifier of the guardrail. Format: |
displayName |
Required. Display name of the guardrail. |
description |
Optional. Description of the guardrail. |
enabled |
Optional. Whether the guardrail is enabled. |
action |
Optional. Action to take when the guardrail is triggered. |
createTime |
Output only. Timestamp when the guardrail was created. Uses RFC 3339, where generated output will always be Z-normalized and use 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted. Examples: |
updateTime |
Output only. Timestamp when the guardrail was last updated. Uses RFC 3339, where generated output will always be Z-normalized and use 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted. Examples: |
etag |
Etag used to ensure the object hasn't changed during a read-modify-write operation. If the etag is empty, the update will overwrite any concurrent changes. |
Union field guardrail_type. Guardrail type. guardrail_type can be only one of the following: |
|
contentFilter |
Optional. Guardrail that bans certain content from being used in the conversation. |
llmPromptSecurity |
Optional. Guardrail that blocks the conversation if the prompt is considered unsafe based on the LLM classification. |
llmPolicy |
Optional. Guardrail that blocks the conversation if the LLM response is considered violating the policy based on the LLM classification. |
modelSafety |
Optional. Guardrail that blocks the conversation if the LLM response is considered unsafe based on the model safety settings. |
codeCallback |
Optional. Guardrail that potentially blocks the conversation based on the result of the callback execution. |
ContentFilter
| JSON representation |
|---|
{
"bannedContents": [
string
],
"bannedContentsInUserInput": [
string
],
"bannedContentsInAgentResponse": [
string
],
"matchType": enum ( |
| Fields | |
|---|---|
bannedContents[] |
Optional. List of banned phrases. Applies to both user inputs and agent responses. |
bannedContentsInUserInput[] |
Optional. List of banned phrases. Applies only to user inputs. |
bannedContentsInAgentResponse[] |
Optional. List of banned phrases. Applies only to agent responses. |
matchType |
Required. Match type for the content filter. |
disregardDiacritics |
Optional. If true, diacritics are ignored during matching. |
LlmPromptSecurity
| JSON representation |
|---|
{ "failOpen": boolean, // Union field |
| Fields | |
|---|---|
failOpen |
Optional. Determines the behavior when the guardrail encounters an LLM error. - If true: the guardrail is bypassed. - If false (default): the guardrail triggers/blocks. Note: If a custom policy is provided, this field is ignored in favor of the policy's 'fail_open' configuration. |
Union field security_config. Defines the security configuration mode. The user must choose one of the following configurations. security_config can be only one of the following: |
|
defaultSettings |
Optional. Use the system's predefined default security settings. To select this mode, include an empty 'default_settings' message in the request. The 'default_prompt_template' field within will be populated by the server in the response. |
customPolicy |
Optional. Use a user-defined LlmPolicy to configure the security guardrail. |
DefaultSecuritySettings
| JSON representation |
|---|
{ "defaultPromptTemplate": string } |
| Fields | |
|---|---|
defaultPromptTemplate |
Output only. The default prompt template used by the system. This field is for display purposes to show the user what prompt the system uses by default. It is OUTPUT_ONLY. |
LlmPolicy
| JSON representation |
|---|
{ "maxConversationMessages": integer, "modelSettings": { object ( |
| Fields | |
|---|---|
maxConversationMessages |
Optional. When checking this policy, consider the last 'n' messages in the conversation. When not set a default value of 10 will be used. |
modelSettings |
Optional. Model settings. |
prompt |
Required. Policy prompt. |
policyScope |
Required. Defines when to apply the policy check during the conversation. If set to |
failOpen |
Optional. If an error occurs during the policy check, fail open and do not trigger the guardrail. |
allowShortUtterance |
Optional. By default, the LLM policy check is bypassed for short utterances. Enabling this setting applies the policy check to all utterances, including those that would normally be skipped. |
ModelSettings
| JSON representation |
|---|
{ "model": string, // Union field |
| Fields | |
|---|---|
model |
Optional. The LLM model that the agent should use. If not set, the agent will inherit the model from its parent agent. |
Union field
|
|
temperature |
Optional. If set, this temperature will be used for the LLM model. Temperature controls the randomness of the model's responses. Lower temperatures produce responses that are more predictable. Higher temperatures produce responses that are more creative. |
ModelSafety
| JSON representation |
|---|
{
"safetySettings": [
{
object ( |
| Fields | |
|---|---|
safetySettings[] |
Required. List of safety settings. |
SafetySetting
| JSON representation |
|---|
{ "category": enum ( |
| Fields | |
|---|---|
category |
Required. The harm category. |
threshold |
Required. The harm block threshold. |
CodeCallback
| JSON representation |
|---|
{ "beforeAgentCallback": { object ( |
| Fields | |
|---|---|
beforeAgentCallback |
Optional. The callback to execute before the agent is called. Each callback function is expected to return a structure (e.g., a dict or object) containing at least: - 'decision': Either 'OK' or 'TRIGGER'. - 'reason': A string explaining the decision. A 'TRIGGER' decision may halt further processing. |
afterAgentCallback |
Optional. The callback to execute after the agent is called. Each callback function is expected to return a structure (e.g., a dict or object) containing at least: - 'decision': Either 'OK' or 'TRIGGER'. - 'reason': A string explaining the decision. A 'TRIGGER' decision may halt further processing. |
beforeModelCallback |
Optional. The callback to execute before the model is called. If there are multiple calls to the model, the callback will be executed multiple times. Each callback function is expected to return a structure (e.g., a dict or object) containing at least: - 'decision': Either 'OK' or 'TRIGGER'. - 'reason': A string explaining the decision. A 'TRIGGER' decision may halt further processing. |
afterModelCallback |
Optional. The callback to execute after the model is called. If there are multiple calls to the model, the callback will be executed multiple times. Each callback function is expected to return a structure (e.g., a dict or object) containing at least: - 'decision': Either 'OK' or 'TRIGGER'. - 'reason': A string explaining the decision. A 'TRIGGER' decision may halt further processing. |
Callback
| JSON representation |
|---|
{ "description": string, "disabled": boolean, "proactiveExecutionEnabled": boolean, // Union field |
| Fields | |
|---|---|
description |
Optional. Human-readable description of the callback. |
disabled |
Optional. Whether the callback is disabled. Disabled callbacks are ignored by the agent. |
proactiveExecutionEnabled |
Optional. If enabled, the callback will also be executed on intermediate model outputs. This setting only affects after model callback. ENABLE WITH CAUTION. Typically after model callback only needs to be executed after receiving all model responses. Enabling proactive execution may have negative implication on the execution cost and latency, and should only be enabled in rare situations. |
Union field callback. The callback to execute. callback can be only one of the following: |
|
pythonCode |
Required. The python code to execute for the callback. |
TriggerAction
| JSON representation |
|---|
{ // Union field |
| Fields | |
|---|---|
Union field action. The action to take. action can be only one of the following: |
|
respondImmediately |
Optional. Immediately respond with a preconfigured response. |
transferAgent |
Optional. Transfer the conversation to a different agent. |
generativeAnswer |
Optional. Respond with a generative answer. |
RespondImmediately
| JSON representation |
|---|
{
"responses": [
{
object ( |
| Fields | |
|---|---|
responses[] |
Required. The canned responses for the agent to choose from. The response is chosen randomly. |
Response
| JSON representation |
|---|
{ "text": string, "disabled": boolean } |
| Fields | |
|---|---|
text |
Required. Text for the agent to respond with. |
disabled |
Optional. Whether the response is disabled. Disabled responses are not used by the agent. |
TransferAgent
| JSON representation |
|---|
{ "agent": string } |
| Fields | |
|---|---|
agent |
Required. The name of the agent to transfer the conversation to. The agent must be in the same app as the current agent. Format: |
GenerativeAnswer
| JSON representation |
|---|
{ "prompt": string } |
| Fields | |
|---|---|
prompt |
Required. The prompt to use for the generative answer. |
Timestamp
| JSON representation |
|---|
{ "seconds": string, "nanos": integer } |
| Fields | |
|---|---|
seconds |
Represents seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z. Must be between -62135596800 and 253402300799 inclusive (which corresponds to 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z). |
nanos |
Non-negative fractions of a second at nanosecond resolution. This field is the nanosecond portion of the duration, not an alternative to seconds. Negative second values with fractions must still have non-negative nanos values that count forward in time. Must be between 0 and 999,999,999 inclusive. |
FieldMask
| JSON representation |
|---|
{ "paths": [ string ] } |
| Fields | |
|---|---|
paths[] |
The set of field mask paths. |
Output Schema
Guardrail contains a list of checks and balances to keep the agents safe and secure.
Guardrail
| JSON representation |
|---|
{ "name": string, "displayName": string, "description": string, "enabled": boolean, "action": { object ( |
| Fields | |
|---|---|
name |
Identifier. The unique identifier of the guardrail. Format: |
displayName |
Required. Display name of the guardrail. |
description |
Optional. Description of the guardrail. |
enabled |
Optional. Whether the guardrail is enabled. |
action |
Optional. Action to take when the guardrail is triggered. |
createTime |
Output only. Timestamp when the guardrail was created. Uses RFC 3339, where generated output will always be Z-normalized and use 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted. Examples: |
updateTime |
Output only. Timestamp when the guardrail was last updated. Uses RFC 3339, where generated output will always be Z-normalized and use 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted. Examples: |
etag |
Etag used to ensure the object hasn't changed during a read-modify-write operation. If the etag is empty, the update will overwrite any concurrent changes. |
Union field guardrail_type. Guardrail type. guardrail_type can be only one of the following: |
|
contentFilter |
Optional. Guardrail that bans certain content from being used in the conversation. |
llmPromptSecurity |
Optional. Guardrail that blocks the conversation if the prompt is considered unsafe based on the LLM classification. |
llmPolicy |
Optional. Guardrail that blocks the conversation if the LLM response is considered violating the policy based on the LLM classification. |
modelSafety |
Optional. Guardrail that blocks the conversation if the LLM response is considered unsafe based on the model safety settings. |
codeCallback |
Optional. Guardrail that potentially blocks the conversation based on the result of the callback execution. |
ContentFilter
| JSON representation |
|---|
{
"bannedContents": [
string
],
"bannedContentsInUserInput": [
string
],
"bannedContentsInAgentResponse": [
string
],
"matchType": enum ( |
| Fields | |
|---|---|
bannedContents[] |
Optional. List of banned phrases. Applies to both user inputs and agent responses. |
bannedContentsInUserInput[] |
Optional. List of banned phrases. Applies only to user inputs. |
bannedContentsInAgentResponse[] |
Optional. List of banned phrases. Applies only to agent responses. |
matchType |
Required. Match type for the content filter. |
disregardDiacritics |
Optional. If true, diacritics are ignored during matching. |
LlmPromptSecurity
| JSON representation |
|---|
{ "failOpen": boolean, // Union field |
| Fields | |
|---|---|
failOpen |
Optional. Determines the behavior when the guardrail encounters an LLM error. - If true: the guardrail is bypassed. - If false (default): the guardrail triggers/blocks. Note: If a custom policy is provided, this field is ignored in favor of the policy's 'fail_open' configuration. |
Union field security_config. Defines the security configuration mode. The user must choose one of the following configurations. security_config can be only one of the following: |
|
defaultSettings |
Optional. Use the system's predefined default security settings. To select this mode, include an empty 'default_settings' message in the request. The 'default_prompt_template' field within will be populated by the server in the response. |
customPolicy |
Optional. Use a user-defined LlmPolicy to configure the security guardrail. |
DefaultSecuritySettings
| JSON representation |
|---|
{ "defaultPromptTemplate": string } |
| Fields | |
|---|---|
defaultPromptTemplate |
Output only. The default prompt template used by the system. This field is for display purposes to show the user what prompt the system uses by default. It is OUTPUT_ONLY. |
LlmPolicy
| JSON representation |
|---|
{ "maxConversationMessages": integer, "modelSettings": { object ( |
| Fields | |
|---|---|
maxConversationMessages |
Optional. When checking this policy, consider the last 'n' messages in the conversation. When not set a default value of 10 will be used. |
modelSettings |
Optional. Model settings. |
prompt |
Required. Policy prompt. |
policyScope |
Required. Defines when to apply the policy check during the conversation. If set to |
failOpen |
Optional. If an error occurs during the policy check, fail open and do not trigger the guardrail. |
allowShortUtterance |
Optional. By default, the LLM policy check is bypassed for short utterances. Enabling this setting applies the policy check to all utterances, including those that would normally be skipped. |
ModelSettings
| JSON representation |
|---|
{ "model": string, // Union field |
| Fields | |
|---|---|
model |
Optional. The LLM model that the agent should use. If not set, the agent will inherit the model from its parent agent. |
Union field
|
|
temperature |
Optional. If set, this temperature will be used for the LLM model. Temperature controls the randomness of the model's responses. Lower temperatures produce responses that are more predictable. Higher temperatures produce responses that are more creative. |
ModelSafety
| JSON representation |
|---|
{
"safetySettings": [
{
object ( |
| Fields | |
|---|---|
safetySettings[] |
Required. List of safety settings. |
SafetySetting
| JSON representation |
|---|
{ "category": enum ( |
| Fields | |
|---|---|
category |
Required. The harm category. |
threshold |
Required. The harm block threshold. |
CodeCallback
| JSON representation |
|---|
{ "beforeAgentCallback": { object ( |
| Fields | |
|---|---|
beforeAgentCallback |
Optional. The callback to execute before the agent is called. Each callback function is expected to return a structure (e.g., a dict or object) containing at least: - 'decision': Either 'OK' or 'TRIGGER'. - 'reason': A string explaining the decision. A 'TRIGGER' decision may halt further processing. |
afterAgentCallback |
Optional. The callback to execute after the agent is called. Each callback function is expected to return a structure (e.g., a dict or object) containing at least: - 'decision': Either 'OK' or 'TRIGGER'. - 'reason': A string explaining the decision. A 'TRIGGER' decision may halt further processing. |
beforeModelCallback |
Optional. The callback to execute before the model is called. If there are multiple calls to the model, the callback will be executed multiple times. Each callback function is expected to return a structure (e.g., a dict or object) containing at least: - 'decision': Either 'OK' or 'TRIGGER'. - 'reason': A string explaining the decision. A 'TRIGGER' decision may halt further processing. |
afterModelCallback |
Optional. The callback to execute after the model is called. If there are multiple calls to the model, the callback will be executed multiple times. Each callback function is expected to return a structure (e.g., a dict or object) containing at least: - 'decision': Either 'OK' or 'TRIGGER'. - 'reason': A string explaining the decision. A 'TRIGGER' decision may halt further processing. |
Callback
| JSON representation |
|---|
{ "description": string, "disabled": boolean, "proactiveExecutionEnabled": boolean, // Union field |
| Fields | |
|---|---|
description |
Optional. Human-readable description of the callback. |
disabled |
Optional. Whether the callback is disabled. Disabled callbacks are ignored by the agent. |
proactiveExecutionEnabled |
Optional. If enabled, the callback will also be executed on intermediate model outputs. This setting only affects after model callback. ENABLE WITH CAUTION. Typically after model callback only needs to be executed after receiving all model responses. Enabling proactive execution may have negative implication on the execution cost and latency, and should only be enabled in rare situations. |
Union field callback. The callback to execute. callback can be only one of the following: |
|
pythonCode |
Required. The python code to execute for the callback. |
TriggerAction
| JSON representation |
|---|
{ // Union field |
| Fields | |
|---|---|
Union field action. The action to take. action can be only one of the following: |
|
respondImmediately |
Optional. Immediately respond with a preconfigured response. |
transferAgent |
Optional. Transfer the conversation to a different agent. |
generativeAnswer |
Optional. Respond with a generative answer. |
RespondImmediately
| JSON representation |
|---|
{
"responses": [
{
object ( |
| Fields | |
|---|---|
responses[] |
Required. The canned responses for the agent to choose from. The response is chosen randomly. |
Response
| JSON representation |
|---|
{ "text": string, "disabled": boolean } |
| Fields | |
|---|---|
text |
Required. Text for the agent to respond with. |
disabled |
Optional. Whether the response is disabled. Disabled responses are not used by the agent. |
TransferAgent
| JSON representation |
|---|
{ "agent": string } |
| Fields | |
|---|---|
agent |
Required. The name of the agent to transfer the conversation to. The agent must be in the same app as the current agent. Format: |
GenerativeAnswer
| JSON representation |
|---|
{ "prompt": string } |
| Fields | |
|---|---|
prompt |
Required. The prompt to use for the generative answer. |
Timestamp
| JSON representation |
|---|
{ "seconds": string, "nanos": integer } |
| Fields | |
|---|---|
seconds |
Represents seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z. Must be between -62135596800 and 253402300799 inclusive (which corresponds to 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z). |
nanos |
Non-negative fractions of a second at nanosecond resolution. This field is the nanosecond portion of the duration, not an alternative to seconds. Negative second values with fractions must still have non-negative nanos values that count forward in time. Must be between 0 and 999,999,999 inclusive. |
Tool Annotations
Destructive Hint: ✅ | Idempotent Hint: ❌ | Read Only Hint: ❌ | Open World Hint: ❌