Skip to main content

SpanLog

Struct SpanLog 

Source
pub struct SpanLog { /* private fields */ }
Expand description

A bounded, in-order log of tool spans, built by pairing a harness’s “call started” and “call finished” records by call id.

Records arrive interleaved and out of order (agents run tools in parallel), so a span is closed by searching back for the still-open span with that id rather than assuming the most recent one.

Implementations§

Source§

impl SpanLog

Source

pub fn unbounded() -> Self

A log that keeps every span. For a one-shot pass over a whole transcript, never for the live tracker, where the memory and the clone per refresh would grow with the session.

Source

pub fn open( &mut self, id: String, name: String, at: SystemTime, sidechain: bool, )

Record the start of a tool call. Ignored when that id is already open, so a transcript line replayed by the harness does not double-count.

Source

pub fn open_kind( &mut self, id: String, name: String, at: SystemTime, sidechain: bool, kind: SpanKind, )

open, for any kind of span.

Source

pub fn end_at(&mut self, id: &str, at: SystemTime)

Move the end of the newest span with this id to at, open or not. An inference span grows as the response streams in, one content block per line, and its end is wherever the last block landed.

Source

pub fn open_of_kind(&self, kind: SpanKind) -> Option<&ToolSpan>

The newest open span of this kind, if any.

Source

pub fn discard_open(&mut self, id: &str)

Remove the newest span with this id if it is still open. For a span that turned out not to be one: an inference that never produced a reply because the user interrupted or submitted again.

Source

pub fn close(&mut self, id: &str, at: SystemTime, error: bool)

Close the open call with this id. A result whose call scrolled out of the window, or that we never saw start, is dropped.

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn iter( &self, ) -> impl DoubleEndedIterator<Item = &ToolSpan> + ExactSizeIterator

Oldest first. Double-ended so callers can take the newest spans without collecting the whole log first, which the UI and the golden tests both do.

Source

pub fn to_vec(&self) -> Vec<ToolSpan>

Source

pub fn merged<'a>( logs: impl IntoIterator<Item = &'a SpanLog>, cap: usize, ) -> SpanLog

One log from several, ordered by start time, keeping the newest cap. A parent’s spans and its subagents’ spans interleave in wall-clock order, which is what a waterfall wants.

Source

pub fn cap(&self) -> usize

Trait Implementations§

Source§

impl Clone for SpanLog

Source§

fn clone(&self) -> SpanLog

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 SpanLog

Source§

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

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

impl Default for SpanLog

Source§

fn default() -> Self

Returns the “default value” for a type. 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> 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.