pub struct Agent { /* private fields */ }Expand description
A stateful agent. Clone shares the same inner state + event channel (like
holding a second reference to the TS Agent instance).
Implementations§
Source§impl Agent
impl Agent
Sourcepub fn subscribe(&self) -> Receiver<AgentEvent>
pub fn subscribe(&self) -> Receiver<AgentEvent>
Subscribe to agent lifecycle events. Returns a broadcast::Receiver.
Mirrors TS subscribe.
Sourcepub fn state(&self) -> AgentState
pub fn state(&self) -> AgentState
Current agent state snapshot. Clones tools/messages so callers can’t
mutate internal state. Mirrors TS get state().
Sourcepub fn steer(&self, message: AgentMessage)
pub fn steer(&self, message: AgentMessage)
Queue a steering message (injected after the current turn’s tool batch).
Sourcepub fn follow_up(&self, message: AgentMessage)
pub fn follow_up(&self, message: AgentMessage)
Queue a follow-up message (injected when the agent would otherwise stop).
Sourcepub fn has_queued_messages(&self) -> bool
pub fn has_queued_messages(&self) -> bool
True when either queue has pending messages.
Sourcepub async fn wait_for_idle(&self)
pub async fn wait_for_idle(&self)
Resolve when the current run finishes (or immediately if idle).
Sourcepub async fn prompt(&self, text: impl Into<String>) -> Result<(), AgentError>
pub async fn prompt(&self, text: impl Into<String>) -> Result<(), AgentError>
Start a new prompt from text. Convenience for prompt_message.
Sourcepub async fn prompt_message(
&self,
message: AgentMessage,
) -> Result<(), AgentError>
pub async fn prompt_message( &self, message: AgentMessage, ) -> Result<(), AgentError>
Start a new prompt from a single AgentMessage.
Sourcepub async fn prompt_messages(
&self,
messages: Vec<AgentMessage>,
) -> Result<(), AgentError>
pub async fn prompt_messages( &self, messages: Vec<AgentMessage>, ) -> Result<(), AgentError>
Start a new prompt from a batch of AgentMessages.
Sourcepub async fn continue_run(&self) -> Result<(), AgentError>
pub async fn continue_run(&self) -> Result<(), AgentError>
Continue from the current transcript. Errors if the agent is busy or the last message is an assistant message with no queued steering/follow-up.
Sourcepub fn reset(&self) -> Result<(), AgentError>
pub fn reset(&self) -> Result<(), AgentError>
Clear transcript + runtime state + queues. Errors if a run is active.