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

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

rust
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

rust
fn with_json(mut self, json: serde_json::Value) -> Self

Set JSON output

Parameters:

NameType
jsonserde_json::Value

with_agent

rust
fn with_agent(mut self, name: impl Into<String>) -> Self

Set agent name

Parameters:

NameType
nameimpl Into&lt;String&gt;

with_duration

rust
fn with_duration(mut self, ms: u64) -> Self

Set duration

Parameters:

NameType
msu64

with_tokens

rust
fn with_tokens(mut self, tokens: u32) -> Self

Set token usage

Parameters:

NameType
tokensu32

with_metadata

rust
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

rust
fn as_str(&self) -> &str

Get raw output as string

parse_json

rust
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


Related Documentation