Skip to main content

zeph_config/
session.rs

1// SPDX-FileCopyrightText: 2026 Andrei G <bug-ops>
2// SPDX-License-Identifier: MIT OR Apache-2.0
3
4//! Session-scoped user experience settings (#3064).
5//!
6//! Configures behaviours that shape the user's experience per session, such as
7//! showing a recap of the previous conversation on resume.
8
9use serde::{Deserialize, Serialize};
10
11/// Top-level `[session]` config block.
12#[derive(Debug, Clone, Deserialize, Serialize)]
13#[serde(default)]
14pub struct SessionConfig {
15    /// Recap-on-resume settings.
16    pub recap: RecapConfig,
17    /// Whether to persist the last-used provider per channel across restarts.
18    ///
19    /// When `true` (the default), the agent stores the active provider name in `SQLite`
20    /// after each `/provider` switch and restores it on the next startup for the same
21    /// `(channel_type, channel_id)` pair.
22    ///
23    /// Set to `false` to always start with the configured primary provider.
24    pub provider_persistence: bool,
25}
26
27impl Default for SessionConfig {
28    fn default() -> Self {
29        Self {
30            recap: RecapConfig::default(),
31            provider_persistence: true,
32        }
33    }
34}
35
36/// `[session.recap]` — controls the session recap feature (#3064).
37///
38/// A recap summarises the previous conversation in a few sentences and is
39/// shown to the user when they resume a session that has a persisted digest.
40///
41/// # Example
42///
43/// ```toml
44/// [session.recap]
45/// on_resume = true
46/// max_tokens = 200
47/// provider = ""
48/// max_input_messages = 20
49/// ```
50#[derive(Debug, Clone, Deserialize, Serialize)]
51#[serde(default)]
52pub struct RecapConfig {
53    /// Show a recap of the previous session when resuming a conversation.
54    ///
55    /// When `true` and a persisted digest exists for the conversation, the
56    /// agent emits a brief recap before accepting the first user message.
57    /// Default: `true`.
58    pub on_resume: bool,
59
60    /// Maximum tokens for the recap text.
61    ///
62    /// Limits the length of the generated or cached recap. Default: `200`.
63    pub max_tokens: usize,
64
65    /// Provider name from `[[llm.providers]]` for recap LLM calls.
66    ///
67    /// An empty string falls back to the primary provider. Default: `""`.
68    pub provider: String,
69
70    /// Maximum recent messages included when generating a fresh recap.
71    ///
72    /// Used only when no cached digest is available (fresh-generation path).
73    /// Default: `20`.
74    pub max_input_messages: usize,
75}
76
77impl Default for RecapConfig {
78    fn default() -> Self {
79        Self {
80            on_resume: true,
81            max_tokens: 200,
82            provider: String::new(),
83            max_input_messages: 20,
84        }
85    }
86}