/AWS1/IF_BDC=>INVOKEAGENTRUNTIMECOMMAND()¶
About InvokeAgentRuntimeCommand¶
Executes a command in a runtime session container and streams the output back to the caller. This operation allows you to run shell commands within the agent runtime environment and receive real-time streaming responses including standard output and standard error.
To invoke a command, you must specify the agent runtime ARN and a runtime session ID. The command execution supports streaming responses, allowing you to receive output as it becomes available through contentStart, contentDelta, and contentStop events.
To use this operation, you must have the bedrock-agentcore:InvokeAgentRuntimeCommand permission.
Method Signature¶
METHODS /AWS1/IF_BDC~INVOKEAGENTRUNTIMECOMMAND
IMPORTING
!IV_CONTENTTYPE TYPE /AWS1/BDCMIMETYPE OPTIONAL
!IV_ACCEPT TYPE /AWS1/BDCMIMETYPE OPTIONAL
!IV_RUNTIMESESSIONID TYPE /AWS1/BDCSESSIONTYPE OPTIONAL
!IV_TRACEID TYPE /AWS1/BDCSTRING OPTIONAL
!IV_TRACEPARENT TYPE /AWS1/BDCSTRING OPTIONAL
!IV_TRACESTATE TYPE /AWS1/BDCSTRING OPTIONAL
!IV_BAGGAGE TYPE /AWS1/BDCSTRING OPTIONAL
!IV_AGENTRUNTIMEARN TYPE /AWS1/BDCSTRING OPTIONAL
!IV_QUALIFIER TYPE /AWS1/BDCSTRING OPTIONAL
!IV_ACCOUNTID TYPE /AWS1/BDCSTRING OPTIONAL
!IO_BODY TYPE REF TO /AWS1/CL_BDCINVAGRUNCMDREQBODY OPTIONAL
RETURNING
VALUE(OO_OUTPUT) TYPE REF TO /aws1/cl_bdcinvagentruncmdrsp
RAISING
/AWS1/CX_BDCACCESSDENIEDEX
/AWS1/CX_BDCINTERNALSERVEREX
/AWS1/CX_BDCRESOURCENOTFOUNDEX
/AWS1/CX_BDCRUNTIMECLIENTERROR
/AWS1/CX_BDCSERVICEQUOTAEXCDEX
/AWS1/CX_BDCTHROTTLINGEX
/AWS1/CX_BDCVALIDATIONEX
/AWS1/CX_BDCCLIENTEXC
/AWS1/CX_BDCSERVEREXC
/AWS1/CX_RT_TECHNICAL_GENERIC
/AWS1/CX_RT_SERVICE_GENERIC.
IMPORTING¶
Required arguments:¶
iv_agentruntimearn TYPE /AWS1/BDCSTRING /AWS1/BDCSTRING¶
The Amazon Resource Name (ARN) of the agent runtime on which to execute the command. This identifies the specific agent runtime environment where the command will run.
io_body TYPE REF TO /AWS1/CL_BDCINVAGRUNCMDREQBODY /AWS1/CL_BDCINVAGRUNCMDREQBODY¶
The request body containing the command to execute and optional configuration parameters such as timeout settings.
Optional arguments:¶
iv_contenttype TYPE /AWS1/BDCMIMETYPE /AWS1/BDCMIMETYPE¶
The MIME type of the input data in the request 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 command. This tells the agent runtime what format to use for the response data. Common values include application/json for JSON data.
iv_runtimesessionid TYPE /AWS1/BDCSESSIONTYPE /AWS1/BDCSESSIONTYPE¶
The unique identifier of the runtime session in which to execute the command. This session ID is used to maintain state and context across multiple command invocations.
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 is an endpoint name that points to a specific version. If not specified, Amazon Bedrock AgentCore uses the default endpoint of the agent runtime.
iv_accountid TYPE /AWS1/BDCSTRING /AWS1/BDCSTRING¶
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.
RETURNING¶
oo_output TYPE REF TO /aws1/cl_bdcinvagentruncmdrsp /AWS1/CL_BDCINVAGENTRUNCMDRSP¶
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->invokeagentruntimecommand(
io_body = new /aws1/cl_bdcinvagruncmdreqbody(
iv_command = |string|
iv_timeout = 123
)
iv_accept = |string|
iv_accountid = |string|
iv_agentruntimearn = |string|
iv_baggage = |string|
iv_contenttype = |string|
iv_qualifier = |string|
iv_runtimesessionid = |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_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_httpresponsecode = lo_result->get_statuscode( ).
TRY.
WHILE lo_result->get_stream( )->/aws1/if_rt_stream_reader~data_available( ) = ABAP_TRUE.
lo_event = lo_result->get_stream( )->READ( ).
IF lo_event->get_chunk( ) IS NOT INITIAL.
" process this kind of event
ENDIF.
ENDWHILE.
CATCH /aws1/cx_bdcaccessdeniedex.
" handle error in stream
CATCH /aws1/cx_bdcinternalserverex.
" handle error in stream
CATCH /aws1/cx_bdcvalidationex.
" handle error in stream
CATCH /aws1/cx_bdcthrottlingex.
" handle error in stream
CATCH /aws1/cx_bdcresourcenotfoundex.
" handle error in stream
CATCH /aws1/cx_bdcservicequotaexcdex.
" handle error in stream
CATCH /aws1/cx_bdcruntimeclienterror.
" handle error in stream
ENDTRY.
ENDIF.