Skip to main content

Event

Enum Event 

Source
pub enum Event {
    ContentDelta {
        id: String,
        kind: ContentKind,
        delta: String,
    },
    ContentFinal {
        id: String,
        kind: ContentKind,
        content: String,
        extensions: SegmentExtensions,
    },
    ToolCallStart {
        id: Id,
        name: Name,
    },
    ToolCallArgumentsDelta {
        id: Id,
        delta: Payload,
    },
    ToolCallFinal {
        call: ToolCall,
        extensions: SegmentExtensions,
    },
    Usage(TokenUsage),
    Done {
        finish_reason: String,
        completion: CompletionReason,
        provider_data: Vec<Envelope>,
    },
}
Expand description

One normalized event produced by a model provider adapter.

Deltas open an item identity and finals close it. Tool calls have an explicit start/arguments/final lifecycle; StreamGrammar validates every pairing.

Deltas are optional. A provider that answers in one frame emits the final alone, and the final’s payload is the whole item; see StreamGrammar::accept. What a final may never do is contradict deltas that were actually sent.

Variants§

§

ContentDelta

A fragment of one text or thinking item.

Fields

§id: String

Stable item identity.

§kind: ContentKind

Portable content lane.

§delta: String

Next exact text fragment.

§

ContentFinal

The complete content and extensions for the same item.

Fields

§id: String

Identity opened by preceding deltas, or by this event when there were none.

§kind: ContentKind

Content lane, matching every delta.

§content: String

The whole item: the exact concatenation of all deltas, or, when no delta was sent, the content itself.

§extensions: SegmentExtensions

Provider data owned by this final item.

§

ToolCallStart

Opens a client-local tool call.

A provider that delivers a call complete in one frame may omit this and send only ToolCallFinal, which names the tool itself.

Fields

§id: Id

Model-assigned call identity.

§name: Name

Selected local tool name.

§

ToolCallArgumentsDelta

Adds opaque argument bytes to the open tool call.

Fields

§id: Id

Identity of the open call.

§delta: Payload

Next exact argument fragment.

§

ToolCallFinal

Closes a tool call with the exact accumulated identity, name, and bytes.

When no argument delta preceded it, this event is the call: its identity, tool name and argument bytes are the whole of what reef records and what the executor receives.

Fields

§call: ToolCall

Complete call value.

§extensions: SegmentExtensions

Provider data owned by this call.

§

Usage(TokenUsage)

Reports token accounting without changing item lifecycle.

§Usage is incremental, and normalising it is the adapter’s obligation

A generation may carry any number of these. Each one reports the tokens consumed since the previous Usage of the same generation, so a generation’s totals are the sum of its usage events, and one event carrying the whole call’s totals is the ordinary single-increment case.

Reef does not and cannot check this. A provider that reports running totals and a provider that reports increments emit sequences core has no way to tell apart, so the rule is an obligation on the adapter rather than a grammar rule: an adapter for a provider that reports running totals must emit the difference, or withhold the numbers and emit one event at the end. An adapter that forwards running totals verbatim is not well-formed, and nothing will say so.

The rule is chosen because summation is the only operation available to the consumer that receives these. They reach a hook through ObserverHooks::model_event and nowhere else, one event at a time, with no per-generation accumulator of reef’s own to subtract from — so a budget policy adds them up. Under the incremental rule that is exact at every scope: within a generation, across the generations of a Run, and across Runs. Forwarded running totals would double-count, and every budget built on them would fire early.

§

Done

The single terminal event.

Fields

§finish_reason: String

Provider’s verbatim finish label.

§completion: CompletionReason

Portable completion classification.

§provider_data: Vec<Envelope>

Provider data owned by the assistant record.

Trait Implementations§

Source§

impl Clone for Event

Source§

fn clone(&self) -> Self

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 Event

Source§

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

Keeps every identity and lane, and sizes the two content fields.

delta and content are the only members of this enum that own model bytes directly. Everything else either identifies an item, classifies a lane, counts tokens, or is a value that already redacts itself — and a stream is debugged by its lifecycle, which those facts describe fully.

Auto Trait Implementations§

§

impl Freeze for Event

§

impl RefUnwindSafe for Event

§

impl Send for Event

§

impl Sync for Event

§

impl Unpin for Event

§

impl UnsafeUnpin for Event

§

impl UnwindSafe for Event

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<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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.