public ChatSession withToolConfig(ToolConfig toolConfig) {
    return new ChatSession(
        model.withToolConfig(toolConfig),
        history,
        previousHistorySize,
        Optional.of(rootChatSession.orElse(this)),
        automaticFunctionCallingResponder);
  }
Creates a copy of the current ChatSession with updated ToolConfig.

@param toolConfig a {@link com.google.cloud.vertexai.api.ToolConfig} that will be used in the
    new ChatSession.
@return a new {@link ChatSession} instance with the specified ToolConfigs.
java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/generativeai/ChatSession.java