> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Task Builder • Rust AI Agent SDK

> TaskBuilder: Builder for Task

# TaskBuilder

> Defined in the [**task**](../modules/task) module.

<Badge color="orange">Rust AI Agent SDK</Badge>

Builder for Task

## Fields

| Name              | Type                   | Description |
| ----------------- | ---------------------- | ----------- |
| `description`     | `String`               | -           |
| `name`            | `Option&lt;String&gt;` | -           |
| `expected_output` | `String`               | -           |
| `depends_on`      | `Vec&lt;String&gt;`    | -           |
| `next_tasks`      | `Vec&lt;String&gt;`    | -           |
| `condition`       | `HashMap&lt;String`    | -           |
| `config`          | `TaskConfig`           | -           |
| `output_file`     | `Option&lt;String&gt;` | -           |
| `output_variable` | `Option&lt;String&gt;` | -           |
| `variables`       | `HashMap&lt;String`    | -           |
| `serde_json`      | `:Value&gt;`           | -           |
| `task_type`       | `TaskType`             | -           |
| `is_start`        | `bool`                 | -           |

## Methods

### `new`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn new(description: impl Into<String>) -> Self
```

Create a new task builder

**Parameters:**

| Name          | Type                      |
| ------------- | ------------------------- |
| `description` | `impl Into&lt;String&gt;` |

### `name`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn name(mut self, name: impl Into<String>) -> Self
```

Set task name

**Parameters:**

| Name   | Type                      |
| ------ | ------------------------- |
| `name` | `impl Into&lt;String&gt;` |

### `expected_output`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn expected_output(mut self, output: impl Into<String>) -> Self
```

Set expected output

**Parameters:**

| Name     | Type                      |
| -------- | ------------------------- |
| `output` | `impl Into&lt;String&gt;` |

### `depends_on`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn depends_on(mut self, task: impl Into<String>) -> Self
```

Add dependency

**Parameters:**

| Name   | Type                      |
| ------ | ------------------------- |
| `task` | `impl Into&lt;String&gt;` |

### `next_task`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn next_task(mut self, task: impl Into<String>) -> Self
```

Add next task

**Parameters:**

| Name   | Type                      |
| ------ | ------------------------- |
| `task` | `impl Into&lt;String&gt;` |

### `task_type`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn task_type(mut self, task_type: TaskType) -> Self
```

Set task type

**Parameters:**

| Name        | Type       |
| ----------- | ---------- |
| `task_type` | `TaskType` |

### `decision`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn decision(mut self) -> Self
```

Set as decision task

### `loop_task`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn loop_task(mut self) -> Self
```

Set as loop task

### `output_file`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn output_file(mut self, path: impl Into<String>) -> Self
```

Set output file

**Parameters:**

| Name   | Type                      |
| ------ | ------------------------- |
| `path` | `impl Into&lt;String&gt;` |

### `output_variable`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn output_variable(mut self, name: impl Into<String>) -> Self
```

Set output variable

**Parameters:**

| Name   | Type                      |
| ------ | ------------------------- |
| `name` | `impl Into&lt;String&gt;` |

### `variable`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn variable(mut self, key: impl Into<String>, value: serde_json::Value) -> Self
```

Add variable

**Parameters:**

| Name    | Type                      |
| ------- | ------------------------- |
| `key`   | `impl Into&lt;String&gt;` |
| `value` | `serde_json::Value`       |

### `max_retries`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn max_retries(mut self, retries: u32) -> Self
```

Set max retries

**Parameters:**

| Name      | Type  |
| --------- | ----- |
| `retries` | `u32` |

### `on_error`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn on_error(mut self, behavior: OnError) -> Self
```

Set error handling

**Parameters:**

| Name       | Type      |
| ---------- | --------- |
| `behavior` | `OnError` |

### `is_start`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn is_start(mut self, is_start: bool) -> Self
```

Set as start task

**Parameters:**

| Name       | Type   |
| ---------- | ------ |
| `is_start` | `bool` |

### `build`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn build(self) -> Task
```

Build the task

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-rust/praisonai/src/task/mod.rs#L319">
  `praisonai/src/task/mod.rs` at line 319
</Card>

***

## Related Documentation

<CardGroup cols={2}>
  <Card title="Rust Tasks" icon="list-check" href="/docs/rust/tasks" />

  <Card title="Rust Execution" icon="play" href="/docs/rust/execution" />

  <Card title="Rust Agent UI" icon="display" href="/docs/rust/agent-ui-agui" />

  <Card title="Rust AGUI" icon="display" href="/docs/rust/agui" />
</CardGroup>
