pub struct Task {
pub id: String,
pub context_id: Option<String>,
pub status: TaskStatus,
pub artifacts: Vec<Artifact>,
pub history: Vec<Message>,
pub metadata: Option<HashMap<String, Value>>,
pub kind: String,
}Expand description
Represents a stateful unit of work
Fields§
§id: StringUnique task identifier
context_id: Option<String>Conversational context identifier
status: TaskStatusCurrent status
artifacts: Vec<Artifact>Outputs produced by the agent
history: Vec<Message>Conversation history (if enabled)
metadata: Option<HashMap<String, Value>>Custom metadata
kind: StringType discriminator
Implementations§
Source§impl Task
impl Task
Sourcepub fn with_context_id(self, context_id: impl Into<String>) -> Self
pub fn with_context_id(self, context_id: impl Into<String>) -> Self
Set the context ID
Sourcepub fn is_terminal(&self) -> bool
pub fn is_terminal(&self) -> bool
Check if the task is in a terminal state
Sourcepub fn is_cancelable(&self) -> bool
pub fn is_cancelable(&self) -> bool
Check if the task can be canceled
Sourcepub fn update_status(&mut self, state: TaskState, message: Option<Message>)
pub fn update_status(&mut self, state: TaskState, message: Option<Message>)
Update the task status
Sourcepub fn add_artifact(&mut self, artifact: Artifact)
pub fn add_artifact(&mut self, artifact: Artifact)
Add an artifact to the task
Sourcepub fn add_message(&mut self, message: Message)
pub fn add_message(&mut self, message: Message)
Add a message to the history
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Task
impl<'de> Deserialize<'de> for Task
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Task
impl RefUnwindSafe for Task
impl Send for Task
impl Sync for Task
impl Unpin for Task
impl UnsafeUnpin for Task
impl UnwindSafe for Task
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