Skip to content

start_code_interpreter_session

Operation

start_code_interpreter_session

start_code_interpreter_session(request: StartCodeInterpreterSessionInput | StartCodeInterpreterSessionInputDict | None = None, /, *, plugins: list[Plugin] | None = None, **kwargs: Unpack[StartCodeInterpreterSessionInputDict]) -> StartCodeInterpreterSessionOutput

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:

Parameters:

Name Type Description Default
request StartCodeInterpreterSessionInput | StartCodeInterpreterSessionInputDict | None

The input as a model or dictionary. Pass this or keyword arguments, not both.

None
plugins list[Plugin] | None

A list of callables that modify the configuration dynamically. Changes made by these plugins only apply for the duration of the operation execution and will not affect any other operation invocations.

None
**kwargs Unpack[StartCodeInterpreterSessionInputDict]

The input fields as keyword arguments.

{}

Returns:

Type Description
StartCodeInterpreterSessionOutput

An instance of StartCodeInterpreterSessionOutput.

start_code_interpreter_session async

start_code_interpreter_session(request: StartCodeInterpreterSessionInput | StartCodeInterpreterSessionInputDict | None = None, /, *, plugins: list[Plugin] | None = None, **kwargs: Unpack[StartCodeInterpreterSessionInputDict]) -> StartCodeInterpreterSessionOutput

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:

Parameters:

Name Type Description Default
request StartCodeInterpreterSessionInput | StartCodeInterpreterSessionInputDict | None

The input as a model or dictionary. Pass this or keyword arguments, not both.

None
plugins list[Plugin] | None

A list of callables that modify the configuration dynamically. Changes made by these plugins only apply for the duration of the operation execution and will not affect any other operation invocations.

None
**kwargs Unpack[StartCodeInterpreterSessionInputDict]

The input fields as keyword arguments.

{}

Returns:

Type Description
StartCodeInterpreterSessionOutput

An instance of StartCodeInterpreterSessionOutput.

Input

Pass the input as keyword arguments, a positional dictionary, or a positional model object. Pass plugins separately as a keyword argument.

StartCodeInterpreterSessionInputDict

Bases: TypedDict

Dictionary form of StartCodeInterpreterSessionInput.

Attributes

certificates instance-attribute
certificates: Sequence[Certificate | CertificateDict] | None

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

client_token instance-attribute
client_token: str | None

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.

code_interpreter_identifier instance-attribute
code_interpreter_identifier: Required[str]

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

filesystem_configurations instance-attribute

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.

name instance-attribute
name: str | None

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

session_timeout_seconds instance-attribute
session_timeout_seconds: int | None

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

trace_id instance-attribute
trace_id: str | None

The trace identifier for request tracking.

trace_parent instance-attribute
trace_parent: str | None

The parent trace information for distributed tracing.

StartCodeInterpreterSessionInput dataclass

Bases: _SerdeShape

Dataclass for StartCodeInterpreterSessionInput structure.

Attributes

certificates class-attribute instance-attribute
certificates: list[Certificate] | None = ...

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

client_token class-attribute instance-attribute
client_token: str | None = ...

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.

code_interpreter_identifier class-attribute instance-attribute
code_interpreter_identifier: str | None = ...

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

filesystem_configurations class-attribute instance-attribute
filesystem_configurations: list[ToolsFileSystemConfiguration] | None = ...

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.

name class-attribute instance-attribute
name: str | None = ...

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

session_timeout_seconds class-attribute instance-attribute
session_timeout_seconds: int = ...

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

trace_id class-attribute instance-attribute
trace_id: str | None = ...

The trace identifier for request tracking.

trace_parent class-attribute instance-attribute
trace_parent: str | None = ...

The parent trace information for distributed tracing.

Output

StartCodeInterpreterSessionOutput dataclass

Bases: _SerdeShape

Dataclass for StartCodeInterpreterSessionOutput structure.

Attributes

code_interpreter_identifier instance-attribute
code_interpreter_identifier: str

The identifier of the code interpreter.

created_at instance-attribute
created_at: datetime

The time at which the code interpreter session was created.

response_metadata class-attribute instance-attribute
response_metadata: ResponseMetadata = ...

Metadata about the response that produced this output. Use this to recover the request identifiers a service's support team needs in order to investigate a call. Members of the metadata are individually optional.

session_id instance-attribute
session_id: str

The unique identifier of the created code interpreter session.