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
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    /// Whether to persist per-session provider override parameters across restarts (#4654).
28    ///
29    /// Currently persists `reasoning_effort` only (Phase 1). Only takes effect when
30    /// `provider_persistence` is also `true` — overrides are meaningless without a persisted
31    /// provider to apply them to. Default: `true`.
32    pub persist_provider_overrides: bool,
33}
34
35impl Default for SessionConfig {
36    fn default() -> Self {
37        Self {
38            recap: RecapConfig::default(),
39            provider_persistence: true,
40            persist_provider_overrides: true,
41        }
42    }
43}
44
45/// `[session.recap]` — controls the session recap feature (#3064).
46///
47/// A recap summarises the previous conversation in a few sentences and is
48/// shown to the user when they resume a session that has a persisted digest.
49///
50/// # Example
51///
52/// ```toml
53/// [session.recap]
54/// on_resume = true
55/// max_tokens = 200
56/// provider = ""
57/// max_input_messages = 20
58/// ```
59#[derive(Debug, Clone, Deserialize, Serialize)]
60#[serde(default)]
61pub struct RecapConfig {
62    /// Show a recap of the previous session when resuming a conversation.
63    ///
64    /// When `true` and a persisted digest exists for the conversation, the
65    /// agent emits a brief recap before accepting the first user message.
66    /// Default: `true`.
67    pub on_resume: bool,
68
69    /// Maximum tokens for the recap text.
70    ///
71    /// Limits the length of the generated or cached recap. Default: `200`.
72    pub max_tokens: usize,
73
74    /// Provider name from `[[llm.providers]]` for recap LLM calls.
75    ///
76    /// An empty [`ProviderName`] falls back to the primary provider. Default: `""`.
77    pub provider: ProviderName,
78
79    /// Maximum recent messages included when generating a fresh recap.
80    ///
81    /// Used only when no cached digest is available (fresh-generation path).
82    /// Default: `20`.
83    pub max_input_messages: usize,
84}
85
86impl Default for RecapConfig {
87    fn default() -> Self {
88        Self {
89            on_resume: true,
90            max_tokens: 200,
91            provider: ProviderName::default(),
92            max_input_messages: 20,
93        }
94    }
95}