

# Manage an A/B test
<a name="ab-testing-manage"></a>

Update an A/B test to start it, pause it, or stop it. You use the `UpdateABTest` operation to change execution status.

## Code samples
<a name="manage-ab-test-examples"></a>

### Start, pause, and stop
<a name="manage-ab-test-start-stop"></a>

**Example**  
Start (resume) a paused test:  

```
agentcore resume ab-test customerSupportTargetTest
```
Pause a running test. Traffic stops splitting and all requests route to the control variant. Can be resumed.  

```
agentcore pause ab-test customerSupportTargetTest
```
Stop a test permanently. All traffic reverts to the control variant. This cannot be undone.  

```
agentcore stop ab-test customerSupportTargetTest
```
Start a test (set execution status to `RUNNING`):  

```
import boto3
import uuid

client = boto3.client("bedrock-agentcore", region_name="us-west-2")

response = client.update_ab_test(
    abTestId="customerSupportPromptTest-Ab1Cd2Ef3G",
    executionStatus="RUNNING",
    clientToken=str(uuid.uuid4()),
)
print(f"Execution status: {response['executionStatus']}")
```
Pause a running test:  

```
response = client.update_ab_test(
    abTestId="customerSupportPromptTest-Ab1Cd2Ef3G",
    executionStatus="PAUSED",
    clientToken=str(uuid.uuid4()),
)
print(f"Execution status: {response['executionStatus']}")
```
Stop a running test permanently:  

```
response = client.update_ab_test(
    abTestId="customerSupportPromptTest-Ab1Cd2Ef3G",
    executionStatus="STOPPED",
    clientToken=str(uuid.uuid4()),
)
print(f"Execution status: {response['executionStatus']}")
```

### Delete an A/B test
<a name="manage-ab-test-remove"></a>

Delete an A/B test and its associated metadata. The test must be in `STOPPED` execution status before it can be deleted. Deleting a test does not affect the configuration bundles, AgentCore Gateway, or online evaluation configuration that the test referenced.

**Example**  

```
agentcore remove ab-test --name customerSupportTargetTest
```
Stop and then delete:  

```
import boto3
import uuid

client = boto3.client("bedrock-agentcore", region_name="us-west-2")

# First stop the test if it's running
client.update_ab_test(
    abTestId="customerSupportPromptTest-Ab1Cd2Ef3G",
    executionStatus="STOPPED",
    clientToken=str(uuid.uuid4()),
)

# Then delete
response = client.delete_ab_test(
    abTestId="customerSupportPromptTest-Ab1Cd2Ef3G"
)
print(f"Deleted: {response['abTestId']}")
```

## Execution status transitions
<a name="manage-ab-test-execution-states"></a>


| From | To | Description | 
| --- | --- | --- | 
|  `NOT_STARTED`  |  `RUNNING`  | Start the test. The AgentCore Gateway begins splitting traffic. | 
|  `RUNNING`  |  `PAUSED`  | Pause the test. Traffic stops splitting; all traffic routes to control. | 
|  `PAUSED`  |  `RUNNING`  | Resume a paused test. | 
|  `RUNNING`  |  `STOPPED`  | Stop the test permanently. Traffic routing ends immediately. | 
|  `PAUSED`  |  `STOPPED`  | Stop a paused test permanently. | 