Task Output • Rust AI Agent SDK
TaskOutput: Task output containing the result of task execution
TaskOutput
Defined in the task module.
Rust AI Agent SDK
Task output containing the result of task execution
Fields
| Name | Type | Description |
|---|---|---|
raw | String | Raw output string |
json | Option<serde_json::Value> | Parsed JSON output (if applicable) |
task_id | String | Task ID |
agent_name | Option<String> | Agent name that executed the task |
duration_ms | Option<u64> | Execution duration in milliseconds |
tokens_used | Option<u32> | Token usage |
metadata | HashMap<String | Additional metadata |
serde_json | :Value> | Additional metadata |
Methods
new
fn new(raw: impl Into<String>, task_id: impl Into<String>) -> SelfCreate a new task output
Parameters:
| Name | Type |
|---|---|
raw | impl Into<String> |
task_id | impl Into<String> |
with_json
fn with_json(mut self, json: serde_json::Value) -> SelfSet JSON output
Parameters:
| Name | Type |
|---|---|
json | serde_json::Value |
with_agent
fn with_agent(mut self, name: impl Into<String>) -> SelfSet agent name
Parameters:
| Name | Type |
|---|---|
name | impl Into<String> |
with_duration
fn with_duration(mut self, ms: u64) -> SelfSet duration
Parameters:
| Name | Type |
|---|---|
ms | u64 |
with_tokens
fn with_tokens(mut self, tokens: u32) -> SelfSet token usage
Parameters:
| Name | Type |
|---|---|
tokens | u32 |
with_metadata
fn with_metadata(mut self, key: impl Into<String>, value: serde_json::Value) -> SelfAdd metadata
Parameters:
| Name | Type |
|---|---|
key | impl Into<String> |
value | serde_json::Value |
as_str
fn as_str(&self) -> &strGet raw output as string
parse_json
fn parse_json(&self) -> Result<serde_json::Value>Try to parse raw output as JSON
Source
View on GitHubpraisonai/src/task/mod.rs at line 28