pub struct RunCost {
pub run: RunId,
pub itinerary: ItineraryId,
pub agent: AgentName,
pub pipeline: Option<PipelineName>,
pub model: Option<String>,
pub usage: TokenUsage,
pub usd: f64,
pub source: CostSource,
pub at: Timestamp,
}Expand description
What one run cost, and how well that is known.
Fields§
§run: RunIdThe run this describes.
itinerary: ItineraryIdThe chain it belonged to.
agent: AgentNameWhich agent was run.
pipeline: Option<PipelineName>The pipeline whose trigger began this chain, when one did.
Carried here rather than only on the run record so that spend can be attributed to the workflow that caused it. “What does the nightly sweep cost me” is the first question a factory with several pipelines raises, and per-agent totals cannot answer it when an agent belongs to more than one.
model: Option<String>Which model, when the runner said.
usage: TokenUsageTokens consumed, as far as they are known.
usd: f64Cost in US dollars. Always zero when source is CostSource::Unreported.
source: CostSourceWhere usd came from.
at: TimestampWhen the run finished.
Implementations§
Source§impl RunCost
impl RunCost
Sourcepub fn reported(
run: RunId,
itinerary: ItineraryId,
agent: AgentName,
model: Option<String>,
usage: TokenUsage,
usd: f64,
) -> Self
pub fn reported( run: RunId, itinerary: ItineraryId, agent: AgentName, model: Option<String>, usage: TokenUsage, usd: f64, ) -> Self
Records a cost the runner reported directly.
A non-finite or negative figure is treated as no report at all rather than trusted: it
comes from parsing a child process’s output, and a NaN in a budget poisons every total
downstream of it.
Sourcepub fn unreported(
run: RunId,
itinerary: ItineraryId,
agent: AgentName,
model: Option<String>,
) -> Self
pub fn unreported( run: RunId, itinerary: ItineraryId, agent: AgentName, model: Option<String>, ) -> Self
Records a run whose runner said nothing about cost.
Sourcepub fn from_pipeline(self, pipeline: PipelineName) -> Self
pub fn from_pipeline(self, pipeline: PipelineName) -> Self
Attributes the cost to the workflow that caused it.