pub struct AgentLoop { /* private fields */ }Implementations§
Source§impl AgentLoop
impl AgentLoop
pub fn new( agent_id: AgentId, llm_client: Arc<dyn LlmClient>, tools: ToolRegistry, system_prompt: String, max_iterations: usize, ) -> Self
Sourcepub fn with_max_context_tokens(self, tokens: usize) -> Self
pub fn with_max_context_tokens(self, tokens: usize) -> Self
Set the maximum context window size in tokens.
Sourcepub fn with_compaction_strategy(self, strategy: CompactionStrategy) -> Self
pub fn with_compaction_strategy(self, strategy: CompactionStrategy) -> Self
Set the compaction strategy to use.
Sourcepub fn with_agent_name(self, name: impl Into<String>) -> Self
pub fn with_agent_name(self, name: impl Into<String>) -> Self
Set a human-readable name for this agent (used in events).
Sourcepub fn with_messages(
agent_id: AgentId,
llm_client: Arc<dyn LlmClient>,
tools: ToolRegistry,
messages: Vec<ChatMessage>,
max_iterations: usize,
) -> Self
pub fn with_messages( agent_id: AgentId, llm_client: Arc<dyn LlmClient>, tools: ToolRegistry, messages: Vec<ChatMessage>, max_iterations: usize, ) -> Self
Create an AgentLoop with existing conversation history (for multi-turn).
pub fn set_event_sink(&mut self, tx: UnboundedSender<AgentEvent>)
Sourcepub fn set_background_rx(&mut self, rx: UnboundedReceiver<BackgroundResult>)
pub fn set_background_rx(&mut self, rx: UnboundedReceiver<BackgroundResult>)
Set the receiver for background agent results. Results arriving on this channel are injected as user messages before each LLM call, mirroring Claude Code’s background agent notification.
Sourcepub fn messages(&self) -> &[ChatMessage]
pub fn messages(&self) -> &[ChatMessage]
Get a clone of the current conversation messages.
pub async fn run( &mut self, initial_user_message: String, ) -> SdkResult<AgentLoopResult>
Auto Trait Implementations§
impl Freeze for AgentLoop
impl !RefUnwindSafe for AgentLoop
impl Send for AgentLoop
impl Sync for AgentLoop
impl Unpin for AgentLoop
impl UnsafeUnpin for AgentLoop
impl !UnwindSafe for AgentLoop
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
Mutably borrows from an owned value. Read more