AgentLoop Prompt 管理 RAM 权限配置

更新时间:
复制为 MD 格式

当 RAM 用户在 AgentLoop Playground 中访问 Prompt 管理功能时提示权限不足,可参考本文为 RAM 用户配置所需的 AI Registry 访问权限。本文提供只读和读写两种最小权限策略及配置步骤。

只读权限策略

仅需在 Playground 中查看和选择 Prompt 时,配置以下最小权限策略:

{
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "airegistry:Read",
        "airegistry:CreateNamespaceWithSource",
        "airegistry:ListNamespaceBySource",
        "airegistry:ListPrompts",
        "airegistry:ListPromptVersions",
        "airegistry:GetPrompt",
        "airegistry:GetPromptVersion",
        "airegistry:GetPromptVersionDetail",
        "airegistry:GetPromptGovernance",
        "airegistry:GetSupportedModels"
      ],
      "Resource": "acs:airegistry:*:*:instance/saas/*"
    }
  ],
  "Version": "1"
}

包含以下权限:

  • 客户端读权限airegistry:Read,用于客户端通过 SDK / API 拉取 Prompt 资源。

  • 工作空间:通过数据源创建和查询工作空间(AgentLoop 集成所需)。

  • 模型列表:获取支持的模型列表。

  • Prompt 只读:查询 Prompt 列表、版本列表、版本详情和治理信息。

    说明

    只读策略中包含 CreateNamespaceWithSource 是因为 AgentLoop 首次访问 Prompt 管理时会自动关联 AI Registry 工作空间。此操作仅在首次访问时触发且不会创建用户数据,因此包含在只读策略中。

读写权限策略

需要在 Playground 中创建、编辑、发布、删除或 AI 优化 Prompt 时,配置以下权限策略:

{
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "airegistry:Read",
        "airegistry:CreateNamespaceWithSource",
        "airegistry:ListNamespaceBySource",
        "airegistry:ListPrompts",
        "airegistry:ListPromptVersions",
        "airegistry:GetPrompt",
        "airegistry:GetPromptVersion",
        "airegistry:GetPromptVersionDetail",
        "airegistry:GetPromptGovernance",
        "airegistry:GetSupportedModels",
        "airegistry:CreatePrompt",
        "airegistry:UpdatePrompt",
        "airegistry:DeletePrompt",
        "airegistry:CreatePromptVersion",
        "airegistry:UpdatePromptVersion",
        "airegistry:SubmitPromptVersion",
        "airegistry:DeletePromptVersion",
        "airegistry:InvokePromptOptimizeStream"
      ],
      "Resource": "acs:airegistry:*:*:instance/saas/*"
    }
  ],
  "Version": "1"
}

相比只读策略,增加了以下权限:

  • Prompt 管理:创建、更新、删除 Prompt 及其版本,发布版本。

  • Prompt 优化:使用 AI 辅助优化 Prompt(InvokePromptOptimizeStream)。

限制资源范围(可选)

上述策略中 Resource 使用了 acs:airegistry:*:*:instance/saas/*,表示授权访问所有 AI Registry 工作空间。如需将权限限制到特定工作空间,将最后一个 * 替换为工作空间 ID:

"Resource": "acs:airegistry:*:*:instance/saas/<工作空间ID>"
说明

AI Registry 工作空间 ID 可在 AgentLoop 的 Prompt 管理页面获取。每个 AgentLoop 工作空间唯一映射一个 AI Registry 工作空间。

如需进一步限制到 Prompt 资源类型,需要注意 Prompt 相关接口存在两种资源类型:

  • 具体资源操作(如创建、更新、删除、发布、调试、优化等):使用 prompt/*

    "Resource": "acs:airegistry:*:*:instance/saas/{工作空间ID}/DEFAULT/prompt/*"
  • 集合级操作(列表查询):使用 prompt(不带 /*

    "Resource": "acs:airegistry:*:*:instance/saas/{工作空间ID}/DEFAULT/prompt"

具体对应关系:

Resource 类型

适用 Action

.../DEFAULT/prompt/*

CreatePrompt、UpdatePrompt、DeletePrompt、CreatePromptVersion、UpdatePromptVersion、SubmitPromptVersion、DeletePromptVersion、GetPrompt、GetPromptVersion、GetPromptVersionDetail、ListPromptVersions、GetPromptGovernance、InvokePromptDebugStream、InvokePromptOptimizeStream

.../DEFAULT/prompt

ListPrompts

配置步骤

说明

当前操作账号需具有 RAM 权限策略的管理权限。如果使用 RAM 用户操作,需确保该用户已被授予 AliyunRAMFullAccess 或自定义的 RAM 管理权限。

  1. 登录 RAM 控制台

  2. 在左侧导航栏,选择权限管理 > 权限策略。

  3. 在权限策略页面,单击创建权限策略。

  4. 在创建权限策略页面,选择脚本编辑模式,将上方对应的策略 JSON 粘贴到编辑器中。

  5. 输入策略名称,单击确定。

    说明

    建议的策略命名:

    • 只读策略:AgentLoopAIRegistryReadOnly

    • 读写策略:AgentLoopAIRegistryFullAccess

  6. 在左侧导航栏,选择身份管理 > 用户。

  7. 找到目标 RAM 用户,单击新增授权。

  8. 在添加权限面板中,选择刚创建的自定义权限策略,单击确定。

Action 说明

下表列出了两种权限策略中涉及的所有 Action 及其用途。

Action

说明

所属策略

airegistry:CreateNamespaceWithSource

通过数据源创建工作空间

只读 / 读写

airegistry:ListNamespaceBySource

按数据源查询工作空间列表

只读 / 读写

airegistry:GetNamespace

获取工作空间详情

只读 / 读写

airegistry:ListPrompts

查询 Prompt 列表

只读 / 读写

airegistry:ListPromptVersions

查询 Prompt 版本列表

只读 / 读写

airegistry:GetPrompt

获取 Prompt 详情

只读 / 读写

airegistry:GetPromptVersion

获取 Prompt 版本信息

只读 / 读写

airegistry:GetPromptVersionDetail

获取 Prompt 版本详细信息

只读 / 读写

airegistry:GetPromptGovernance

获取 Prompt 治理信息

只读 / 读写

airegistry:GetSupportedModels

获取支持的模型列表

读写

airegistry:CreatePrompt

创建 Prompt

读写

airegistry:UpdatePrompt

更新 Prompt

读写

airegistry:DeletePrompt

删除 Prompt

读写

airegistry:CreatePromptVersion

创建 Prompt 版本

读写

airegistry:UpdatePromptVersion

更新 Prompt 版本

读写

airegistry:SubmitPromptVersion

发布 Prompt 版本

读写

airegistry:DeletePromptVersion

删除 Prompt 版本

读写

airegistry:InvokePromptOptimizeStream

AI 辅助优化 Prompt(流式调用)

读写