pub struct Agent { /* private fields */ }Expand description
Full Agent with event output
Implementations§
Source§impl Agent
impl Agent
Sourcepub fn event_sender(&self) -> Sender<AgentEvent>
pub fn event_sender(&self) -> Sender<AgentEvent>
Get event sender for streaming
Sourcepub fn set_ask_channel(&mut self, rx: Receiver<String>)
pub fn set_ask_channel(&mut self, rx: Receiver<String>)
Set ask response channel (for TUI mode)
Sourcepub fn set_cancel_token(&mut self, token: CancellationToken)
pub fn set_cancel_token(&mut self, token: CancellationToken)
Set cancellation token
Sourcepub fn set_approve_mode(&mut self, mode: ApproveMode)
pub fn set_approve_mode(&mut self, mode: ApproveMode)
Set approve mode at runtime
Get a shared reference to the approve mode atomic. TUI can hold this and update it directly, even while agent is running.
Replace the internal approve mode with an externally-created shared atomic. Replace the internal approve mode with an externally-created shared atomic. This allows the TUI to update the mode while the agent is running.
Sourcepub fn update_memory_summary(&mut self, summary: Option<String>)
pub fn update_memory_summary(&mut self, summary: Option<String>)
Update memory summary and rebuild system prompt. This is called before each turn to use context-aware memory retrieval.
Sourcepub async fn run(&mut self, user_input: String) -> Result<Vec<AgentEvent>>
pub async fn run(&mut self, user_input: String) -> Result<Vec<AgentEvent>>
Run chat loop with tool execution (streaming version).
Events are emitted via the event_tx channel in real-time.
The returned Vec is intentionally empty — callers should consume
events from the channel instead.
Sourcepub fn set_messages(&mut self, messages: Vec<Message>)
pub fn set_messages(&mut self, messages: Vec<Message>)
Restore message history (for session continue/resume)
Sourcepub fn get_messages(&self) -> &[Message]
pub fn get_messages(&self) -> &[Message]
Get current messages (for session saving)
Sourcepub fn get_token_counts(&self) -> (u64, u64)
pub fn get_token_counts(&self) -> (u64, u64)
Get current token counts
Sourcepub fn clear_history(&mut self)
pub fn clear_history(&mut self)
Clear message history
Sourcepub fn message_count(&self) -> usize
pub fn message_count(&self) -> usize
Get message count