Task • Rust AI Agent SDK

Task: A unit of work that can be executed by an Agent

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

rust
fn new(description: impl Into<String>) -> TaskBuilder

Create a new task with description

Parameters:

NameType
descriptionimpl Into&lt;String&gt;

id

rust
fn id(&self) -> &str

Get task ID

display_name

rust
fn display_name(&self) -> &str

Get task name or description

is_completed

rust
fn is_completed(&self) -> bool

Check if task is completed

is_failed

rust
fn is_failed(&self) -> bool

Check if task failed

can_retry

rust
fn can_retry(&self) -> bool

Check if task can be retried

increment_retry

rust
fn increment_retry(&mut self) -> ()

Increment retry count

set_result

rust
fn set_result(&mut self, output: TaskOutput) -> ()

Set task result

Parameters:

NameType
outputTaskOutput

set_failed

rust
fn set_failed(&mut self, error: &str) -> ()

Set task as failed

Parameters:

NameType
error&str

result_str

rust
fn result_str(&self) -> Option<&str>

Get result as string

substitute_variables

rust
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


Related Documentation