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'
                }
            }
        },
    ],
    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.

  • 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