Skip to content

Invoke Agent Runtime

bedrockagentcore_invoke_agent_runtime R Documentation

Sends a request to an agent or tool hosted in an Amazon Bedrock AgentCore Runtime and receives responses in real-time

Description

Sends a request to an agent or tool hosted in an Amazon Bedrock AgentCore Runtime and receives responses in real-time.

To invoke an agent, you can specify either the AgentCore Runtime ARN or the agent ID with an account ID, and provide a payload containing your request. When you use the agent ID instead of the full ARN, you don't need to URL-encode the identifier. You can optionally specify a qualifier to target a specific endpoint of the agent.

This operation supports streaming responses, allowing you to receive partial responses as they become available. We recommend using pagination to ensure that the operation returns quickly and successfully when processing large responses.

For example code, see Invoke an AgentCore Runtime agent.

If you're integrating your agent with OAuth, you can't use the Amazon Web Services SDK to call invoke_agent_runtime. Instead, make a HTTPS request to invoke_agent_runtime. For an example, see Authenticate and authorize with Inbound Auth and Outbound Auth.

To use this operation, you must have the bedrock-agentcore:InvokeAgentRuntime permission. If you are making a call to invoke_agent_runtime on behalf of a user ID with the X-Amzn-Bedrock-AgentCore-Runtime-User-Id header, You require permissions to both actions (bedrock-agentcore:InvokeAgentRuntime and bedrock-agentcore:InvokeAgentRuntimeForUser).

Usage

bedrockagentcore_invoke_agent_runtime(contentType, accept, mcpSessionId,
  runtimeSessionId, mcpProtocolVersion, runtimeUserId, traceId,
  traceParent, traceState, baggage, agentRuntimeArn, qualifier, accountId,
  payload)

Arguments

contentType

The MIME type of the input data in the payload. This tells the agent runtime how to interpret the payload data. Common values include application/json for JSON data.

accept

The desired MIME type for the response from the agent runtime. This tells the agent runtime what format to use for the response data. Common values include application/json for JSON data.

mcpSessionId

The identifier of the MCP session.

runtimeSessionId

The identifier of the runtime session.

mcpProtocolVersion

The version of the MCP protocol being used.

runtimeUserId

The identifier of the runtime user.

traceId

The trace identifier for request tracking.

traceParent

The parent trace information for distributed tracing.

traceState

The trace state information for distributed tracing.

baggage

Additional context information for distributed tracing.

agentRuntimeArn

[required] The identifier of the agent runtime to invoke. You can specify either the full Amazon Web Services Resource Name (ARN) or the agent ID. If you use the agent ID, you must also provide the accountId query parameter.

qualifier

The qualifier to use for the agent runtime. This is an endpoint name that points to a specific version. If not specified, Amazon Bedrock AgentCore uses the default endpoint of the agent runtime.

accountId

The identifier of the Amazon Web Services account for the agent runtime resource. This parameter is required when you specify an agent ID instead of the full ARN for agentRuntimeArn.

payload

[required] The input data to send to the agent runtime. The format of this data depends on the specific agent configuration and must match the specified content type. For most agents, this is a JSON object containing the user's request.

Value

A list with the following syntax:

list(
  runtimeSessionId = "string",
  mcpSessionId = "string",
  mcpProtocolVersion = "string",
  traceId = "string",
  traceParent = "string",
  traceState = "string",
  baggage = "string",
  contentType = "string",
  response = raw,
  statusCode = 123
)

Request syntax

svc$invoke_agent_runtime(
  contentType = "string",
  accept = "string",
  mcpSessionId = "string",
  runtimeSessionId = "string",
  mcpProtocolVersion = "string",
  runtimeUserId = "string",
  traceId = "string",
  traceParent = "string",
  traceState = "string",
  baggage = "string",
  agentRuntimeArn = "string",
  qualifier = "string",
  accountId = "string",
  payload = raw
)