Class SessionConfig

java.lang.Object
com.github.copilot.sdk.json.SessionConfig

public class SessionConfig extends Object
Configuration for creating a new Copilot session.

This class provides options for customizing session behavior, including model selection, tool registration, system message customization, and more. All setter methods return this for method chaining.

Example Usage


 var config = new SessionConfig().setModel("gpt-5").setStreaming(true).setSystemMessage(
 		new SystemMessageConfig().setMode(SystemMessageMode.APPEND).setContent("Be concise in your responses."));

 var session = client.createSession(config).get();
 
See Also:
  • Constructor Details

    • SessionConfig

      public SessionConfig()
  • Method Details

    • getSessionId

      public String getSessionId()
      Gets the custom session ID.
      Returns:
      the session ID, or null to generate automatically
    • setSessionId

      public SessionConfig setSessionId(String sessionId)
      Sets a custom session ID.

      If not provided, a unique session ID will be generated automatically.

      Parameters:
      sessionId - the custom session ID
      Returns:
      this config instance for method chaining
    • getModel

      public String getModel()
      Gets the AI model to use.
      Returns:
      the model name
    • setModel

      public SessionConfig setModel(String model)
      Sets the AI model to use for this session.

      Examples: "gpt-5", "claude-sonnet-4.5", "o3-mini".

      Parameters:
      model - the model name
      Returns:
      this config instance for method chaining
    • getTools

      public List<ToolDefinition> getTools()
      Gets the custom tools for this session.
      Returns:
      the list of tool definitions
    • setTools

      public SessionConfig setTools(List<ToolDefinition> tools)
      Sets custom tools that the assistant can invoke during the session.

      Tools allow the assistant to call back into your application to perform actions or retrieve information.

      Parameters:
      tools - the list of tool definitions
      Returns:
      this config instance for method chaining
      See Also:
    • getSystemMessage

      public SystemMessageConfig getSystemMessage()
      Gets the system message configuration.
      Returns:
      the system message config
    • setSystemMessage

      public SessionConfig setSystemMessage(SystemMessageConfig systemMessage)
      Sets the system message configuration.

      The system message controls the behavior and personality of the assistant. Use SystemMessageMode.APPEND to add instructions while preserving default behavior, or SystemMessageMode.REPLACE to fully customize.

      Parameters:
      systemMessage - the system message configuration
      Returns:
      this config instance for method chaining
      See Also:
    • getAvailableTools

      public List<String> getAvailableTools()
      Gets the list of allowed tool names.
      Returns:
      the list of available tool names
    • setAvailableTools

      public SessionConfig setAvailableTools(List<String> availableTools)
      Sets the list of tool names that are allowed in this session.

      When specified, only tools in this list will be available to the assistant.

      Parameters:
      availableTools - the list of allowed tool names
      Returns:
      this config instance for method chaining
    • getExcludedTools

      public List<String> getExcludedTools()
      Gets the list of excluded tool names.
      Returns:
      the list of excluded tool names
    • setExcludedTools

      public SessionConfig setExcludedTools(List<String> excludedTools)
      Sets the list of tool names to exclude from this session.

      Tools in this list will not be available to the assistant.

      Parameters:
      excludedTools - the list of tool names to exclude
      Returns:
      this config instance for method chaining
    • getProvider

      public ProviderConfig getProvider()
      Gets the custom API provider configuration.
      Returns:
      the provider configuration
    • setProvider

      public SessionConfig setProvider(ProviderConfig provider)
      Sets a custom API provider for BYOK (Bring Your Own Key) scenarios.

      This allows using your own OpenAI, Azure OpenAI, or other compatible API endpoints instead of the default Copilot backend.

      Parameters:
      provider - the provider configuration
      Returns:
      this config instance for method chaining
      See Also:
    • getOnPermissionRequest

      public PermissionHandler getOnPermissionRequest()
      Gets the permission request handler.
      Returns:
      the permission handler
    • setOnPermissionRequest

      public SessionConfig setOnPermissionRequest(PermissionHandler onPermissionRequest)
      Sets a handler for permission requests from the assistant.

      When the assistant needs permission to perform certain actions, this handler will be invoked to approve or deny the request.

      Parameters:
      onPermissionRequest - the permission handler
      Returns:
      this config instance for method chaining
      See Also:
    • isStreaming

      public boolean isStreaming()
      Returns whether streaming is enabled.
      Returns:
      true if streaming is enabled
    • setStreaming

      public SessionConfig setStreaming(boolean streaming)
      Sets whether to enable streaming of response chunks.

      When enabled, the session will emit AssistantMessageDeltaEvent events as the response is generated, allowing for real-time display of partial responses.

      Parameters:
      streaming - true to enable streaming
      Returns:
      this config instance for method chaining
    • getMcpServers

      public Map<String,Object> getMcpServers()
      Gets the MCP server configurations.
      Returns:
      the MCP servers map
    • setMcpServers

      public SessionConfig setMcpServers(Map<String,Object> mcpServers)
      Sets MCP (Model Context Protocol) server configurations.

      MCP servers extend the assistant's capabilities by providing additional context sources and tools.

      Parameters:
      mcpServers - the MCP servers configuration map
      Returns:
      this config instance for method chaining
    • getCustomAgents

      public List<CustomAgentConfig> getCustomAgents()
      Gets the custom agent configurations.
      Returns:
      the list of custom agent configurations
    • setCustomAgents

      public SessionConfig setCustomAgents(List<CustomAgentConfig> customAgents)
      Sets custom agent configurations.

      Custom agents allow extending the assistant with specialized behaviors and capabilities.

      Parameters:
      customAgents - the list of custom agent configurations
      Returns:
      this config instance for method chaining
      See Also:
    • getInfiniteSessions

      public InfiniteSessionConfig getInfiniteSessions()
      Gets the infinite sessions configuration.
      Returns:
      the infinite sessions config
    • setInfiniteSessions

      public SessionConfig setInfiniteSessions(InfiniteSessionConfig infiniteSessions)
      Sets the infinite session configuration for persistent workspaces and automatic compaction.

      When enabled (default), sessions automatically manage context limits and persist state to a workspace directory. The workspace contains checkpoints/, plan.md, and files/ subdirectories.

      Parameters:
      infiniteSessions - the infinite sessions configuration
      Returns:
      this config instance for method chaining
      See Also: