

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# AgentCore 安全带版本控制和端点
<a name="harness-versioning"></a>

Amazon Bedrock 为安全带 AgentCore 实现自动版本 AgentCore 控制，并允许您使用终端节点管理不同的配置。安全带版本控制与[AgentCore 运行时版本控制的工作方式相同 ](agent-runtime-versioning.md) ——线束是运行时之上的托管抽象——但你可以通过线束控制平面 API 进行管理。

亚马逊 Bedrock 中的每个安全带 AgentCore 都是自动版本控制的：
+ 创建安全带时， AgentCore 会自动创建版本 1 (V1)
+ 对该工具的每次更新都会创建一个具有完整、独立配置的新版本
+ 版本一经创建，即不可更改
+ 每个版本都包含执行所需的所有配置：模型、系统提示、工具、内存、限制和环境

## 端点如何引用版本
<a name="harness-endpoint-versioning"></a>

端点提供了一种引用安全带特定版本的方法：
+ 终`DEFAULT`端会自动指向您的安全带的最新版本
+ 端点可以指向特定的版本，允许您维护不同的环境（例如开发、暂存、生产）
+ 更新线束时，`DEFAULT`端点会自动更新为指向新版本
+ 必须明确更新端点以指向新版本

 **示例：将端点更新到新版本 ** 

**Example**  

```
import boto3

control_client = boto3.client('bedrock-agentcore-control', region_name='us-west-2')

response = control_client.update_harness_endpoint(
    harnessId='MyHarness-UuFdkQoXSL',
    endpointName='production-endpoint',
    targetVersion='2',
    description='Updated production endpoint'
)

print(response)
```
或者使用 Amazon CLI：  

```
aws bedrock-agentcore-control update-harness-endpoint \
  --harness-id "MyHarness-UuFdkQoXSL" \
  --endpoint-name "production-endpoint" \
  --target-version "2" \
  --description "Updated production endpoint"
```

## 版本控制场景
<a name="harness-versioning-scenarios"></a>

下表说明了版本控制和端点在工具生命周期中的交互方式：


| 更改类型 | 版本创建行为 | 最新版本 | 端点行为 | 
| --- | --- | --- | --- | 
| 初始创作 | 自动创建版本 1 (V1) | V1 | 默认指向 V1 | 
| 型号变更 | 使用更新的模型选择创建新版本 | V2 | DEFAULT 自动更新到 V2 | 
| 使用 V2 创建 “PROD” 端点 | 未创建新版本 | V2 | PROD 端点指向 V2 | 
| 工具或技能更新 | 使用更新的工具配置创建新版本 | V3 | V3 的默认更新，PROD 仍在 V2 上 | 
| 将 “PROD” 更新到 V3 | 未创建新版本 | V3 | PROD 对 V3 的更新 | 
| 限制或环境修改 | 使用更新的执行参数创建新版本 | V4 | V4 的默认更新，PROD 仍在 V3 上 | 

## 端点生命周期状态
<a name="harness-endpoint-lifecycle"></a>

安全带端点在其生命周期中会经历不同的状态：

CREATING  
创建端点时的初始状态

创建\_失败  
表示由于权限、配置或其他问题导致创建失败

就绪  
端点已准备好接受请求

UPDATING  
端点正在更新到新版本

UPDATE\_FAILED  
表示更新操作失败

## 创建终端节点
<a name="harness-creating-endpoints"></a>

创建命名端点以将环境固定到特定的安全带版本。如果省略`targetVersion`，则终端节点指向创建时的最新版本。

**Example**  

```
import boto3

control_client = boto3.client('bedrock-agentcore-control', region_name='us-west-2')

response = control_client.create_harness_endpoint(
    harnessId='MyHarness-UuFdkQoXSL',
    endpointName='production-endpoint',
    targetVersion='2',
    description='Production endpoint pinned to V2'
)

print(response)
```
或者使用 Amazon CLI：  

```
aws bedrock-agentcore-control create-harness-endpoint \
  --harness-id "MyHarness-UuFdkQoXSL" \
  --endpoint-name "production-endpoint" \
  --target-version "2" \
  --description "Production endpoint pinned to V2"
```

## 列出安全带版本和端点
<a name="harness-listing-versions"></a>

您可以通过调用`ListHarnessVersions`操作列出线束的所有版本。要列出安全带的端点，请致电`ListHarnessEndpoints`。

**Example**  

```
import boto3

control_client = boto3.client('bedrock-agentcore-control', region_name='us-west-2')

# List all versions of a harness
versions = control_client.list_harness_versions(
    harnessId='MyHarness-UuFdkQoXSL'
)
for version in versions['harnessVersions']:
    print(version)

# List all endpoints for a harness
endpoints = control_client.list_harness_endpoints(
    harnessId='MyHarness-UuFdkQoXSL'
)
for endpoint in endpoints['endpoints']:
    print(endpoint)
```
或者使用 Amazon CLI：  

```
aws bedrock-agentcore-control list-harness-versions \
  --harness-id "MyHarness-UuFdkQoXSL"

aws bedrock-agentcore-control list-harness-endpoints \
  --harness-id "MyHarness-UuFdkQoXSL"
```
两种操作都支持通过`maxResults`和`nextToken`进行分页。要检索单个端点的配置，请调用`GetHarnessEndpoint`；要删除一个端点的配置，请致电`DeleteHarnessEndpoint`。

## 相关主题
<a name="_related_topics"></a>
+  [开始使用](harness-get-started.md)-创建并调用你的第一个安全带
+  [型号和说明书](harness-models.md)-配置代理、模型和提供商
+  [可观察性和成本控制](harness-operations.md)-可观测性、成本控制和标签
+  [AgentCore 运行时版本控制和端点](agent-runtime-versioning.md)-运行时的版本控制和端点 AgentCore 