Amazon Bedrock AgentCore

2026/03/16 - Amazon Bedrock AgentCore - 1 new api methods

Changes  Provide support to perform deterministic operations on agent runtime through shell command executions via the new InvokeAgentRuntimeCommand API

InvokeAgentRuntimeCommand (new) Link ΒΆ

Executes a command in a runtime session container. Returns streaming output with contentStart, contentDelta, and contentStop events.

See also: AWS API Documentation

Request Syntax

client.invoke_agent_runtime_command(
    contentType='string',
    accept='string',
    runtimeSessionId='string',
    traceId='string',
    traceParent='string',
    traceState='string',
    baggage='string',
    agentRuntimeArn='string',
    qualifier='string',
    accountId='string',
    body={
        'command': 'string',
        'timeout': 123
    }
)
type contentType:

string

param contentType:

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.

type accept:

string

param accept:

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.

type runtimeSessionId:

string

param runtimeSessionId:

Runtime session identifier

This field is autopopulated if not provided.

type traceId:

string

param traceId:

The trace identifier for request tracking.

type traceParent:

string

param traceParent:

The parent trace information for distributed tracing.

type traceState:

string

param traceState:

The trace state information for distributed tracing.

type baggage:

string

param baggage:

Additional context information for distributed tracing.

type agentRuntimeArn:

string

param agentRuntimeArn:

[REQUIRED]

ARN of the agent runtime

type qualifier:

string

param qualifier:

Version or alias qualifier

type accountId:

string

param accountId:

Account ID (12 digits)

type body:

dict

param body:

[REQUIRED]

Request body containing command and timeout

  • command (string) -- [REQUIRED]

    The command to execute in the runtime container

  • timeout (integer) --

    Command timeout in seconds (default: 300, min:1, max: 3600)

rtype:

dict

returns:

The response of this operation contains an :class:`.EventStream` member. When iterated the :class:`.EventStream` will yield events based on the structure below, where only one of the top level keys will be present for any given event.

Response Syntax

{
    'runtimeSessionId': 'string',
    'traceId': 'string',
    'traceParent': 'string',
    'traceState': 'string',
    'baggage': 'string',
    'contentType': 'string',
    'statusCode': 123,
    'stream': EventStream({
        'chunk': {
            'contentStart': {},
            'contentDelta': {
                'stdout': 'string',
                'stderr': 'string'
            },
            'contentStop': {
                'exitCode': 123,
                'status': 'COMPLETED'|'TIMED_OUT'
            }
        },
        'accessDeniedException': {
            'message': 'string'
        },
        'internalServerException': {
            'message': 'string'
        },
        'resourceNotFoundException': {
            'message': 'string'
        },
        'serviceQuotaExceededException': {
            'message': 'string'
        },
        'throttlingException': {
            'message': 'string'
        },
        'validationException': {
            'message': 'string',
            'reason': 'CannotParse'|'FieldValidationFailed'|'IdempotentParameterMismatchException'|'EventInOtherSession'|'ResourceConflict',
            'fieldList': [
                {
                    'name': 'string',
                    'message': 'string'
                },
            ]
        },
        'runtimeClientError': {
            'message': 'string'
        }
    })
}

Response Structure

  • (dict) --

    Response for InvokeAgentRuntimeCommand operation

    • runtimeSessionId (string) --

      Runtime session identifier

    • traceId (string) --

      The trace identifier for request tracking.

    • traceParent (string) --

      The parent trace information for distributed tracing.

    • traceState (string) --

      The trace state information for distributed tracing.

    • baggage (string) --

      Additional context information for distributed tracing.

    • contentType (string) --

      The MIME type of the response data. This indicates how to interpret the response data. Common values include application/json for JSON data.

    • statusCode (integer) --

      The HTTP status code of the response. A status code of 200 indicates a successful operation. Other status codes indicate various error conditions.

    • stream (:class:`.EventStream`) --

      Streaming output containing command execution events

      • chunk (dict) --

        Response chunk containing command execution events

        • contentStart (dict) --

          First chunk - indicates command execution has started

        • contentDelta (dict) --

          Middle chunks - stdout/stderr output

          • stdout (string) --

            Standard output content

          • stderr (string) --

            Standard error content

        • contentStop (dict) --

          Last chunk - indicates command execution has completed

          • exitCode (integer) --

            Exit code: 0 = success, -1 = platform error, >0 = command error

          • status (string) --

            Execution status

      • accessDeniedException (dict) --

        Exception events for error streaming

        • message (string) --

      • internalServerException (dict) --

        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.

        • message (string) --

      • resourceNotFoundException (dict) --

        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.

        • message (string) --

      • serviceQuotaExceededException (dict) --

        The exception that occurs when the request would cause a service quota to be exceeded. Review your service quotas and either reduce your request rate or request a quota increase.

        • message (string) --

      • throttlingException (dict) --

        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.

        • message (string) --

      • validationException (dict) --

        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.

        • message (string) --

        • reason (string) --

        • fieldList (list) --

          • (dict) --

            Stores information about a field passed inside a request that resulted in an exception.

            • name (string) --

              The name of the field.

            • message (string) --

              A message describing why this field failed validation.

      • runtimeClientError (dict) --

        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.

        • message (string) --