pub struct AgentSession {
pub manager: Mutex<SessionManager>,
pub registry: Arc<Registry>,
/* private fields */
}Fields§
§manager: Mutex<SessionManager>§registry: Arc<Registry>Implementations§
Source§impl AgentSession
impl AgentSession
pub fn new( manager: SessionManager, tools: Vec<DynTool>, registry: impl Into<Arc<Registry>>, settings: Settings, system_prompt: String, model: Model, thinking: ThinkingLevel, api_key_override: Option<(String, String)>, sink: SessionEventSink, ) -> Arc<Self> ⓘ
pub fn new_with_subagents_allowed( manager: SessionManager, tools: Vec<DynTool>, registry: impl Into<Arc<Registry>>, settings: Settings, system_prompt: String, model: Model, thinking: ThinkingLevel, api_key_override: Option<(String, String)>, sink: SessionEventSink, subagents_allowed: bool, ) -> Arc<Self> ⓘ
Sourcepub fn set_stream_fn(&self, stream_fn: Option<StreamFn>)
pub fn set_stream_fn(&self, stream_fn: Option<StreamFn>)
Replace the provider streaming function used by every later request.
Pass None to restore the real provider. Child sessions created after
this call inherit the override so a scripted fake model also serves
subagents and compaction.
pub fn model(&self) -> Model
pub fn thinking_level(&self) -> ThinkingLevel
pub fn fast_mode(&self) -> bool
pub fn set_fast_mode(&self, enabled: bool)
pub fn totals(&self) -> Usage
pub fn is_running(&self) -> bool
pub fn settings(&self) -> Settings
pub fn update_settings(&self, settings: Settings)
Sourcepub fn reload_runtime(
&self,
settings: Settings,
system_prompt: String,
tools: Vec<DynTool>,
)
pub fn reload_runtime( &self, settings: Settings, system_prompt: String, tools: Vec<DynTool>, )
Replace resources used by the next model request.
Sourcepub fn install_session_tool(&self, tool: DynTool)
pub fn install_session_tool(&self, tool: DynTool)
Add or replace one tool for this process without changing saved tool configuration.
Sourcepub fn remove_session_tool(&self, name: &str) -> bool
pub fn remove_session_tool(&self, name: &str) -> bool
Remove one process-only tool. Return true when a tool was removed.
Sourcepub fn workflows_enabled(&self) -> bool
pub fn workflows_enabled(&self) -> bool
Dynamic workflows are built on child agents, so they need subagents on as well as their own setting.
Sourcepub fn prompt_mode_for(&self, text: &str) -> PromptMode
pub fn prompt_mode_for(&self, text: &str) -> PromptMode
Select workflow mode from one submitted user prompt.
pub fn workflows(&self) -> Option<Arc<WorkflowRuntime>>
pub fn iterative_jobs(&self) -> Option<Arc<IterativeRuntime>>
Sourcepub fn set_workflow_approver(&self, approver: WorkflowApprover)
pub fn set_workflow_approver(&self, approver: WorkflowApprover)
Install the callback that asks the user to approve a run.
pub fn available_tool_names(&self) -> Vec<String>
Sourcepub fn replace_manager(&self, manager: SessionManager)
pub fn replace_manager(&self, manager: SessionManager)
Switch the active session without appending synthetic history.
pub fn set_model(&self, model: Model)
pub fn set_thinking_level(&self, level: ThinkingLevel)
Move the active leaf in the current session tree, with an optional summary of the branch that is no longer active.
pub fn queue_steering(&self, message: AgentMessage)
pub fn queue_steering_with_mode(&self, message: AgentMessage, mode: PromptMode)
pub fn queue_follow_up(&self, message: AgentMessage)
pub fn queue_follow_up_with_mode(&self, message: AgentMessage, mode: PromptMode)
Sourcepub fn reclaim_queued(&self) -> Vec<AgentMessage>
pub fn reclaim_queued(&self) -> Vec<AgentMessage>
Drain both queues back to the caller (Escape restores to editor).
pub fn abort(&self)
Sourcepub async fn answer_btw(
self: &Arc<Self>,
question: &str,
cancel: CancellationToken,
) -> Result<EphemeralResponse>
pub async fn answer_btw( self: &Arc<Self>, question: &str, cancel: CancellationToken, ) -> Result<EphemeralResponse>
Answer a short side question without changing the active session.
Sourcepub async fn generate_session_title(
self: &Arc<Self>,
prompt: &str,
cancel: CancellationToken,
) -> Result<String>
pub async fn generate_session_title( self: &Arc<Self>, prompt: &str, cancel: CancellationToken, ) -> Result<String>
Generate a short session title without changing conversation history.
Sourcepub async fn generate_recap(
self: &Arc<Self>,
previous_recap: Option<&str>,
cancel: CancellationToken,
) -> Result<EphemeralResponse>
pub async fn generate_recap( self: &Arc<Self>, previous_recap: Option<&str>, cancel: CancellationToken, ) -> Result<EphemeralResponse>
Create a one-line recap without changing the active session.
Sourcepub async fn prompt(self: &Arc<Self>, prompts: Vec<AgentMessage>)
pub async fn prompt(self: &Arc<Self>, prompts: Vec<AgentMessage>)
Run one prompt to completion, including retry and auto-compaction.
Sourcepub async fn prompt_with_mode(
self: &Arc<Self>,
prompts: Vec<AgentMessage>,
prompt_mode: PromptMode,
)
pub async fn prompt_with_mode( self: &Arc<Self>, prompts: Vec<AgentMessage>, prompt_mode: PromptMode, )
Run one prompt with tools and instructions selected for this turn.
Sourcepub async fn compact(
self: &Arc<Self>,
custom_instructions: Option<String>,
auto: bool,
)
pub async fn compact( self: &Arc<Self>, custom_instructions: Option<String>, auto: bool, )
Manual or automatic compaction.
Sourcepub fn context_usage(&self) -> (u64, u64)
pub fn context_usage(&self) -> (u64, u64)
Current estimated context tokens and window fraction.
Auto Trait Implementations§
impl !Freeze for AgentSession
impl !RefUnwindSafe for AgentSession
impl !UnwindSafe for AgentSession
impl Send for AgentSession
impl Sync for AgentSession
impl Unpin for AgentSession
impl UnsafeUnpin for AgentSession
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more