Skip to main content

TaskOutput

Defined in the task module.
Rust AI Agent SDK Task output containing the result of task execution

Fields

NameTypeDescription
rawStringRaw output string
jsonOption<serde_json::Value>Parsed JSON output (if applicable)
task_idStringTask ID
agent_nameOption<String>Agent name that executed the task
duration_msOption<u64>Execution duration in milliseconds
tokens_usedOption<u32>Token usage
metadataHashMap<StringAdditional metadata
serde_json:Value>Additional metadata

Methods

new

fn new(raw: impl Into<String>, task_id: impl Into<String>) -> Self
Create a new task output Parameters:
NameType
rawimpl Into&lt;String&gt;
task_idimpl Into&lt;String&gt;

with_json

fn with_json(mut self, json: serde_json::Value) -> Self
Set JSON output Parameters:
NameType
jsonserde_json::Value

with_agent

fn with_agent(mut self, name: impl Into<String>) -> Self
Set agent name Parameters:
NameType
nameimpl Into&lt;String&gt;

with_duration

fn with_duration(mut self, ms: u64) -> Self
Set duration Parameters:
NameType
msu64

with_tokens

fn with_tokens(mut self, tokens: u32) -> Self
Set token usage Parameters:
NameType
tokensu32

with_metadata

fn with_metadata(mut self, key: impl Into<String>, value: serde_json::Value) -> Self
Add metadata Parameters:
NameType
keyimpl Into&lt;String&gt;
valueserde_json::Value

as_str

fn as_str(&self) -> &str
Get raw output as string

parse_json

fn parse_json(&self) -> Result<serde_json::Value>
Try to parse raw output as JSON

Source

View on GitHub

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