Handle keepSession in generate()