Skip to main content

Session

Struct Session 

Source
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: String

Model 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: bool

Whether the user selected automatic reasoning effort.

§auto_model: bool

Whether the user selected automatic model routing.

§workspace: PathBuf

Workspace 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: SessionUsage

Total tokens used in this session

§allow_shell: bool

Whether shell execution is allowed

§trust_mode: bool

Whether to trust paths outside workspace

§auto_approve: bool

Whether the current session should auto-approve tool safety checks.

§approval_mode: ApprovalMode

Live UI approval policy used to steer the system prompt.

§notes_path: PathBuf

Notes file path

§mcp_config_path: PathBuf

MCP config path

§id: String

Session ID (for tracking)

§project_context: Option<ProjectContext>

Project context loaded from AGENTS.md, etc.

§working_set: WorkingSet

Repo-aware working set for context management.

§cycle_count: u32

Number 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

Source

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

Source

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

Source

pub fn add_message(&mut self, message: Message)

Add a message to the conversation

Source

pub fn rebuild_working_set(&mut self)

Rebuild the working set from current messages (best effort).

Trait Implementations§

Source§

impl Clone for Session

Source§

fn clone(&self) -> Session

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Session

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more