ALTER AGENT

修改现有 Cortex Agent 的属性或规格。

另请参阅:

CREATE AGENTDESCRIBE AGENTDROP AGENTSHOW AGENTS

语法

ALTER AGENT <name> SET
  [ COMMENT = '<string>' ]
  [ PROFILE = '<string>' ]

ALTER AGENT <name> MODIFY LIVE VERSION SET SPECIFICATION = <specification>

必填参数

name

用于指定要修改的代理标识符(即名称)的字符串。

如果标识符包含空格或特殊字符,则整个字符串必须放在双引号内。放在双引号内的标识符也区分大小写。

有关更多信息,请参阅 标识符要求

可选参数

SET ...

为代理设置一个或多个指定的属性或参数:

COMMENT = comment

指定代理的描述。

PROFILE = string

指定代理的配置文件信息,例如显示名称、头像和颜色。如下所示,设置字符串格式:

'{"display_name": "<display_name>", "avatar": "<avatar>", "color": "<color>"}'

下表描述了该字符串中的键值对:

类型

描述

display_name

字符串

代理的显示名称。

data

字符串

头像图像文件名或标识符。

tools

字符串

代理的颜色主题(例如“蓝色”、“绿色”、“红色”)

MODIFY LIVE VERSION SET SPECIFICATION specification

指定一个 VARCHAR 包含代理替换设置的值,该值以 YAML 或 JSON 对象的形式存在。

规范对象的最大长度为 100,000 字节。

重要

新规范会完全取代现有规范。未包含在新规范中的字段将被移除。

YAML 对象应具有以下结构:

models:
  orchestration: <model_name>

orchestration:
  budget:
      seconds: <number_of_seconds>
      tokens: <number_of_tokens>

instructions:
  response: '<response_instructions>'
  orchestration: '<orchestration_instructions>'
  system: '<system_instructions>'
  sample_questions:
      - question: '<sample_question>'
        answer: '<sample_answer>'
      ...

tools:
  - tool_spec:
      type: '<tool_type>'
      name: '<tool_name>'
      description: '<tool_description>'
      input_schema:
          type: 'object'
          properties:
            <property_name>:
              type: '<property_type>'
              description: '<property_description>'
          required: <required_property_names>
  ...

tool_resources:
  <tool_name>:
    <resource_key>: '<resource_value>'
    ...
  ...

JSON 对象应具有以下结构:

{
  "models": {
    "orchestration": "<model_name>"
  },
  "orchestration": {
    "budget": {
      "seconds": <number_of_seconds>,
      "tokens": <number_of_tokens>
    }
  },
  "instructions": {
    "response": "<response_instructions>",
    "orchestration": "<orchestration_instructions>",
    "system": "<system_instructions>",
    "sample_questions": [
      {
        "question": "<sample_question>",
        "answer": "<sample_answer>"
      }
    ]
  },
  "tools": [
    {
      "tool_spec": {
        "type": "<tool_type>",
        "name": "<tool_name>",
        "description": "<tool_description>",
        "input_schema": {
          "type": "object",
          "properties": {
            "<property_name>": {
              "type": "<property_type>",
              "description": "<property_description>"
            }
          },
          "required": ["<required_property_names>"]
        }
      }
    }
  ],
  "tool_resources": {
    "<tool_name>": {
      "<resource_key>": "<resource_value>"
    }
  }
}

下表描述了该对象中的键值对:

类型

描述

models

ModelConfig

代理的可选模型配置。包括编排模型(例如 claude-4-sonnet)。如果未提供,则自动选择模型。目前仅适用于 编排 步骤。

orchestration

OrchestrationConfig

可选编排配置,包括预算约束(例如,秒数、令牌)。

instructions

AgentInstructions

代理的可选行为指令,包括响应、编排、系统和示例问题。

tools

Tool 的数组

代理可使用的可选工具列表。每个工具包含一个 tool_spec,其中包括类型、名称、描述和输入架构。工具可能在 tool_resources 中有相应的配置。

tool_resources

ToolResource 的地图

对工具数组中每个引用工具的可选配置。密钥必须与相应工具的名称匹配。

访问控制要求

用于执行此操作的 角色 必须至少具有以下 权限

权限

对象

备注

OWNERSHIP 或 MODIFY

代理

修改代理属性或规范所必需的权限。

OWNERSHIP is a special privilege on an object that is automatically granted to the role that created the object, but can also be transferred using the GRANT OWNERSHIP command to a different role by the owning role (or any role with the MANAGE GRANTS privilege).

对架构中的对象进行操作至少需要父数据库的一项权限和父架构的一项权限。

有关创建具有指定权限集的自定义角色的说明,请参阅 创建自定义角色

有关对 安全对象 执行 SQL 操作的相应角色和权限授予的一般信息,请参阅 访问控制概述

使用说明

  • 修改实时版本的规范时,新规范会完全取代现有规范。未包含在新规范中的字段将被移除。

  • 规范支持 YAML 和 JSON 两种格式。

  • 无效的规范字段会导致错误。

  • 关于元数据:

    注意

    客户应确保在使用 Snowflake 服务时,不会将个人数据(用户对象除外)、敏感数据、出口管制数据或其他受监管数据作为元数据输入。有关更多信息,请参阅 Snowflake 中的元数据字段

示例

更新代理的注释:

ALTER AGENT my_support_agent SET COMMENT = 'Customer support agent for product inquiries';

更新代理的配置文件:

ALTER AGENT my_support_agent SET PROFILE = '{"display_name": "Support Bot", "avatar": "bot-icon.png"}';

同时更新注释和配置文件:

ALTER AGENT my_support_agent
  SET COMMENT = 'Production support agent',
      PROFILE = '{"display_name": "Customer Assistant", "avatar": "assistant.png"}';

使用 YAML 式更新实时版本规范:

ALTER AGENT my_support_agent
  MODIFY LIVE VERSION SET SPECIFICATION =
  $$
  models:
    orchestration: claude-4-sonnet

  orchestration:
    budget:
      seconds: 30
      tokens: 50000

  instructions:
    system: "You are a helpful customer support assistant."
    response: "Always be concise and accurate."
    sample_questions:
      - question: "What is the status of my order?"
        answer: "I can help you check your order status. Please provide your order number."
  $$;

使用 JSON 式更新实时版本规范:

ALTER AGENT my_support_agent
  MODIFY LIVE VERSION SET SPECIFICATION = '{"models":{"orchestration":"claude-4-sonnet"},"orchestration":{"budget":{"seconds":45,"tokens":80000}}}';