pub struct TaskAgent {
pub id: String,
/* private fields */
}Expand description
Autonomous task agent that runs a provider + tool loop until completion.
Create with TaskAgent::new, then call TaskAgent::execute (or spawn
it on a background task with spawn_task_agent).
Fields§
§id: StringUnique agent ID.
Implementations§
Source§impl TaskAgent
impl TaskAgent
Sourcepub fn new(
id: String,
task: Task,
provider: Arc<dyn Provider>,
context: Arc<AgentContext>,
config: TaskAgentConfig,
) -> Self
pub fn new( id: String, task: Task, provider: Arc<dyn Provider>, context: Arc<AgentContext>, config: TaskAgentConfig, ) -> Self
Create a new task agent.
The agent starts in TaskAgentStatus::Idle and does not begin
execution until execute is called.
Sourcepub async fn status(&self) -> TaskAgentStatus
pub async fn status(&self) -> TaskAgentStatus
Get the current status.
Sourcepub async fn conversation_snapshot(&self) -> Vec<Message>
pub async fn conversation_snapshot(&self) -> Vec<Message>
Get a read-only snapshot of the conversation history.
Sourcepub async fn conversation_len(&self) -> usize
pub async fn conversation_len(&self) -> usize
Get the current message count.
Sourcepub async fn inject_message(&self, msg: Message)
pub async fn inject_message(&self, msg: Message)
Inject a message into the conversation (e.g., from a parent agent).
Sourcepub async fn execute(&self) -> Result<TaskAgentResult>
pub async fn execute(&self) -> Result<TaskAgentResult>
Execute the task to completion, returning the result.
Blocks the calling async task until the agent finishes. Use
spawn_task_agent to run the agent on a Tokio background task.
Auto Trait Implementations§
impl Freeze for TaskAgent
impl !RefUnwindSafe for TaskAgent
impl Send for TaskAgent
impl Sync for TaskAgent
impl Unpin for TaskAgent
impl UnsafeUnpin for TaskAgent
impl !UnwindSafe for TaskAgent
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