startRecommendation method

Future<StartRecommendationResponse> startRecommendation({
  1. required String name,
  2. required RecommendationConfig recommendationConfig,
  3. required RecommendationType type,
  4. String? clientToken,
  5. String? description,
})

Starts a recommendation job that analyzes agent traces and generates optimization suggestions for system prompts or tool descriptions to improve agent performance.

May throw AccessDeniedException. May throw ConflictException. May throw InternalServerException. May throw ServiceQuotaExceededException. May throw ThrottlingException. May throw ValidationException.

Parameter name : The name of the recommendation. Must be unique within your account.

Parameter recommendationConfig : The configuration for the recommendation, including the input to optimize, agent traces to analyze, and evaluation settings.

Parameter type : The type of recommendation to generate. Valid values are SYSTEM_PROMPT_RECOMMENDATION for system prompt optimization or TOOL_DESCRIPTION_RECOMMENDATION for tool description optimization.

Parameter clientToken : A unique, case-sensitive identifier to ensure that the API request completes no more than one time. If this token matches a previous request, the service ignores the request, but does not return an error.

Parameter description : The description of the recommendation.

Implementation

Future<StartRecommendationResponse> startRecommendation({
  required String name,
  required RecommendationConfig recommendationConfig,
  required RecommendationType type,
  String? clientToken,
  String? description,
}) async {
  final $payload = <String, dynamic>{
    'name': name,
    'recommendationConfig': recommendationConfig,
    'type': type.value,
    'clientToken': clientToken ?? _s.generateIdempotencyToken(),
    if (description != null) 'description': description,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/recommendations',
    exceptionFnMap: _exceptionFns,
  );
  return StartRecommendationResponse.fromJson(response);
}