GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • ADK for TypeScript: API Reference

This view

  • Original page
  • New address

GeezerVison is showing adk.dev — ContainerCodeExecutor | ADK for TypeScript: API Reference - v2.5.0

  • ContainerCodeExecutor

Class ContainerCodeExecutor

A code executor that runs model-generated code inside a hardened Docker container via the dockerode client.

Security note: this executor runs model-generated code, which may be influenced by untrusted input (e.g. via prompt injection). By default the container is started with networking disabled and all Linux capabilities dropped so the executed code cannot reach the network (including the cloud metadata endpoint at 169.254.169.254) or escalate privileges. Networking can be re-enabled via networkEnabled: true when the executed code is trusted.

A separate container is started per session (keyed on appName, userId, and session.id from ExecuteCodeParams.invocationContext) rather than one container shared across every call: codeExecutor is a single property set once on an LlmAgent instance, and that instance is the long-lived object serving every session the agent handles, so a single shared container would let one session's files, environment, and background processes persist into a later, unrelated session's execution. A container is still reused across multiple calls within the same session, so the per-call container-startup cost is paid once per session, not once per call. Set maxContainers to bound how many session containers run at once; beyond it, the least recently used idle one is stopped.

Limitations: this executor runs a code string only. inputFiles and args on the request are not copied into the container, and output files are not collected (outputFiles is always empty), so tools that stage resource files or read artifacts back (e.g. RunSkillScriptTool) are not yet supported. Sending files in and out via putArchive/getArchive is future work.

Hierarchy (View Summary)

  • BaseCodeExecutor
    • ContainerCodeExecutor
  • Defined in core/src/code_executors/container_code_executor.ts:134

Constructors

constructor

  • new ContainerCodeExecutor(
        options?: ContainerCodeExecutorOptions,
    ): ContainerCodeExecutor

    Parameters

    • options: ContainerCodeExecutorOptions = {}

    Returns ContainerCodeExecutor

    Overrides BaseCodeExecutor.constructor

    • Defined in core/src/code_executors/container_code_executor.ts:153

Properties

Readonly[BASE_CODE_EXECUTOR_SIGNATURE_SYMBOL]

"[BASE_CODE_EXECUTOR_SIGNATURE_SYMBOL]": true

A unique symbol to identify BaseCodeExecutor class.

Inherited from BaseCodeExecutor.[BASE_CODE_EXECUTOR_SIGNATURE_SYMBOL]

  • Defined in core/src/code_executors/base_code_executor.ts:52

codeBlockDelimiters

codeBlockDelimiters: [string, string][] = ...

The list of the enclosing delimiters to identify the code blocks. For example, the delimiter('javascript\\n', '\\n') can be used to identify code blocks with the following format:

 console.log("hello")

Inherited from BaseCodeExecutor.codeBlockDelimiters

  • Defined in core/src/code_executors/base_code_executor.ts:82

errorRetryAttempts

errorRetryAttempts: number = 2

The number of attempts to retry on consecutive code execution errors. Default to 2.

Inherited from BaseCodeExecutor.errorRetryAttempts

  • Defined in core/src/code_executors/base_code_executor.ts:71

executionResultDelimiters

executionResultDelimiters: [string, string] = ...

The delimiters to format the code execution result.

Inherited from BaseCodeExecutor.executionResultDelimiters

  • Defined in core/src/code_executors/base_code_executor.ts:94

optimizeDataFile

optimizeDataFile: boolean = false

If true, extract and process data files from the model request and attach them to the code executor.

Supported data file MimeTypes are [text/csv]. Default to false.

Inherited from BaseCodeExecutor.optimizeDataFile

  • Defined in core/src/code_executors/base_code_executor.ts:60

stateful

stateful: boolean = false

Whether the code executor is stateful. Default to false.

Inherited from BaseCodeExecutor.stateful

  • Defined in core/src/code_executors/base_code_executor.ts:65

Methods

close

  • close(): Promise<void>

    Stops and removes every session's container. Waits for container starts that are still in flight, so no container is left running after it resolves. Safe to call when none has been started, and concurrent calls share one teardown. Provided for deterministic teardown in tests and app shutdown.

    Returns Promise<void>

    • Defined in core/src/code_executors/container_code_executor.ts:260

executeCode

  • executeCode(params: ExecuteCodeParams): Promise<CodeExecutionResult>

    Executes code and return the code execution result.

    Parameters

    • params: ExecuteCodeParams

      The parameters for executing code.

    Returns Promise<CodeExecutionResult>

    The result of the code execution.

    Overrides BaseCodeExecutor.executeCode

    • Defined in core/src/code_executors/container_code_executor.ts:190
Constructors
constructor
Properties
[BASE_CODE_EXECUTOR_SIGNATURE_SYMBOL]codeBlockDelimiterserrorRetryAttemptsexecutionResultDelimitersoptimizeDataFilestateful
Methods
closeexecuteCode
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.