# Class CodeExecutorContext

java.lang.Object
com.google.adk.codeexecutors.CodeExecutorContext

public class CodeExecutorContext extends Object
The persistent context used to configure the code executor.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `CodeExecutorContext(Map<String,Object> sessionState)`
  Initializes the code executor context.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addInputFiles(List<CodeExecutionUtils.File> inputFiles)`
  Adds the input files to the code executor context.
  `void`
  `addProcessedFileNames(List<String> fileNames)`
  Adds the processed file name to the session state.
  `void`
  `clearInputFiles()`
  Removes the input files and processed file names to the code executor context.
  `int`
  `getErrorCount(String invocationId)`
  Gets the error count from the session state.
  `Optional<String>`
  `getExecutionId()`
  Gets the session ID for the code executor.
  `List<CodeExecutionUtils.File>`
  `getInputFiles()`
  Gets the code executor input file names from the session state.
  `List<String>`
  `getProcessedFileNames()`
  Gets the processed file names from the session state.
  `Map<String,Object>`
  `getStateDelta()`
  Gets the state delta to update in the persistent session state.
  `void`
  `incrementErrorCount(String invocationId)`
  Increments the error count from the session state.
  `void`
  `resetErrorCount(String invocationId)`
  Resets the error count from the session state.
  `void`
  `setExecutionId(String sessionId)`
  Sets the session ID for the code executor.
  `void`
  `updateCodeExecutionResult(String invocationId, String code, String resultStdout, String resultStderr)`
  Updates the code execution result.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### CodeExecutorContext

    public CodeExecutorContext(Map<String,Object> sessionState)
    Initializes the code executor context.
    Parameters:
      `sessionState` - The session state to get the code executor context from.

- ## Method Details

  - ### getStateDelta

    public Map<String,Object> getStateDelta()
    Gets the state delta to update in the persistent session state.
    Returns:
      The state delta to update in the persistent session state.

  - ### getExecutionId

    public Optional<String> getExecutionId()
    Gets the session ID for the code executor.
    Returns:
      The session ID for the code executor context.

  - ### setExecutionId

    public void setExecutionId(String sessionId)
    Sets the session ID for the code executor.
    Parameters:
      `sessionId` - The session ID for the code executor.

  - ### getProcessedFileNames

    public List<String> getProcessedFileNames()
    Gets the processed file names from the session state.
    Returns:
      A list of processed file names in the code executor context.

  - ### addProcessedFileNames

    public void addProcessedFileNames(List<String> fileNames)
    Adds the processed file name to the session state.
    Parameters:
      `fileNames` - The processed file names to add to the session state.

  - ### getInputFiles

    public List<CodeExecutionUtils.File> getInputFiles()
    Gets the code executor input file names from the session state.
    Returns:
      A list of input files in the code executor context.

  - ### addInputFiles

    public void addInputFiles(List<CodeExecutionUtils.File> inputFiles)
    Adds the input files to the code executor context.
    Parameters:
      `inputFiles` - The input files to add to the code executor context.

  - ### clearInputFiles

    public void clearInputFiles()
    Removes the input files and processed file names to the code executor context.

  - ### getErrorCount

    public int getErrorCount(String invocationId)
    Gets the error count from the session state.
    Parameters:
      `invocationId` - The invocation ID to get the error count for.
    Returns:
      The error count for the given invocation ID.

  - ### incrementErrorCount

    public void incrementErrorCount(String invocationId)
    Increments the error count from the session state.
    Parameters:
      `invocationId` - The invocation ID to increment the error count for.

  - ### resetErrorCount

    public void resetErrorCount(String invocationId)
    Resets the error count from the session state.
    Parameters:
      `invocationId` - The invocation ID to reset the error count for.

  - ### updateCodeExecutionResult

    public void updateCodeExecutionResult(String invocationId, String code, String resultStdout, String resultStderr)
    Updates the code execution result.
    Parameters:
      `invocationId` - The invocation ID to update the code execution result for.
      `code` - The code to execute.
      `resultStdout` - The standard output of the code execution.
      `resultStderr` - The standard error of the code execution.