Skip to content

Executes a command in a runtime session container and streams the output back to the caller

Description

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.

Usage

bedrockagentcore_invoke_agent_runtime_command(contentType, accept,
  runtimeSessionId, traceId, traceParent, traceState, baggage,
  agentRuntimeArn, qualifier, accountId, body)

Arguments

  • 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.

  • 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.

  • runtimeSessionId

    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.

  • 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 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.

  • 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.

  • body

    [required] The request body containing the command to execute and optional configuration parameters such as timeout settings.

Value

A list with the following syntax:

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

Request syntax

svc$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 = list(
    command = "string",
    timeout = 123
  )
)