Class HostedCodeExecutionCallPart

All Implemented Interfaces:
PropertyChangeSource, ThoughtSignature, Rebindable

public class HostedCodeExecutionCallPart extends ModelTextPart
A specialized part representing a request from the model to execute code on the server (e.g., Python in OpenAI's Code Interpreter or Gemini's Code Execution).

This part captures the source code and the language intended for execution. It is used to maintain the narrative of the model's actions in the history, allowing for accurate replay across different AI providers.

Author:
anahata
  • Field Details

    • language

      private String language
      The programming language requested for the remote execution (e.g., "python", "javascript").
  • Constructor Details

    • HostedCodeExecutionCallPart

      public HostedCodeExecutionCallPart(AbstractModelMessage message, String code, String language, byte[] thoughtSignature)
      Constructs a new ModelCodeCallPart.
      Parameters:
      message - The model message that initiated the code execution request.
      code - The source code to be executed.
      language - The programming language of the code.
      thoughtSignature - The signature of the thought process associated with this call, if any.
  • Method Details

    • asText

      public String asText()
      Returns the content of the part as a simple string. This is implemented by subclasses.

      Returns a formatted string indicating a hosted code execution request.

      Overrides:
      asText in class TextPart
      Returns:
      The text representation of the part.
    • getDefaultMaxDepth

      protected int getDefaultMaxDepth()
      Template method hook for subclasses to provide their specific default max depth policy. This is the fallback value used when no explicit maxDepth is set on the instance. Returns the default maximum depth to keep a text part in context, as defined in the agi configuration. Returns the default maximum depth for thoughts if this is a thought part, otherwise falls back to the standard text part depth.

      Returns the default maximum depth to keep a hosted code execution call part in context.

      Overrides:
      getDefaultMaxDepth in class ModelTextPart
      Returns:
      The default maximum depth for this part type.