Skip to content

start_experiment_run async

start_experiment_run(
    experiment_id: ExperimentId,
    evaluators: ExperimentEvaluatorList,
    target: TargetConfig,
    dataset: ExperimentRunDataset,
    *,
    config_overrides: Optional[AsyncCloudWatchOmniClientConfig] = None,
    client_token: Optional[ClientToken] = None,
    rule: Optional[ExperimentRule] = None,
    control: Optional[ControlSource] = None,
    metadata: Optional[RunMetadataMap] = None,
    description: Optional[Description] = None,
) -> StartExperimentRunOutput

Starts a hosted run of an experiment. The service runs the dataset's cases against the given version of the experiment's target with an Amazon Bedrock AgentCore batch evaluation and scores them with the given evaluators. The run starts as RUNNING and ends as COMPLETED, or as DID_NOT_FINISH when it is stopped or fails. Use GetExperimentRun to check the run's progress. When the run has a rule, it gets a verdict when it ends. A target control starts a second, live control run alongside this one.

Parameters:

  • experiment_id (ExperimentId) –

    The ID of the experiment to start the run in.

  • client_token (Optional[ClientToken], default: None ) –

    Idempotency token for safe retries. Repeated requests with the same token return the original run instead of starting another.

  • rule (Optional[ExperimentRule], default: None ) –

    An optional rule. When present, the run gets a verdict when it ends.

  • evaluators (ExperimentEvaluatorList) –

    The evaluators to score the run with, from 1 to 10 for a hosted run. The run's rule can reference only these evaluators.

  • target (TargetConfig) –

    The version of the experiment's target to run. Hosted runs support only agentCoreRuntime.

  • dataset (ExperimentRunDataset) –

    The dataset to run, with source AGENTCORE, an id and a published version. Fails with FIELD_REQUIRED without a version, and the version cannot be DRAFT. Omit caseCount and contentHash.

  • control (Optional[ControlSource], default: None ) –

    An optional control to compare the run with. A target control starts a second run on the same dataset alongside this one, which uses a second AgentCore batch evaluation and counts toward the experiment's run quota. Required by rules that use vsControl or paired metrics (RULE_CONTROL_REQUIRED).

  • metadata (Optional[RunMetadataMap], default: None ) –

    Additional details about what the run tested, beyond the target and dataset versions.

  • description (Optional[Description], default: None ) –

    An optional description of the run, up to 1024 characters with no control characters. Cannot be changed after the run starts.

Raises:

Examples:

Start a hosted run The following example starts a hosted run of an experiment against version 3 of an AgentCore dataset, scored with one evaluator and gated on a 90% pass rate. Payloads are shown as JSON; on the wire they are CBOR-encoded.

>>> await client.start_experiment_run(experiment_id='exp-01JD8K3M5N7P9Q2R4S6T8V0W1X', client_token='release-2026-11-10-hosted', evaluators=[{'evaluatorId': 'Builtin.Helpfulness', 'ratingScale': 'NUMERIC'}], rule={'source': 'INLINE', 'name': 'release-gate', 'caseCriteria': [{'evaluator': {'evaluatorId': 'Builtin.Helpfulness', 'threshold': {'minScore': 0.7}}}], 'gates': [{'metric': {'passRate': {}}, 'bound': {'min': 0.9}}]}, target={'agentCoreRuntime': {'endpointArn': 'arn:aws:bedrock-agentcore:us-east-1:123456789012:runtime/support_agent-a1B2c3D4e5/runtime-endpoint/production'}}, dataset={'source': 'AGENTCORE', 'id': 'support-faq-dataset', 'version': '3'}, metadata={'modelId': 'anthropic.claude-sonnet', 'promptVersion': 'v3'}, description='Release candidate with the v3 support prompt')
Source code in docs_src/capo_cloudwatchomni/_services/async_cloud_watch_omni.py
async def start_experiment_run(
    self,
    experiment_id: "capo_cloudwatchomni.types.experiment_id.ExperimentId",
    evaluators: "capo_cloudwatchomni.types.experiment_evaluator_list.ExperimentEvaluatorList",
    target: "capo_cloudwatchomni.types.target_config.TargetConfig",
    dataset: "capo_cloudwatchomni.types.experiment_run_dataset.ExperimentRunDataset",
    *,
    config_overrides: Optional[AsyncCloudWatchOmniClientConfig] = None,
    client_token: Optional[
        "capo_cloudwatchomni.types.client_token.ClientToken"
    ] = None,
    rule: Optional[
        "capo_cloudwatchomni.types.experiment_rule.ExperimentRule"
    ] = None,
    control: Optional[
        "capo_cloudwatchomni.types.control_source.ControlSource"
    ] = None,
    metadata: Optional[
        "capo_cloudwatchomni.types.run_metadata_map.RunMetadataMap"
    ] = None,
    description: Optional[
        "capo_cloudwatchomni.types.description.Description"
    ] = None,
) -> (
    "capo_cloudwatchomni.types.start_experiment_run_output.StartExperimentRunOutput"
):
    """Starts a hosted run of an experiment. The service runs the dataset's cases against the given version of the experiment's target with an Amazon Bedrock AgentCore batch evaluation and scores them with the given evaluators. The run starts as RUNNING and ends as COMPLETED, or as DID_NOT_FINISH when it is stopped or fails. Use GetExperimentRun to check the run's progress. When the run has a rule, it gets a verdict when it ends. A target control starts a second, live control run alongside this one.

    Args:
        experiment_id: The ID of the experiment to start the run in.
        client_token: Idempotency token for safe retries. Repeated requests with the same token return the original run instead of starting another.
        rule: An optional rule. When present, the run gets a verdict when it ends.
        evaluators: The evaluators to score the run with, from 1 to 10 for a hosted run. The run's rule can reference only these evaluators.
        target: The version of the experiment's target to run. Hosted runs support only agentCoreRuntime.
        dataset: The dataset to run, with source AGENTCORE, an id and a published version. Fails with FIELD_REQUIRED without a version, and the version cannot be DRAFT. Omit caseCount and contentHash.
        control: An optional control to compare the run with. A target control starts a second run on the same dataset alongside this one, which uses a second AgentCore batch evaluation and counts toward the experiment's run quota. Required by rules that use vsControl or paired metrics (RULE_CONTROL_REQUIRED).
        metadata: Additional details about what the run tested, beyond the target and dataset versions.
        description: An optional description of the run, up to 1024 characters with no control characters. Cannot be changed after the run starts.

    Raises:
        capo_cloudwatchomni.errors.access_denied_exception.AccessDeniedException: The caller is not authorized to perform this action.
        capo_cloudwatchomni.errors.conflict_exception.ConflictException: The operation could not be completed because of a conflict with the current state of the resource.
        capo_cloudwatchomni.errors.internal_server_exception.InternalServerException: An unexpected error occurred while processing the request.
        capo_cloudwatchomni.errors.resource_not_found_exception.ResourceNotFoundException: The specified resource does not exist.
        capo_cloudwatchomni.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: A service quota was exceeded.
        capo_cloudwatchomni.errors.throttling_exception.ThrottlingException: The request was throttled due to exceeding the allowed request rate.
        capo_cloudwatchomni.errors.validation_exception.ValidationException: A parameter is specified incorrectly.
        capo_cloudwatchomni.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        Start a hosted run
        The following example starts a hosted run of an experiment against version 3 of an AgentCore dataset, scored with one evaluator and gated on a 90% pass rate. Payloads are shown as JSON; on the wire they are CBOR-encoded.

        >>> await client.start_experiment_run(experiment_id='exp-01JD8K3M5N7P9Q2R4S6T8V0W1X', client_token='release-2026-11-10-hosted', evaluators=[{'evaluatorId': 'Builtin.Helpfulness', 'ratingScale': 'NUMERIC'}], rule={'source': 'INLINE', 'name': 'release-gate', 'caseCriteria': [{'evaluator': {'evaluatorId': 'Builtin.Helpfulness', 'threshold': {'minScore': 0.7}}}], 'gates': [{'metric': {'passRate': {}}, 'bound': {'min': 0.9}}]}, target={'agentCoreRuntime': {'endpointArn': 'arn:aws:bedrock-agentcore:us-east-1:123456789012:runtime/support_agent-a1B2c3D4e5/runtime-endpoint/production'}}, dataset={'source': 'AGENTCORE', 'id': 'support-faq-dataset', 'version': '3'}, metadata={'modelId': 'anthropic.claude-sonnet', 'promptVersion': 'v3'}, description='Release candidate with the v3 support prompt')
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_cloudwatchomni.types.start_experiment_run_input.StartExperimentRunInput]",
    ) -> AsyncOperationResponse[
        "capo_cloudwatchomni.types.start_experiment_run_output.StartExperimentRunOutput"
    ]:
        import capo_cloudwatchomni._operations.cloud_watch_omni_frontend.start_experiment_run

        (
            output,
            http_response,
        ) = await capo_cloudwatchomni._operations.cloud_watch_omni_frontend.start_experiment_run.async_start_experiment_run(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_cloudwatchomni.types.start_experiment_run_input.StartExperimentRunInput",
    ) -> dict[str, Any]:
        import capo_cloudwatchomni.types.start_experiment_run_input

        return (
            capo_cloudwatchomni.types.start_experiment_run_input.redact_sensitive(
                input_
            )
        )

    def _redact_output(
        output: "capo_cloudwatchomni.types.start_experiment_run_output.StartExperimentRunOutput",
    ) -> dict[str, Any]:
        import capo_cloudwatchomni.types.start_experiment_run_output

        return (
            capo_cloudwatchomni.types.start_experiment_run_output.redact_sensitive(
                output
            )
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "StartExperimentRun",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_cloudwatchomni.types.start_experiment_run_input.StartExperimentRunInput = {
        "experiment_id": experiment_id,
        "evaluators": evaluators,
        "target": target,
        "dataset": dataset,
    }
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if rule is not None:
        input_["rule"] = rule
    if control is not None:
        input_["control"] = control
    if metadata is not None:
        input_["metadata"] = metadata
    if description is not None:
        input_["description"] = description

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output