BedrockAgentCore / Client / start_code_interpreter_session

start_code_interpreter_session

BedrockAgentCore.Client.start_code_interpreter_session(**kwargs)

Creates and initializes a code interpreter session in Amazon Bedrock AgentCore. The session enables agents to execute code as part of their response generation, supporting programming languages such as Python for data analysis, visualization, and computation tasks.

To create a session, you must specify a code interpreter identifier and a name. The session remains active until it times out or you explicitly stop it using the StopCodeInterpreterSession operation.

The following operations are related to StartCodeInterpreterSession:

See also: AWS API Documentation

Request Syntax

response = client.start_code_interpreter_session(
    traceId='string',
    traceParent='string',
    codeInterpreterIdentifier='string',
    name='string',
    sessionTimeoutSeconds=123,
    certificates=[
        {
            'location': {
                'secretsManager': {
                    'secretArn': 'string'
                }
            }
        },
    ],
    filesystemConfigurations=[
        {
            's3FilesConfiguration': {
                'accessPointArn': 'string',
                'mountPath': 'string',
                'fileSystemArn': 'string'
            },
            'efsConfiguration': {
                'accessPointArn': 'string',
                'mountPath': 'string',
                'fileSystemArn': 'string'
            }
        },
    ],
    clientToken='string'
)
Parameters:
  • traceId (string) – The trace identifier for request tracking.

  • traceParent (string) – The parent trace information for distributed tracing.

  • codeInterpreterIdentifier (string) –

    [REQUIRED]

    The unique identifier of the code interpreter to use for this session. This identifier specifies which code interpreter environment to initialize for the session.

  • name (string) – The name of the code interpreter session. This name helps you identify and manage the session. The name does not need to be unique.

  • sessionTimeoutSeconds (integer) – The duration in seconds (time-to-live) after which the session automatically terminates, regardless of ongoing activity. Defaults to 900 seconds (15 minutes). Recommended minimum: 60 seconds. Maximum allowed: 28,800 seconds (8 hours).

  • certificates (list) –

    A list of certificates to install in the code interpreter session.

    • (dict) –

      A certificate to install in the browser or code interpreter session.

      • location (dict) – [REQUIRED]

        The location of the certificate.

        Note

        This is a Tagged Union structure. Only one of the following top level keys can be set: secretsManager.

        • secretsManager (dict) –

          The Amazon Web Services Secrets Manager location of the certificate.

          • secretArn (string) – [REQUIRED]

            The ARN of the Amazon Web Services Secrets Manager secret containing the certificate.

  • filesystemConfigurations (list) –

    The file system configurations to mount into the code interpreter session. Use these configurations to mount your own Amazon Simple Storage Service (Amazon S3) Files or Amazon Elastic File System (Amazon EFS) access points. Your session can then read and write your data. If you don’t specify this field, no additional file systems are mounted.

    • (dict) –

      Specifies a file system to mount into the session by providing exactly one of the following:

      • s3FilesConfiguration - Mounts an Amazon Simple Storage Service (Amazon S3) Files access point.

      • efsConfiguration - Mounts an Amazon Elastic File System (Amazon EFS) access point.

      Note

      This is a Tagged Union structure. Only one of the following top level keys can be set: s3FilesConfiguration, efsConfiguration.

      • s3FilesConfiguration (dict) –

        The configuration for mounting your own Amazon Simple Storage Service (Amazon S3) Files access point into the session.

        • accessPointArn (string) – [REQUIRED]

          The Amazon Resource Name (ARN) of the Amazon Simple Storage Service (Amazon S3) Files access point to mount.

        • mountPath (string) – [REQUIRED]

          The absolute path within the session at which the access point is mounted, for example /mnt/s3data. Each mount path must be unique across all file system configurations in the session.

        • fileSystemArn (string) – [REQUIRED]

          The Amazon Resource Name (ARN) of the Amazon Simple Storage Service (Amazon S3) Files file system that owns the access point.

      • efsConfiguration (dict) –

        The configuration for mounting your own Amazon Elastic File System (Amazon EFS) access point into the session.

        • accessPointArn (string) – [REQUIRED]

          The Amazon Resource Name (ARN) of the Amazon Elastic File System (Amazon EFS) access point to mount.

        • mountPath (string) – [REQUIRED]

          The absolute path within the session at which the access point is mounted, for example /mnt/efs. Each mount path must be unique across all file system configurations in the session.

        • fileSystemArn (string) – [REQUIRED]

          The Amazon Resource Name (ARN) of the Amazon Elastic File System (Amazon EFS) file system that owns the access point.

  • clientToken (string) –

    A unique, case-sensitive identifier to ensure that the API request completes no more than one time. If this token matches a previous request, Amazon Bedrock AgentCore ignores the request, but does not return an error. This parameter helps prevent the creation of duplicate sessions if there are temporary network issues.

    This field is autopopulated if not provided.

Return type:

dict

Returns:

Response Syntax

{
    'codeInterpreterIdentifier': 'string',
    'sessionId': 'string',
    'createdAt': datetime(2015, 1, 1)
}

Response Structure

  • (dict) –

    • codeInterpreterIdentifier (string) –

      The identifier of the code interpreter.

    • sessionId (string) –

      The unique identifier of the created code interpreter session.

    • createdAt (datetime) –

      The time at which the code interpreter session was created.

Exceptions

  • BedrockAgentCore.Client.exceptions.ServiceQuotaExceededException

  • BedrockAgentCore.Client.exceptions.AccessDeniedException

  • BedrockAgentCore.Client.exceptions.ConflictException

  • BedrockAgentCore.Client.exceptions.ValidationException

  • BedrockAgentCore.Client.exceptions.ResourceNotFoundException

  • BedrockAgentCore.Client.exceptions.ThrottlingException

  • BedrockAgentCore.Client.exceptions.InternalServerException