Class AgiConfig

All Implemented Interfaces:
PropertyChangeSource, Rebindable
Direct Known Subclasses:
SwingAgiConfig

public class AgiConfig extends BasicPropertyChangeSource
The definitive configuration blueprint for an individual Agi session.

Defines the operational parameters, enabled toolkits, AI providers, and context management policies. This class serves as the 'DNA' of an Agi, ensuring architectural consistency and facilitating model-agnostic orchestration across session restarts.

Author:
anahata
  • Field Details

    • asiContainer

      @NonNull private transient @NonNull AbstractAsiContainer asiContainer
      A reference to the global, application-wide configuration.
    • sessionId

      @NonNull private @NonNull String sessionId
      The unique identifier for this specific agi session.
    • parentUuid

      private String parentUuid
      The UUID of the AGI that spawned this session, if any.
    • agi

      private Agi agi
      A late-binding reference to the parent Agi. Set during Agi construction.
    • selectedProviderUuid

      private String selectedProviderUuid
      The UUID of the AI provider currently selected for this session.
    • selectedModelId

      private String selectedModelId
      The ID of the AI model currently selected for this session.
    • providerUuids

      private List<String> providerUuids
      The list of AI provider UUIDs available for this agi session.
    • toolClasses

      private final List<Class<?>> toolClasses
      The list of tool classes to be used in this agi session.
    • localToolsEnabled

      private boolean localToolsEnabled
      If true, local Java tools are enabled.
    • hostedToolsEnabled

      private boolean hostedToolsEnabled
      If true, server-side tools (like Google Search) are enabled.
    • autoReplyTools

      private boolean autoReplyTools
      If true, the agi loop will automatically re-prompt the model after executing tools.
    • streaming

      private boolean streaming
      If true, token streaming is enabled for model responses.
    • includeThoughts

      private boolean includeThoughts
      If true, the model is requested to include its internal thought process in the response.
    • expandThoughts

      private boolean expandThoughts
      If true, thought parts are initially expanded in the UI.
    • expandTools

      private ExpandToolsPreference expandTools
      Preference for expanding tool calls in the UI.
    • apiMaxRetries

      private int apiMaxRetries
      The maximum number of times to retry an API call on failure.
    • apiInitialDelayMillis

      private long apiInitialDelayMillis
      The initial delay in milliseconds before the first retry.
    • apiMaxDelayMillis

      private long apiMaxDelayMillis
      The maximum delay in milliseconds between retries.
    • tokenThreshold

      private int tokenThreshold
      The maximum number of tokens allowed in the context window.
    • defaultBlobPartMaxDepth

      private int defaultBlobPartMaxDepth
      The default maximum depth a BlobPart should be kept in context.
    • defaultToolMaxDepth

      private int defaultToolMaxDepth
      The default maximum depth a ToolResponse should be kept in context.
    • defaultThoughtPartMaxDepth

      private int defaultThoughtPartMaxDepth
      The default maximum depth a model thought should be kept in context.
    • defaultTextPartMaxDepth

      private int defaultTextPartMaxDepth
      The default maximum depth a TextPart should be kept in context.
    • defaultModelCodeExecutionMaxDepth

      private int defaultModelCodeExecutionMaxDepth
      The default maximum depth a model code execution part should be kept in context.
    • defaultWebSearchMaxDepth

      private int defaultWebSearchMaxDepth
      The default maximum depth a web search call part should be kept in context.
    • defaultResponseModalities

      private List<String> defaultResponseModalities
      The default response modalities for this agi session.
  • Constructor Details

    • AgiConfig

      public AgiConfig(@NonNull @NonNull AbstractAsiContainer asiConfig)
      Constructs a new AgiConfig with a randomly generated session ID.
      Parameters:
      asiConfig - The global AI configuration.
    • AgiConfig

      public AgiConfig(@NonNull @NonNull AbstractAsiContainer asiConfig, @NonNull @NonNull String sessionId)
      Constructs a new AgiConfig with a specific session ID.
      Parameters:
      asiConfig - The global AI configuration.
      sessionId - The unique session ID.
  • Method Details

    • setSelectedProviderUuid

      public void setSelectedProviderUuid(String selectedProviderUuid)
      Sets the selected provider UUID and fires a property change event.
      Parameters:
      selectedProviderUuid - The UUID of the selected provider.
    • setSelectedModelId

      public void setSelectedModelId(String selectedModelId)
      Sets the selected model ID and fires a property change event.
      Parameters:
      selectedModelId - The ID of the selected model.
    • setAutoReplyTools

      public void setAutoReplyTools(boolean autoReplyTools)
      Sets whether tool calls should be auto-replied and fires a property change event.
      Parameters:
      autoReplyTools - true to enable auto-reply.
    • setStreaming

      public void setStreaming(boolean streaming)
      Sets whether streaming is enabled and fires a property change event.
      Parameters:
      streaming - true to enable streaming.
    • setIncludeThoughts

      public void setIncludeThoughts(boolean includeThoughts)
      Sets whether thoughts should be included and fires a property change event.
      Parameters:
      includeThoughts - true to include thoughts.
    • setExpandTools

      public void setExpandTools(ExpandToolsPreference expandTools)
      Sets the tool expansion preference and fires a property change event.
      Parameters:
      expandTools - The expansion preference.
    • setExpandThoughts

      public void setExpandThoughts(boolean expandThoughts)
      Sets whether thoughts should be expanded and fires a property change event.
      Parameters:
      expandThoughts - true to expand thoughts.
    • setApiMaxRetries

      public void setApiMaxRetries(int apiMaxRetries)
      Sets the max API retries and fires a property change event.
      Parameters:
      apiMaxRetries - The maximum number of retries.
    • setApiInitialDelayMillis

      public void setApiInitialDelayMillis(long apiInitialDelayMillis)
      Sets the initial API retry delay and fires a property change event.
      Parameters:
      apiInitialDelayMillis - The initial delay in milliseconds.
    • setApiMaxDelayMillis

      public void setApiMaxDelayMillis(long apiMaxDelayMillis)
      Sets the max API retry delay and fires a property change event.
      Parameters:
      apiMaxDelayMillis - The maximum delay in milliseconds.
    • setTokenThreshold

      public void setTokenThreshold(int tokenThreshold)
      Sets the token threshold and fires a property change event.
      Parameters:
      tokenThreshold - The threshold token count.
    • setDefaultTextPartMaxDepth

      public void setDefaultTextPartMaxDepth(int defaultTextPartMaxDepth)
      Sets the default text part max depth and fires a property change event.
      Parameters:
      defaultTextPartMaxDepth - The default max depth.
    • setDefaultToolMaxDepth

      public void setDefaultToolMaxDepth(int defaultToolMaxDepth)
      Sets the default tool response max depth and fires a property change event.
      Parameters:
      defaultToolMaxDepth - The default max depth.
    • setDefaultBlobPartMaxDepth

      public void setDefaultBlobPartMaxDepth(int defaultBlobPartMaxDepth)
      Sets the default blob part max depth and fires a property change event.
      Parameters:
      defaultBlobPartMaxDepth - The default max depth.
    • setDefaultThoughtPartMaxDepth

      public void setDefaultThoughtPartMaxDepth(int defaultThoughtPartMaxDepth)
      Sets the default thought part max depth and fires a property change event.
      Parameters:
      defaultThoughtPartMaxDepth - The default max depth.
    • setDefaultModelCodeExecutionMaxDepth

      public void setDefaultModelCodeExecutionMaxDepth(int defaultModelCodeExecutionMaxDepth)
      Sets the default model code execution max depth and fires a property change event.
      Parameters:
      defaultModelCodeExecutionMaxDepth - The default max depth.
    • setDefaultWebSearchMaxDepth

      public void setDefaultWebSearchMaxDepth(int defaultWebSearchMaxDepth)
      Sets the default web search max depth and fires a property change event.
      Parameters:
      defaultWebSearchMaxDepth - The default max depth.
    • setLocalToolsEnabled

      public void setLocalToolsEnabled(boolean enabled)
      Configures the session to utilize local Java-based toolkits.

      Enabling local tools automatically disables hosted server tools to maintain environmental consistency.

      Parameters:
      enabled - true to enable local toolkits.
    • setHostedToolsEnabled

      public void setHostedToolsEnabled(boolean enabled)
      Configures the session to utilize hosted server-side tools (e.g., Google Search).

      Enabling hosted tools automatically disables local Java toolkits to prevent capability conflicts.

      Parameters:
      enabled - true to enable server-side tools.
    • getTokenThreshold

      public int getTokenThreshold()
      Gets the maximum number of tokens allowed in the context window.
      Returns:
      The token threshold.
    • createResourceHandle

      public ResourceHandle createResourceHandle(URI uri)
      Creates a specialized ResourceHandle based on the URI scheme.

      Supports 'file' schemes via PathHandle and fallbacks to UrlHandle for remote resources.

      Parameters:
      uri - The resource URI to wrap.
      Returns:
      A concrete handle implementation for the specified URI.
    • getHostApplicationId

      public String getHostApplicationId()
      Convenience method to get the host application ID from the parent AsiContainer.
      Returns:
      The host application ID.