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