Skip to content

/AWS1/CL_BDC=>INVOKEAGENTRUNTIME()

About InvokeAgentRuntime

Sends a request to an agent runtime in Amazon Bedrock and receives responses in real-time. The agent processes the request using the configured foundation model and any associated knowledge bases or action groups.

To invoke an agent runtime, you must specify the agent runtime ARN and provide a payload containing your request. You can optionally specify a qualifier to target a specific version or alias 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.

Method Signature

IMPORTING

Required arguments:

iv_agentruntimearn TYPE /AWS1/BDCSTRING /AWS1/BDCSTRING

The Amazon Web Services Resource Name (ARN) of the agent runtime to invoke. The ARN uniquely identifies the agent runtime resource in Amazon Bedrock.

iv_payload TYPE /AWS1/BDCBODY /AWS1/BDCBODY

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.

Optional arguments:

iv_contenttype TYPE /AWS1/BDCMIMETYPE /AWS1/BDCMIMETYPE

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.

iv_accept TYPE /AWS1/BDCMIMETYPE /AWS1/BDCMIMETYPE

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.

iv_mcpsessionid TYPE /AWS1/BDCSTRINGTYPE /AWS1/BDCSTRINGTYPE

The identifier of the MCP session.

iv_runtimesessionid TYPE /AWS1/BDCSESSIONTYPE /AWS1/BDCSESSIONTYPE

The identifier of the runtime session.

iv_mcpprotocolversion TYPE /AWS1/BDCSTRINGTYPE /AWS1/BDCSTRINGTYPE

The version of the MCP protocol being used.

iv_runtimeuserid TYPE /AWS1/BDCSTRINGTYPE /AWS1/BDCSTRINGTYPE

The identifier of the runtime user.

iv_traceid TYPE /AWS1/BDCSTRING /AWS1/BDCSTRING

The trace identifier for request tracking.

iv_traceparent TYPE /AWS1/BDCSTRING /AWS1/BDCSTRING

The parent trace information for distributed tracing.

iv_tracestate TYPE /AWS1/BDCSTRING /AWS1/BDCSTRING

The trace state information for distributed tracing.

iv_baggage TYPE /AWS1/BDCSTRING /AWS1/BDCSTRING

Additional context information for distributed tracing.

iv_qualifier TYPE /AWS1/BDCSTRING /AWS1/BDCSTRING

The qualifier to use for the agent runtime. This can be a version number or an alias name that points to a specific version. If not specified, Amazon Bedrock uses the default version of the agent runtime.

RETURNING

oo_output TYPE REF TO /aws1/cl_bdcinvkagentrtimersp /AWS1/CL_BDCINVKAGENTRTIMERSP

Domain /AWS1/RT_ACCOUNT_ID
Primitive Type NUMC

Examples

Syntax Example

This is an example of the syntax for calling the method. It includes every possible argument and initializes every possible value. The data provided is not necessarily semantically accurate (for example the value "string" may be provided for something that is intended to be an instance ID, or in some cases two arguments may be mutually exclusive). The syntax shows the ABAP syntax for creating the various data structures.

DATA(lo_result) = lo_client->/aws1/if_bdc~invokeagentruntime(
  iv_accept = |string|
  iv_agentruntimearn = |string|
  iv_baggage = |string|
  iv_contenttype = |string|
  iv_mcpprotocolversion = |string|
  iv_mcpsessionid = |string|
  iv_payload = '5347567362473873563239796247513D'
  iv_qualifier = |string|
  iv_runtimesessionid = |string|
  iv_runtimeuserid = |string|
  iv_traceid = |string|
  iv_traceparent = |string|
  iv_tracestate = |string|
).

This is an example of reading all possible response values

lo_result = lo_result.
IF lo_result IS NOT INITIAL.
  lv_sessionid = lo_result->get_runtimesessionid( ).
  lv_sessionid = lo_result->get_mcpsessionid( ).
  lv_string = lo_result->get_mcpprotocolversion( ).
  lv_string = lo_result->get_traceid( ).
  lv_string = lo_result->get_traceparent( ).
  lv_string = lo_result->get_tracestate( ).
  lv_string = lo_result->get_baggage( ).
  lv_string = lo_result->get_contenttype( ).
  lv_responsestream = lo_result->get_response( ).
  lv_httpresponsecode = lo_result->get_statuscode( ).
ENDIF.