Skip to main content

AgentSession

Struct AgentSession 

Source
pub struct AgentSession {
    pub manager: Mutex<SessionManager>,
    pub registry: Arc<Registry>,
    /* private fields */
}

Fields§

§manager: Mutex<SessionManager>§registry: Arc<Registry>

Implementations§

Source§

impl AgentSession

Source

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> ⓘ

Source

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> ⓘ

Source

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.

Source

pub fn model(&self) -> Model

Source

pub fn thinking_level(&self) -> ThinkingLevel

Source

pub fn fast_mode(&self) -> bool

Source

pub fn set_fast_mode(&self, enabled: bool)

Source

pub fn totals(&self) -> Usage

Source

pub fn is_running(&self) -> bool

Source

pub fn settings(&self) -> Settings

Source

pub fn update_settings(&self, settings: Settings)

Source

pub fn reload_runtime( &self, settings: Settings, system_prompt: String, tools: Vec<DynTool>, )

Replace resources used by the next model request.

Source

pub fn install_session_tool(&self, tool: DynTool)

Add or replace one tool for this process without changing saved tool configuration.

Source

pub fn remove_session_tool(&self, name: &str) -> bool

Remove one process-only tool. Return true when a tool was removed.

Source

pub fn workflows_enabled(&self) -> bool

Dynamic workflows are built on child agents, so they need subagents on as well as their own setting.

Source

pub fn prompt_mode_for(&self, text: &str) -> PromptMode

Select workflow mode from one submitted user prompt.

Source

pub fn workflows(&self) -> Option<Arc<WorkflowRuntime>>

Source

pub fn iterative_jobs(&self) -> Option<Arc<IterativeRuntime>>

Source

pub fn set_workflow_approver(&self, approver: WorkflowApprover)

Install the callback that asks the user to approve a run.

Source

pub fn available_tool_names(&self) -> Vec<String>

Source

pub fn replace_manager(&self, manager: SessionManager)

Switch the active session without appending synthetic history.

Source

pub fn set_model(&self, model: Model)

Source

pub fn set_thinking_level(&self, level: ThinkingLevel)

Source

pub async fn navigate_tree( self: &Arc<Self>, target_id: &str, summarize: bool, custom_instructions: Option<String>, cancel: CancellationToken, ) -> Result<TreeNavigationOutcome>

Move the active leaf in the current session tree, with an optional summary of the branch that is no longer active.

Source

pub fn queue_steering(&self, message: AgentMessage)

Source

pub fn queue_steering_with_mode(&self, message: AgentMessage, mode: PromptMode)

Source

pub fn queue_follow_up(&self, message: AgentMessage)

Source

pub fn queue_follow_up_with_mode(&self, message: AgentMessage, mode: PromptMode)

Source

pub fn reclaim_queued(&self) -> Vec<AgentMessage>

Drain both queues back to the caller (Escape restores to editor).

Source

pub fn abort(&self)

Source

pub async fn answer_btw( self: &Arc<Self>, question: &str, cancel: CancellationToken, ) -> Result<EphemeralResponse>

Answer a short side question without changing the active session.

Source

pub async fn generate_session_title( self: &Arc<Self>, prompt: &str, cancel: CancellationToken, ) -> Result<String>

Generate a short session title without changing conversation history.

Source

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.

Source

pub async fn prompt(self: &Arc<Self>, prompts: Vec<AgentMessage>)

Run one prompt to completion, including retry and auto-compaction.

Source

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.

Source

pub async fn compact( self: &Arc<Self>, custom_instructions: Option<String>, auto: bool, )

Manual or automatic compaction.

Source

pub fn context_usage(&self) -> (u64, u64)

Current estimated context tokens and window fraction.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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