Class SessionConfig
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();
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the list of allowed tool names.Gets the custom agent configurations.Gets the list of excluded tool names.Gets the infinite sessions configuration.Gets the MCP server configurations.getModel()Gets the AI model to use.Gets the permission request handler.Gets the custom API provider configuration.Gets the custom session ID.Gets the system message configuration.getTools()Gets the custom tools for this session.booleanReturns whether streaming is enabled.setAvailableTools(List<String> availableTools) Sets the list of tool names that are allowed in this session.setCustomAgents(List<CustomAgentConfig> customAgents) Sets custom agent configurations.setExcludedTools(List<String> excludedTools) Sets the list of tool names to exclude from this session.setInfiniteSessions(InfiniteSessionConfig infiniteSessions) Sets the infinite session configuration for persistent workspaces and automatic compaction.setMcpServers(Map<String, Object> mcpServers) Sets MCP (Model Context Protocol) server configurations.Sets the AI model to use for this session.setOnPermissionRequest(PermissionHandler onPermissionRequest) Sets a handler for permission requests from the assistant.setProvider(ProviderConfig provider) Sets a custom API provider for BYOK (Bring Your Own Key) scenarios.setSessionId(String sessionId) Sets a custom session ID.setStreaming(boolean streaming) Sets whether to enable streaming of response chunks.setSystemMessage(SystemMessageConfig systemMessage) Sets the system message configuration.setTools(List<ToolDefinition> tools) Sets custom tools that the assistant can invoke during the session.
-
Constructor Details
-
SessionConfig
public SessionConfig()
-
-
Method Details
-
getSessionId
Gets the custom session ID.- Returns:
- the session ID, or
nullto generate automatically
-
setSessionId
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
Gets the AI model to use.- Returns:
- the model name
-
setModel
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
Gets the custom tools for this session.- Returns:
- the list of tool definitions
-
setTools
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
Gets the system message configuration.- Returns:
- the system message config
-
setSystemMessage
Sets the system message configuration.The system message controls the behavior and personality of the assistant. Use
SystemMessageMode.APPENDto add instructions while preserving default behavior, orSystemMessageMode.REPLACEto fully customize.- Parameters:
systemMessage- the system message configuration- Returns:
- this config instance for method chaining
- See Also:
-
getAvailableTools
Gets the list of allowed tool names.- Returns:
- the list of available tool names
-
setAvailableTools
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
Gets the list of excluded tool names.- Returns:
- the list of excluded tool names
-
setExcludedTools
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
Gets the custom API provider configuration.- Returns:
- the provider configuration
-
setProvider
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
Gets the permission request handler.- Returns:
- the permission handler
-
setOnPermissionRequest
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:
trueif streaming is enabled
-
setStreaming
Sets whether to enable streaming of response chunks.When enabled, the session will emit
AssistantMessageDeltaEventevents as the response is generated, allowing for real-time display of partial responses.- Parameters:
streaming-trueto enable streaming- Returns:
- this config instance for method chaining
-
getMcpServers
Gets the MCP server configurations.- Returns:
- the MCP servers map
-
setMcpServers
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
Gets the custom agent configurations.- Returns:
- the list of custom agent configurations
-
setCustomAgents
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
Gets the infinite sessions configuration.- Returns:
- the infinite sessions config
-
setInfiniteSessions
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:
-