Skip to content

put_experiment_run_results async

put_experiment_run_results(
    experiment_id: ExperimentId,
    run_id: ExperimentRunId,
    results: ExperimentCaseResultList,
    *,
    config_overrides: Optional[AsyncCloudWatchOmniClientConfig] = None,
    client_token: Optional[ClientToken] = None,
    run: Optional[ReportedRunInfo] = None,
) -> PutExperimentRunResultsOutput

Reports a batch of scored cases for a run. Applies to runs reported from the caller's code (REPORTED runs). Each call reports up to 25 cases. The first call with a new runId creates the run and must include the run block. Repeat the call to report more cases, then call CompleteExperimentRun to end the run. Fails with a ConflictException (RUN_TERMINAL) for a run that has ended, and (RUN_ID_DELETED) for the runId of a deleted run. The batch is atomic: an invalid item fails the whole request with a ValidationException that names the item and field (for example, results[3].caseId), and nothing is written. A request is at most 1 MB, and each results item at most 256 KB as canonical JSON. A larger item fails with a ValidationException, and a larger request is rejected before it reaches the API.

Parameters:

  • experiment_id (ExperimentId) –

    The ID of the experiment the run belongs to.

  • run_id (ExperimentRunId) –

    The ID of the run, chosen by the caller. A runId that is new to the experiment creates a run. A call that fails validation does not create the run.

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

    Idempotency token for safe retries. Repeated requests with the same token and identical input return the recorded response. A call that fails validation frees the token, so the corrected batch can be resent with the same token.

  • run (Optional[ReportedRunInfo], default: None ) –

    The details of the run. Required on the call that creates the run; optional afterwards, and must match the run when present.

  • results (ExperimentCaseResultList) –

    The cases to report: up to 25 distinct cases, written atomically so that all are accepted or none are. Each item is at most 256 KB as canonical JSON.

Raises:

Examples:

Create a reported run and report its first cases The following example creates a run reported from the caller's code and reports two cases: one the agent answered, and one where the agent could not be invoked. Payloads are shown as JSON; on the wire they are CBOR-encoded.

>>> await client.put_experiment_run_results(experiment_id='exp-01JD8K3M5N7P9Q2R4S6T8V0W1X', run_id='ci-build-4821', client_token='ci-build-4821-batch-1', run={'producer': {'kind': 'CUSTOM', 'name': 'release-eval-harness', 'version': '1.4.0', 'externalId': '4821'}, 'evaluators': [{'evaluatorId': 'Builtin.Helpfulness', 'ratingScale': 'NUMERIC'}], 'rule': {'source': 'FILE', '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', 'version': '7'}}, 'dataset': {'source': 'FILE', 'name': 'support-faq.jsonl', 'caseCount': 50}, 'metadata': {'gitCommit': '4f9c2e1'}, 'startedAt': '2026-11-10T15:01:58Z'}, results=[{'caseId': 'faq-001', 'sessionId': 'ci-build-4821-faq-001', 'executionStatus': 'COMPLETED', 'turns': [{'traceId': '6f1c2a9e4b7d3f08a5c1e9b2d4f6a8c0', 'input': 'How do I reset my password?', 'output': 'Choose Forgot password on the sign-in page and follow the link that we email you.'}], 'evaluators': [{'evaluatorId': 'Builtin.Helpfulness', 'score': 0.86}]}, {'caseId': 'faq-002', 'executionStatus': 'TARGET_ERROR', 'statusReason': 'TARGET_INVOKE_ERROR', 'turns': [{'input': 'Can I change the email on my account?'}]}])
Source code in docs_src/capo_cloudwatchomni/_services/async_cloud_watch_omni.py
async def put_experiment_run_results(
    self,
    experiment_id: "capo_cloudwatchomni.types.experiment_id.ExperimentId",
    run_id: "capo_cloudwatchomni.types.experiment_run_id.ExperimentRunId",
    results: "capo_cloudwatchomni.types.experiment_case_result_list.ExperimentCaseResultList",
    *,
    config_overrides: Optional[AsyncCloudWatchOmniClientConfig] = None,
    client_token: Optional[
        "capo_cloudwatchomni.types.client_token.ClientToken"
    ] = None,
    run: Optional[
        "capo_cloudwatchomni.types.reported_run_info.ReportedRunInfo"
    ] = None,
) -> "capo_cloudwatchomni.types.put_experiment_run_results_output.PutExperimentRunResultsOutput":
    """Reports a batch of scored cases for a run. Applies to runs reported from the caller's code (REPORTED runs). Each call reports up to 25 cases. The first call with a new runId creates the run and must include the run block. Repeat the call to report more cases, then call CompleteExperimentRun to end the run. Fails with a ConflictException (RUN_TERMINAL) for a run that has ended, and (RUN_ID_DELETED) for the runId of a deleted run. The batch is atomic: an invalid item fails the whole request with a ValidationException that names the item and field (for example, results[3].caseId), and nothing is written. A request is at most 1 MB, and each results item at most 256 KB as canonical JSON. A larger item fails with a ValidationException, and a larger request is rejected before it reaches the API.

    Args:
        experiment_id: The ID of the experiment the run belongs to.
        run_id: The ID of the run, chosen by the caller. A runId that is new to the experiment creates a run. A call that fails validation does not create the run.
        client_token: Idempotency token for safe retries. Repeated requests with the same token and identical input return the recorded response. A call that fails validation frees the token, so the corrected batch can be resent with the same token.
        run: The details of the run. Required on the call that creates the run; optional afterwards, and must match the run when present.
        results: The cases to report: up to 25 distinct cases, written atomically so that all are accepted or none are. Each item is at most 256 KB as canonical JSON.

    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:
        Create a reported run and report its first cases
        The following example creates a run reported from the caller's code and reports two cases: one the agent answered, and one where the agent could not be invoked. Payloads are shown as JSON; on the wire they are CBOR-encoded.

        >>> await client.put_experiment_run_results(experiment_id='exp-01JD8K3M5N7P9Q2R4S6T8V0W1X', run_id='ci-build-4821', client_token='ci-build-4821-batch-1', run={'producer': {'kind': 'CUSTOM', 'name': 'release-eval-harness', 'version': '1.4.0', 'externalId': '4821'}, 'evaluators': [{'evaluatorId': 'Builtin.Helpfulness', 'ratingScale': 'NUMERIC'}], 'rule': {'source': 'FILE', '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', 'version': '7'}}, 'dataset': {'source': 'FILE', 'name': 'support-faq.jsonl', 'caseCount': 50}, 'metadata': {'gitCommit': '4f9c2e1'}, 'startedAt': '2026-11-10T15:01:58Z'}, results=[{'caseId': 'faq-001', 'sessionId': 'ci-build-4821-faq-001', 'executionStatus': 'COMPLETED', 'turns': [{'traceId': '6f1c2a9e4b7d3f08a5c1e9b2d4f6a8c0', 'input': 'How do I reset my password?', 'output': 'Choose Forgot password on the sign-in page and follow the link that we email you.'}], 'evaluators': [{'evaluatorId': 'Builtin.Helpfulness', 'score': 0.86}]}, {'caseId': 'faq-002', 'executionStatus': 'TARGET_ERROR', 'statusReason': 'TARGET_INVOKE_ERROR', 'turns': [{'input': 'Can I change the email on my account?'}]}])
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_cloudwatchomni.types.put_experiment_run_results_input.PutExperimentRunResultsInput]",
    ) -> AsyncOperationResponse[
        "capo_cloudwatchomni.types.put_experiment_run_results_output.PutExperimentRunResultsOutput"
    ]:
        import capo_cloudwatchomni._operations.cloud_watch_omni_frontend.put_experiment_run_results

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

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

        return capo_cloudwatchomni.types.put_experiment_run_results_input.redact_sensitive(
            input_
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("PutExperimentRunResults", redact_input=_redact_input),
    )
    input_: capo_cloudwatchomni.types.put_experiment_run_results_input.PutExperimentRunResultsInput = {
        "experiment_id": experiment_id,
        "run_id": run_id,
        "results": results,
    }
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if run is not None:
        input_["run"] = run

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