4.0 KiB
Sessions
By default, Loki does not send back all previous messages in a conversation to the model. This means that each time you
query a model, it's essentially a one-off. However, Loki does support chat-like conversations with LLMs via its
sessions mechanism.
Sessions in Loki enable the familiar conversational interactions with LLMs. This means you can reference previous answers and ask follow-up questions and the model will know what you're referring to.
Sessions can be temporary, or can be saved so you can continue conversations at a later time.
Saved sessions are stored in the sessions subdirectory of the Loki configuration directory. The location of the
sessions directory varies by system, so you can use the following command to find the sessions directory if you need
it:
loki --info | grep 'sessions_dir' | awk '{print $2}'
Usage
When you use a session in Loki, you can either persist it or discard it once you're done. Sessions you discard are then just considered 'temporary' sessions.
Sessions you persist and then load again later will inherit the same configuration as was used during the last usage of that session. That is to say, if you had certain tools or MCP servers enabled when you were last in that session, they will be available again when you continue that session.
Configuration
Session behavior can be configured from the global Loki configuration file. The location of this file varies between systems so you can use the following command to locate it on your system:
loki --info | grep 'config_file' | awk '{print $2}'
The following settings are available to customize the default behavior of sessions globally:
| Setting | Description |
|---|---|
save_session |
Controls the persistence of the session.
|
compression_threshold |
Defines the token count threshold at which Loki will compress the session to save on the context length |
summarization_prompt |
This is the prompt that is used to compress the session up to a given point when compression is triggered |
summary_context_prompt |
This is the prompt that's used to add the summarized conversation generated by the summarization_prompt as context to the model |
