pub struct Session {Show 26 fields
pub model: String,
pub reasoning_effort: Option<String>,
pub reasoning_effort_auto: bool,
pub auto_model: bool,
pub workspace: PathBuf,
pub system_prompt: Option<SystemPrompt>,
pub last_system_prompt_hash: Option<u64>,
pub compaction_summary_prompt: Option<SystemPrompt>,
pub messages: Vec<Message>,
pub total_usage: SessionUsage,
pub allow_shell: bool,
pub trust_mode: bool,
pub auto_approve: bool,
pub approval_mode: ApprovalMode,
pub notes_path: PathBuf,
pub mcp_config_path: PathBuf,
pub id: String,
pub project_context: Option<ProjectContext>,
pub working_set: WorkingSet,
pub cycle_count: u32,
pub current_cycle_started: DateTime<Utc>,
pub cycle_briefings: Vec<CycleBriefing>,
pub last_api_input_tokens: Option<u32>,
pub temperature: Option<f32>,
pub top_p: Option<f32>,
pub max_output_tokens: Option<u32>,
}Expand description
Session state for the engine.
Fields§
§model: StringModel being used
reasoning_effort: Option<String>Reasoning-effort tier for DeepSeek thinking mode:
"off" | "low" | "medium" | "high" | "max". None lets the provider
apply its own defaults.
reasoning_effort_auto: boolWhether the user selected automatic reasoning effort.
auto_model: boolWhether the user selected automatic model routing.
workspace: PathBufWorkspace directory
system_prompt: Option<SystemPrompt>System prompt (optional)
last_system_prompt_hash: Option<u64>Hash of the last assembled stable system prompt. Used to avoid
replacing system_prompt when unchanged.
compaction_summary_prompt: Option<SystemPrompt>Persisted summary blocks generated by context compaction.
messages: Vec<Message>Conversation history (API format)
total_usage: SessionUsageTotal tokens used in this session
allow_shell: boolWhether shell execution is allowed
trust_mode: boolWhether to trust paths outside workspace
auto_approve: boolWhether the current session should auto-approve tool safety checks.
approval_mode: ApprovalModeLive UI approval policy used to steer the system prompt.
notes_path: PathBufNotes file path
mcp_config_path: PathBufMCP config path
id: StringSession ID (for tracking)
project_context: Option<ProjectContext>Project context loaded from AGENTS.md, etc.
working_set: WorkingSetRepo-aware working set for context management.
cycle_count: u32Number of cycle boundaries crossed in this session (issue #124). The
active cycle index is cycle_count + 1 (cycles are 1-based for users).
current_cycle_started: DateTime<Utc>UTC start time of the current cycle. Updated when the engine resets
the conversation buffer. Used by archive headers and the /cycles
command’s display.
cycle_briefings: Vec<CycleBriefing>Briefings produced at past cycle boundaries, in chronological order. Bounded growth: one entry per cycle, briefing capped at ~3,000 tokens.
last_api_input_tokens: Option<u32>Provider-reported usage.input_tokens from the most recent API round
(overwrite per round — not summed across tool-call rounds). Authoritative
for “context size at last inference” per DeepSeek API docs.
temperature: Option<f32>Per-session sampling overrides (optional). None → provider / model defaults.
top_p: Option<f32>§max_output_tokens: Option<u32>Max output tokens for API requests; when unset, model-specific default applies.
Implementations§
Source§impl Session
impl Session
Sourcepub fn record_api_round_usage(&mut self, usage: &Usage)
pub fn record_api_round_usage(&mut self, usage: &Usage)
Record per-round API usage. Turn totals still sum via Turn::add_usage.
Source§impl Session
impl Session
Sourcepub fn new(
model: String,
workspace: PathBuf,
allow_shell: bool,
trust_mode: bool,
notes_path: PathBuf,
mcp_config_path: PathBuf,
) -> Self
pub fn new( model: String, workspace: PathBuf, allow_shell: bool, trust_mode: bool, notes_path: PathBuf, mcp_config_path: PathBuf, ) -> Self
Create a new session
Sourcepub fn add_message(&mut self, message: Message)
pub fn add_message(&mut self, message: Message)
Add a message to the conversation
Sourcepub fn rebuild_working_set(&mut self)
pub fn rebuild_working_set(&mut self)
Rebuild the working set from current messages (best effort).