Skip to main content

Agent

Struct Agent 

Source
pub struct Agent {
    pub thinking_budget: u32,
    /* private fields */
}

Fields§

§thinking_budget: u32

Implementations§

Source§

impl Agent

Source

pub fn new( providers: Vec<Box<dyn Provider>>, db: Db, config: &Config, memory: Option<Arc<MemoryStore>>, tools: ToolRegistry, profiles: Vec<AgentProfile>, cwd: String, agents_context: AgentsContext, hooks: HookRegistry, commands: CommandRegistry, ) -> Result<Self>

Source

pub fn aside_provider(&self) -> Arc<dyn Provider>

Source

pub fn set_background_tx(&mut self, tx: UnboundedSender<AgentEvent>)

Source

pub fn background_tx(&self) -> Option<UnboundedSender<AgentEvent>>

Source

pub fn execute_command(&self, name: &str, args: &str) -> Result<String>

Source

pub fn list_commands(&self) -> Vec<(&str, &str)>

Source

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

Source

pub fn hooks(&self) -> &HookRegistry

Source

pub fn conversation_id(&self) -> &str

Source

pub fn messages(&self) -> &[Message]

Source

pub fn set_model(&mut self, model: String)

Source

pub fn set_active_provider(&mut self, provider_name: &str, model: &str)

Source

pub fn set_thinking_budget(&mut self, budget: u32)

Source

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

Source

pub fn cached_all_models(&self) -> Vec<(String, Vec<String>)>

Source

pub async fn fetch_all_models(&mut self) -> Vec<(String, Vec<String>)>

Source

pub fn current_model(&self) -> &str

Source

pub fn current_provider_name(&self) -> &str

Source

pub fn current_agent_name(&self) -> &str

Source

pub fn context_window(&self) -> u32

Source

pub async fn fetch_context_window(&self) -> u32

Source

pub fn agent_profiles(&self) -> &[AgentProfile]

Source

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

Source

pub fn cleanup_if_empty(&mut self)

Source

pub fn new_conversation(&mut self) -> Result<()>

Source

pub fn resume_conversation(&mut self, conversation: &Conversation) -> Result<()>

Source

pub fn add_interrupted_message( &mut self, content: String, tool_calls: Vec<InterruptedToolCall>, thinking: Option<String>, ) -> Result<()>

Add an interrupted (cancelled) assistant message to context and DB so the model sees it on the next send and can continue from where it stopped.

Source

pub fn list_sessions(&self) -> Result<Vec<ConversationSummary>>

Source

pub fn get_session(&self, id: &str) -> Result<Conversation>

Source

pub fn get_tool_calls(&self, message_id: &str) -> Result<Vec<DbToolCall>>

Source

pub fn conversation_title(&self) -> Option<String>

Source

pub fn rename_session(&self, title: &str) -> Result<()>

Source

pub fn cwd(&self) -> &str

Source

pub fn truncate_messages(&mut self, count: usize)

Source

pub fn revert_to_message(&mut self, keep: usize) -> Result<Vec<String>>

Source

pub fn fork_conversation(&mut self, msg_count: usize) -> Result<()>

Source

pub async fn send_message( &mut self, content: &str, event_tx: UnboundedSender<AgentEvent>, ) -> Result<()>

Source

pub async fn send_message_with_images( &mut self, content: &str, images: Vec<(String, String)>, event_tx: UnboundedSender<AgentEvent>, ) -> Result<()>

Auto Trait Implementations§

§

impl !Freeze for Agent

§

impl !RefUnwindSafe for Agent

§

impl Send for Agent

§

impl !Sync for Agent

§

impl Unpin for Agent

§

impl UnsafeUnpin for Agent

§

impl !UnwindSafe for Agent

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> 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<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: 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: 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> 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 = 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<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