Skip to content

Python: Kernel instance lifetime in a web api #10490

Answered by moonbox3
vslepakov asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @vslepakov,

Generally, it's best to create and configure the Kernel as a singleton, reusing it across requests, to avoid the overhead of reinitializing plugins and services, provided everything is thread-safe. For per-session data like chat history, it's best to manage that state separately (for example, storing it per session) to keep user conversations isolated and maintain clean separation between global kernel state and session-specific context.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@vslepakov
Comment options

Answer selected by vslepakov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
python Pull requests for the Python Semantic Kernel
2 participants