InvokeHarness
Operation to invoke a Harness.
Request Syntax
POST /harnesses/invoke?harnessArn=harnessArn HTTP/1.1
X-Amzn-Bedrock-AgentCore-Runtime-Session-Id: runtimeSessionId
Content-type: application/json
{
"actorId": "string",
"allowedTools": [ "string" ],
"maxIterations": number,
"maxTokens": number,
"messages": [
{
"content": [
{ ... }
],
"role": "string"
}
],
"model": { ... },
"skills": [
{ ... }
],
"systemPrompt": [
{ ... }
],
"timeoutSeconds": number,
"tools": [
{
"config": { ... },
"name": "string",
"type": "string"
}
]
}
URI Request Parameters
The request uses the following URI parameters.
- harnessArn
-
The ARN of the harness to invoke.
Pattern:
arn:([^:]+)?:bedrock-agentcore:[a-z0-9-]+:[0-9]{12}:harness/[a-zA-Z][a-zA-Z0-9_]{0,39}-[a-zA-Z0-9]{10}Required: Yes
- runtimeSessionId
-
The session ID for the invocation. Use the same session ID across requests to continue a conversation.
Length Constraints: Minimum length of 1. Maximum length of 100.
Pattern:
[a-zA-Z0-9][a-zA-Z0-9-_]*Required: Yes
Request Body
The request accepts the following data in JSON format.
- actorId
-
The actor ID for memory operations. Overrides the actor ID configured on the harness.
Type: String
Required: No
- allowedTools
-
The tools that the agent is allowed to use for this invocation. If specified, overrides the harness default.
Type: Array of strings
Length Constraints: Minimum length of 1. Maximum length of 64.
Pattern:
(\*|@?[^/]+(/[^/]+)?)Required: No
- maxIterations
-
The maximum number of iterations the agent loop can execute. If specified, overrides the harness default.
Type: Integer
Required: No
- maxTokens
-
The maximum number of tokens the agent can generate per iteration. If specified, overrides the harness default.
Type: Integer
Required: No
- messages
-
The messages to send to the agent.
Type: Array of HarnessMessage objects
Required: Yes
- model
-
The model configuration to use for this invocation. If specified, overrides the harness default.
Type: HarnessModelConfiguration object
Note: This object is a Union. Only one member of this object can be specified or returned.
Required: No
- skills
-
The skills available to the agent for this invocation. If specified, overrides the harness default.
Type: Array of HarnessSkill objects
Required: No
- systemPrompt
-
The system prompt to use for this invocation. If specified, overrides the harness default.
Type: Array of HarnessSystemContentBlock objects
Required: No
- timeoutSeconds
-
The maximum duration in seconds for the agent loop execution. If specified, overrides the harness default.
Type: Integer
Required: No
- tools
-
The tools available to the agent for this invocation. If specified, overrides the harness default.
Type: Array of HarnessTool objects
Required: No
Response Syntax
HTTP/1.1 200
Content-type: application/json
{
"contentBlockDelta": {
"contentBlockIndex": number,
"delta": { ... }
},
"contentBlockStart": {
"contentBlockIndex": number,
"start": { ... }
},
"contentBlockStop": {
"contentBlockIndex": number
},
"internalServerException": {
},
"messageStart": {
"role": "string"
},
"messageStop": {
"stopReason": "string"
},
"metadata": {
"metrics": {
"latencyMs": number
},
"usage": {
"cacheReadInputTokens": number,
"cacheWriteInputTokens": number,
"inputTokens": number,
"outputTokens": number,
"totalTokens": number
}
},
"runtimeClientError": {
},
"validationException": {
}
}
Response Elements
If the action is successful, the service sends back an HTTP 200 response.
The following data is returned in JSON format by the service.
- contentBlockDelta
-
A delta update to the current content block.
Type: HarnessContentBlockDeltaEvent object
- contentBlockStart
-
Indicates the start of a new content block.
Type: HarnessContentBlockStartEvent object
- contentBlockStop
-
Indicates the end of the current content block.
Type: HarnessContentBlockStopEvent object
- internalServerException
-
The exception that occurs when the service encounters an unexpected internal error. This is a temporary condition that will resolve itself with retries. We recommend implementing exponential backoff retry logic in your application.
Type: Exception
HTTP Status Code: 500
- messageStart
-
Indicates the start of a new message from the agent.
Type: HarnessMessageStartEvent object
- messageStop
-
Indicates the end of the current message.
Type: HarnessMessageStopEvent object
- metadata
-
Token usage and latency metrics for the invocation.
Type: HarnessMetadataEvent object
- runtimeClientError
-
The exception that occurs when there is an error in the runtime client. This can happen due to network issues, invalid configuration, or other client-side problems. Check the error message for specific details about the error.
Type: Exception
HTTP Status Code: 424
- validationException
-
The exception that occurs when the input fails to satisfy the constraints specified by the service. Check the error message for details about which input parameter is invalid and correct your request.
Type: Exception
HTTP Status Code: 400
Errors
For information about the errors that are common to all actions, see Common Error Types.
- AccessDeniedException
-
The exception that occurs when you do not have sufficient permissions to perform an action. Verify that your IAM policy includes the necessary permissions for the operation you are trying to perform.
HTTP Status Code: 403
- InternalServerException
-
The exception that occurs when the service encounters an unexpected internal error. This is a temporary condition that will resolve itself with retries. We recommend implementing exponential backoff retry logic in your application.
HTTP Status Code: 500
- ResourceNotFoundException
-
The exception that occurs when the specified resource does not exist. This can happen when using an invalid identifier or when trying to access a resource that has been deleted.
HTTP Status Code: 404
- ThrottlingException
-
The exception that occurs when the request was denied due to request throttling. This happens when you exceed the allowed request rate for an operation. Reduce the frequency of requests or implement exponential backoff retry logic in your application.
HTTP Status Code: 429
- ValidationException
-
The exception that occurs when the input fails to satisfy the constraints specified by the service. Check the error message for details about which input parameter is invalid and correct your request.
HTTP Status Code: 400
See Also
For more information about using this API in one of the language-specific AWS SDKs, see the following: