Skip to main content

Task

Defined in the task module.
Rust AI Agent SDK A unit of work that can be executed by an Agent

Fields

NameTypeDescription
idStringUnique task ID
nameOption<String>Task name (optional)
descriptionStringTask description (what to do)
expected_outputStringExpected output description
statusTaskStatusTask status
task_typeTaskTypeTask type
resultOption<TaskOutput>Task result
depends_onVec<String>Dependencies (task IDs or names)
next_tasksVec<String>Next tasks to execute
conditionHashMap<StringCondition for routing (decision tasks)
configTaskConfigTask configuration
output_fileOption<String>Output file path
output_variableOption<String>Output variable name
variablesHashMap<StringVariables for substitution
serde_json:Value>Variables for substitution
retry_countu32Retry count
is_startboolIs this the start task?

Methods

new

fn new(description: impl Into<String>) -> TaskBuilder
Create a new task with description Parameters:
NameType
descriptionimpl Into&lt;String&gt;

id

fn id(&self) -> &str
Get task ID

display_name

fn display_name(&self) -> &str
Get task name or description

is_completed

fn is_completed(&self) -> bool
Check if task is completed

is_failed

fn is_failed(&self) -> bool
Check if task failed

can_retry

fn can_retry(&self) -> bool
Check if task can be retried

increment_retry

fn increment_retry(&mut self) -> ()
Increment retry count

set_result

fn set_result(&mut self, output: TaskOutput) -> ()
Set task result Parameters:
NameType
outputTaskOutput

set_failed

fn set_failed(&mut self, error: &str) -> ()
Set task as failed Parameters:
NameType
error&str

result_str

fn result_str(&self) -> Option<&str>
Get result as string

substitute_variables

fn substitute_variables(&self, context: &HashMap<String, String>) -> String
Substitute variables in description Parameters:
NameType
context&HashMap&lt;String

Source

View on GitHub

praisonai/src/task/mod.rs at line 186