Skip to main content

Module cost

Module cost 

Source
Expand description

Cost tracking for agent runs.

CostTracker observes token usage flowing through the agent and accumulates cost data. It writes a cost.json file into the session directory alongside the JSONL transcript, and can update the session meta file with cost summary fields.

§Usage

let tracker = CostTracker::new(&workspace, "gpt-4o", "openai");
// after runtime.run(...):
tracker.record_usage(outcome.total_usage, outcome.llm_latency_ms);
tracker.finish()?;

Structs§

CostData
Accumulated cost data for a single agent run.
CostPricing
Serializable pricing rates, mirroring ModelPricing but serializable.
CostTracker
Tracks token usage and cost across an agent run, persisting to the session directory.