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