Struct CostRecord
pub struct CostRecord {
pub id: String,
pub usage: TokenUsage,
pub session_id: String,
pub conversation_id: Option<String>,
pub agent_alias: Option<String>,
pub task_id: Option<String>,
}Fields§
§id: StringUnique identifier
usage: TokenUsageToken usage details
session_id: StringTracker identifier: one random UUID per daemon process, grouping every
record this daemon emits. This is NOT the chat session — attribute
per-conversation spend through conversation_id.
conversation_id: Option<String>Chat-session identifier (the runtime session key scoped around the
turn), so per-conversation spend can be separated across the sessions
one daemon serves. None for records persisted before the field
existed or turns without a chat-session scope.
agent_alias: Option<String>Alias of the agent that incurred this cost (HashMap key in
config.agents). None for records persisted before per-agent
attribution, or when [cost].track_per_agent = false.
task_id: Option<String>Implementations§
Source§impl CostRecord
impl CostRecord
Sourcepub fn new(session_id: impl Into<String>, usage: TokenUsage) -> CostRecord
pub fn new(session_id: impl Into<String>, usage: TokenUsage) -> CostRecord
Create a new cost record without agent attribution.
Sourcepub fn with_agent(
session_id: impl Into<String>,
agent_alias: Option<String>,
usage: TokenUsage,
) -> CostRecord
pub fn with_agent( session_id: impl Into<String>, agent_alias: Option<String>, usage: TokenUsage, ) -> CostRecord
Create a new cost record attributed to an agent.
Sourcepub fn with_attribution(
session_id: impl Into<String>,
agent_alias: Option<String>,
task_id: Option<String>,
usage: TokenUsage,
) -> CostRecord
pub fn with_attribution( session_id: impl Into<String>, agent_alias: Option<String>, task_id: Option<String>, usage: TokenUsage, ) -> CostRecord
Create a new cost record attributed to an agent and/or durable task.
Sourcepub fn with_conversation_id(self, conversation_id: Option<String>) -> CostRecord
pub fn with_conversation_id(self, conversation_id: Option<String>) -> CostRecord
Attach the chat-session identifier this spend belongs to. The ledger
is append-only JSONL, so the field is additive and older rows read
back as None.
Trait Implementations§
Source§impl Clone for CostRecord
impl Clone for CostRecord
Source§fn clone(&self) -> CostRecord
fn clone(&self) -> CostRecord
1.0.0 (const: unstable) · §fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CostRecord
impl Debug for CostRecord
Source§impl<'de> Deserialize<'de> for CostRecord
impl<'de> Deserialize<'de> for CostRecord
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<CostRecord, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<CostRecord, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for CostRecord
impl Serialize for CostRecord
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for CostRecord
impl RefUnwindSafe for CostRecord
impl Send for CostRecord
impl Sync for CostRecord
impl Unpin for CostRecord
impl UnsafeUnpin for CostRecord
impl UnwindSafe for CostRecord
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more