updateHarness method

Future<UpdateHarnessResponse> updateHarness({
  1. required String harnessId,
  2. List<String>? allowedTools,
  3. UpdatedAuthorizerConfiguration? authorizerConfiguration,
  4. String? clientToken,
  5. HarnessEnvironmentProviderRequest? environment,
  6. UpdatedHarnessEnvironmentArtifact? environmentArtifact,
  7. Map<String, String>? environmentVariables,
  8. String? executionRoleArn,
  9. int? maxIterations,
  10. int? maxTokens,
  11. UpdatedHarnessMemoryConfiguration? memory,
  12. HarnessModelConfiguration? model,
  13. List<HarnessSkill>? skills,
  14. List<HarnessSystemContentBlock>? systemPrompt,
  15. int? timeoutSeconds,
  16. List<HarnessTool>? tools,
  17. HarnessTruncationConfiguration? truncation,
})

Operation to update a Harness.

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

Parameter harnessId : The ID of the harness to update.

Parameter allowedTools : The tools that the agent is allowed to use. If specified, this replaces all existing allowed tools. If not specified, the existing value is retained.

Parameter clientToken : A unique, case-sensitive identifier to ensure idempotency of the request.

Parameter environment : The compute environment configuration for the harness. If not specified, the existing value is retained.

Parameter environmentArtifact : The environment artifact for the harness. Use the optionalValue wrapper to set a new value, or set it to null to clear the existing configuration.

Parameter environmentVariables : Environment variables to set in the harness runtime environment. If specified, this replaces all existing environment variables. If not specified, the existing value is retained.

Parameter executionRoleArn : The ARN of the IAM role that the harness assumes when running. If not specified, the existing value is retained.

Parameter maxIterations : The maximum number of iterations the agent loop can execute per invocation. If not specified, the existing value is retained.

Parameter maxTokens : The maximum total number of output tokens the agent can generate across all model calls within a single invocation. If not specified, the existing value is retained.

Parameter memory : The AgentCore Memory configuration. Use the optionalValue wrapper to set a new value, or set it to null to clear the existing configuration.

Parameter model : The model configuration for the harness. If not specified, the existing value is retained.

Parameter skills : The skills available to the agent. If specified, this replaces all existing skills. If not specified, the existing value is retained.

Parameter systemPrompt : The system prompt that defines the agent's behavior. If not specified, the existing value is retained.

Parameter timeoutSeconds : The maximum duration in seconds for the agent loop execution per invocation. If not specified, the existing value is retained.

Parameter tools : The tools available to the agent. If specified, this replaces all existing tools. If not specified, the existing value is retained.

Parameter truncation : The truncation configuration for managing conversation context. If not specified, the existing value is retained.

Implementation

Future<UpdateHarnessResponse> updateHarness({
  required String harnessId,
  List<String>? allowedTools,
  UpdatedAuthorizerConfiguration? authorizerConfiguration,
  String? clientToken,
  HarnessEnvironmentProviderRequest? environment,
  UpdatedHarnessEnvironmentArtifact? environmentArtifact,
  Map<String, String>? environmentVariables,
  String? executionRoleArn,
  int? maxIterations,
  int? maxTokens,
  UpdatedHarnessMemoryConfiguration? memory,
  HarnessModelConfiguration? model,
  List<HarnessSkill>? skills,
  List<HarnessSystemContentBlock>? systemPrompt,
  int? timeoutSeconds,
  List<HarnessTool>? tools,
  HarnessTruncationConfiguration? truncation,
}) async {
  final $payload = <String, dynamic>{
    if (allowedTools != null) 'allowedTools': allowedTools,
    if (authorizerConfiguration != null)
      'authorizerConfiguration': authorizerConfiguration,
    'clientToken': clientToken ?? _s.generateIdempotencyToken(),
    if (environment != null) 'environment': environment,
    if (environmentArtifact != null)
      'environmentArtifact': environmentArtifact,
    if (environmentVariables != null)
      'environmentVariables': environmentVariables,
    if (executionRoleArn != null) 'executionRoleArn': executionRoleArn,
    if (maxIterations != null) 'maxIterations': maxIterations,
    if (maxTokens != null) 'maxTokens': maxTokens,
    if (memory != null) 'memory': memory,
    if (model != null) 'model': model,
    if (skills != null) 'skills': skills,
    if (systemPrompt != null) 'systemPrompt': systemPrompt,
    if (timeoutSeconds != null) 'timeoutSeconds': timeoutSeconds,
    if (tools != null) 'tools': tools,
    if (truncation != null) 'truncation': truncation,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'PATCH',
    requestUri: '/harnesses/${Uri.encodeComponent(harnessId)}',
    exceptionFnMap: _exceptionFns,
  );
  return UpdateHarnessResponse.fromJson(response);
}