Skip to main content

Episode

Enum Episode 

Source
#[non_exhaustive]
pub enum Episode {
Show 13 variants Started { agent: String, }, LlmCall { tokens: u32, latency_ms: u32, provider: Option<String>, model: Option<String>, prompt_tokens: Option<u32>, completion_tokens: Option<u32>, }, ToolCall { name: String, args: Value, result: ToolResult, }, BusPublish { subject: String, }, BusReceive { subject: String, }, BusCausalLink { subject: String, caused_by_run: String, }, Completed, Failed { error: String, }, SummaryCheckpoint { input_message_count: u32, summary_chars: u32, latency_ms: u32, tokens: u32, }, Ops(Value), RunAttributed { tenant_label: String, }, RunOrigin { parent_anchor: String, }, MemoryRecall { query: String, k: u32, returned_fact_ids: Vec<FactId>, },
}
Expand description

One event in the episodic event stream of a single agent run.

Marked #[non_exhaustive] so additive variants (e.g. Self::SummaryCheckpoint) can be introduced without forcing a SemVer-major bump. Match arms in downstream crates must include a fallback _ => ….

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Started

Run started.

Fields

§agent: String

Agent name.

§

LlmCall

LLM call completed.

provider/model/prompt_tokens/completion_tokens are Option so legacy emit sites can leave them None; downstream projectors fall back to the LlmIo sidecar in klieo-runlog when the structured fields are absent.

Fields

§tokens: u32

Total tokens reported by the provider (prompt + completion).

§latency_ms: u32

Wall-clock latency in milliseconds.

§provider: Option<String>

Provider identifier — e.g. "ollama", "openai", "anthropic", "gemini". None for older records or providers that don’t expose a stable name.

#[serde(default)] so legacy episodes serialised under klieo 0.6.x deserialise as None.

§model: Option<String>

Model identifier — e.g. "qwen2.5:14b", "gpt-4o-mini".

§prompt_tokens: Option<u32>

Prompt-side token count when the provider splits the breakdown; None falls back to tokens for total-only reports.

§completion_tokens: Option<u32>

Completion-side token count when the provider splits the breakdown.

§

ToolCall

Tool call completed.

Fields

§name: String

Tool name.

§args: Value

JSON arguments.

§result: ToolResult

Tool outcome.

§

BusPublish

Agent published a bus message.

Fields

§subject: String

Subject.

§

BusReceive

Agent received a bus message.

Fields

§subject: String

Subject.

Causal link: this run received a bus message caused by another run’s publish. Recorded by AgentContext::record_received when the publisher threaded its run id via the klieo-causation-run bus header. Additive — absent on records from publishers that did not thread the causation header.

Fields

§subject: String

Subject the causal handoff occurred on.

§caused_by_run: String

Run id of the publisher that caused this receive.

§

Completed

Run completed successfully.

§

Failed

Run failed.

Fields

§error: String

Error message.

§

SummaryCheckpoint

Summarizer checkpoint completed.

Emitted by crate::summarize::summarize_history in lieu of Self::LlmCall so the audit trail can distinguish summarizer overhead from substantive agent reasoning. Downstream observability (e.g. klieo-runlog) typically projects this as a separate step kind so cost / latency attribution stays faithful.

Fields

§input_message_count: u32

Number of older messages folded into the summary call.

§summary_chars: u32

Length of the resulting summary, in Unicode scalar values.

§latency_ms: u32

Wall-clock latency of the summarizer call.

§tokens: u32

Total tokens reported by the summarizer LLM (prompt + completion).

§

Ops(Value)

Operational-layer event (klieo-ops). Body is an opaque serde_json::Value to keep klieo-core free of an ops dependency. klieo-ops provides typed serde conversion helpers via OpsEvent.

§

RunAttributed

Non-PII tenant attribution stamped at run entry when an external caller drives the run.

tenant_label is a derived identifier (e.g. truncated SHA-256 of the caller’s sub) — never the raw principal, which lives only in server-side tracing/authorization. Emitted at most once per run, adjacent to Self::Started, so the audit trail can attribute each run to its driving tenant without admitting PII into agent memory or LLM-visible context.

Fields

§tenant_label: String

Derived non-PII attribution label for the driving caller.

§

RunOrigin

Cross-hop provenance origin stamped at run entry when an authenticated external caller supplies a parent-chain anchor.

parent_anchor is the caller’s own provenance chain-entry id (or its run’s episodic-root hash) — recorded verbatim so the value equals the caller’s identifier and downstream tooling can stitch klieo→klieo lineage across deployments. It is a caller-asserted, unverified claim (klieo does not own or validate the caller’s chain); it is co-recorded with Self::RunAttributed so the claim is attributable to the authenticated principal that made it. Emitted at most once per run, adjacent to Self::Started; never admitted into agent memory or LLM-visible context.

Fields

§parent_anchor: String

Verbatim caller-supplied cross-hop provenance anchor.

§

MemoryRecall

A graphRAG recall performed during the run. Recorded by the recall-recording wrapper so the run view can surface — and deep-link — retrieval calls. query is redacted + length-bounded at the recording boundary before it reaches this episode.

Fields

§query: String

Redacted, length-bounded recall query text.

§k: u32

Requested top-k.

§returned_fact_ids: Vec<FactId>

Fact ids the recall returned.

Implementations§

Source§

impl Episode

Source

pub fn llm_call(tokens: u32, latency_ms: u32) -> Self

Construct an Episode::LlmCall with the legacy two-field shape (tokens + latency_ms), leaving the 0.7-added provider/model/prompt_tokens/completion_tokens fields as None.

Use this when the emit site does not have the enriched fields to hand — e.g. test fixtures, providers that only report total tokens, or call sites being migrated incrementally. For full 0.7 emit semantics, construct the struct variant directly.

use klieo_core::Episode;
let ep = Episode::llm_call(42, 17);
match ep {
    Episode::LlmCall { tokens, latency_ms, provider, .. } => {
        assert_eq!(tokens, 42);
        assert_eq!(latency_ms, 17);
        assert!(provider.is_none());
    }
    _ => unreachable!(),
}

Trait Implementations§

Source§

impl Clone for Episode

Source§

fn clone(&self) -> Episode

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Episode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Episode

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Episode

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more