pub struct WorkflowTotals {
pub total_input_tokens: u64,
pub total_output_tokens: u64,
pub total_cached_input_tokens: u64,
pub total_thinking_tokens: u64,
pub total_tool_tokens: u64,
pub total_cost_usd: f64,
pub task_count: u32,
}Expand description
Aggregate token + cost rollup emitted on EngineEvent::WorkflowEnd.
Issue #1173: today’s WorkflowEnd carries just the workflow’s return
value, so dashboards and the CLI re-walk every TaskEnd to compute
per-execution totals. This struct surfaces the same numbers once on
the terminating event so consumers can size the run without parsing
the full event log.
The engine populates this by summing TokenUsage fields across
every TaskEnd emitted in the workflow scope. Sub-script TaskEnds
(events wrapped inside EngineEvent::SubScript) DO contribute —
the engine relay forwards them to the parent counter so a chain’s
outer WorkflowEnd reflects the entire chain’s spend.
total_cost_usd is the only field the engine can’t always populate
on its own — pricing tables live in akribes-server to keep
akribes-core free of provider rate metadata. The field defaults to
0.0 and stays 0.0 when the engine has no cost data; downstream
enrichers may overwrite it on the server side before persistence.
Fields§
§total_input_tokens: u64Sum of TokenUsage::input_tokens across every TaskEnd in the
workflow scope (including sub-script TaskEnds). Superset of
cached + cache-write — see TokenUsage for the convention.
total_output_tokens: u64Sum of TokenUsage::output_tokens.
total_cached_input_tokens: u64Sum of TokenUsage::cached_input_tokens (cache READS).
total_thinking_tokens: u64Sum of TokenUsage::reasoning_tokens (extended thinking /
reasoning tokens — a SUBSET of total_output_tokens).
total_tool_tokens: u64Tokens spent on tool-call traffic. Reserved for future per-tool
breakdown — the engine doesn’t track this separately today, so
it stays 0. Present on the wire so SDKs can render the slot
without a schema bump when the engine starts populating it.
total_cost_usd: f64Sum of per-task USD cost. Always 0.0 when emitted by the
engine — pricing lives in akribes-server. Server-side
enrichment may overwrite before persistence.
task_count: u32Number of TaskEnd events folded into the totals above.
Implementations§
Source§impl WorkflowTotals
impl WorkflowTotals
Sourcepub fn accumulate(&mut self, usage: Option<&TokenUsage>)
pub fn accumulate(&mut self, usage: Option<&TokenUsage>)
Fold a single TokenUsage into the running totals. No-op for
None so the engine can call it on every TaskEnd without
branching on the optional usage field.
Sourcepub fn merge(&mut self, other: &WorkflowTotals)
pub fn merge(&mut self, other: &WorkflowTotals)
Merge another WorkflowTotals (e.g. from a sub-script) into self.
Used by the engine when the relay surfaces a child workflow’s
rollup — the outer chain’s totals subsume every sub-script’s.
Trait Implementations§
Source§impl Clone for WorkflowTotals
impl Clone for WorkflowTotals
Source§fn clone(&self) -> WorkflowTotals
fn clone(&self) -> WorkflowTotals
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for WorkflowTotals
impl Debug for WorkflowTotals
Source§impl Default for WorkflowTotals
impl Default for WorkflowTotals
Source§fn default() -> WorkflowTotals
fn default() -> WorkflowTotals
Source§impl<'de> Deserialize<'de> for WorkflowTotals
impl<'de> Deserialize<'de> for WorkflowTotals
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for WorkflowTotals
impl PartialEq for WorkflowTotals
Source§fn eq(&self, other: &WorkflowTotals) -> bool
fn eq(&self, other: &WorkflowTotals) -> bool
self and other values to be equal, and is used by ==.