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
| Name | Type | Description |
|---|---|---|
id | String | Unique task ID |
name | Option<String> | Task name (optional) |
description | String | Task description (what to do) |
expected_output | String | Expected output description |
status | TaskStatus | Task status |
task_type | TaskType | Task type |
result | Option<TaskOutput> | Task result |
depends_on | Vec<String> | Dependencies (task IDs or names) |
next_tasks | Vec<String> | Next tasks to execute |
condition | HashMap<String | Condition for routing (decision tasks) |
config | TaskConfig | Task configuration |
output_file | Option<String> | Output file path |
output_variable | Option<String> | Output variable name |
variables | HashMap<String | Variables for substitution |
serde_json | :Value> | Variables for substitution |
retry_count | u32 | Retry count |
is_start | bool | Is this the start task? |
Methods
new
fn new(description: impl Into<String>) -> TaskBuilderCreate a new task with description
Parameters:
| Name | Type |
|---|---|
description | impl Into<String> |
id
fn id(&self) -> &strGet task ID
display_name
fn display_name(&self) -> &strGet task name or description
is_completed
fn is_completed(&self) -> boolCheck if task is completed
is_failed
fn is_failed(&self) -> boolCheck if task failed
can_retry
fn can_retry(&self) -> boolCheck 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:
| Name | Type |
|---|---|
output | TaskOutput |
set_failed
fn set_failed(&mut self, error: &str) -> ()Set task as failed
Parameters:
| Name | Type |
|---|---|
error | &str |
result_str
fn result_str(&self) -> Option<&str>Get result as string
substitute_variables
fn substitute_variables(&self, context: &HashMap<String, String>) -> StringSubstitute variables in description
Parameters:
| Name | Type |
|---|---|
context | &HashMap<String |
Source
View on GitHubpraisonai/src/task/mod.rs at line 186