Skip to main content

LoopRecord

Struct LoopRecord 

Source
pub struct LoopRecord {
Show 19 fields pub loop_id: String, pub session_id: String, pub agent_id: String, pub parent_loop_id: Option<String>, pub continuation_kind: ContinuationKind, pub started_at: DateTime<Utc>, pub ended_at: Option<DateTime<Utc>>, pub status: LoopStatus, pub rejection: Option<String>, pub config: Option<LoopConfigSnapshot>, pub messages: Vec<AgentMessage>, pub turns: Vec<Turn>, pub usage: Usage, pub metadata: Option<Value>, pub events: Vec<LoopEvent>, pub children_loop_ids: Vec<String>, pub child_loop_refs: Vec<ChildLoopRef>, pub parallel_group: Option<ParallelGroupRecord>, pub compaction_block: Option<CompactionBlock>,
}
Expand description

A complete record of one agent-loop execution.

§Loop origin classification

parent_loop_idcontinuation_kindMeaning
NoneInitialFresh origin loop (agent_loop)
Some(p), same sessionDefaultRegular continuation
Some(p), same sessionRerunRetry / error recovery
Some(p), same sessionBranchBranch exploration
Some(p), different sessionInitialSub-agent loop (spawned by a tool)

§Tree navigation

Fields§

§loop_id: String

Unique identifier for this loop execution.

§session_id: String

Session this loop belongs to.

§agent_id: String

Agent that ran this loop.

§parent_loop_id: Option<String>

loop_id of the loop that directly preceded this one (if any).

  • None for origin loops (started by agent_loop).
  • Some(id) for continuations started by agent_loop_continue.
  • For sub-agent loops, parent_loop_id refers to the tool call loop in a different session.
§continuation_kind: ContinuationKind

How this loop relates to its parent.

  • Initial for origin loops (agent_loop) and sub-agent loops.
  • Default for regular same-session continuations.
  • Rerun for retries / error recovery.
  • Branch {..} for branch explorations.
§started_at: DateTime<Utc>

Timestamp from AgentStart.

§ended_at: Option<DateTime<Utc>>

Timestamp from AgentEnd (None while running or pending).

§status: LoopStatus§rejection: Option<String>

Set when AgentEnd.rejection is Some(_) (input filter blocked the run).

§config: Option<LoopConfigSnapshot>

Identifies the model and provider that ran this loop.

Populated from the first Message::Assistant seen in the loop. None if the loop ended before any assistant message was produced.

§messages: Vec<AgentMessage>

All new messages produced by this loop — taken directly from AgentEnd.messages.

These are the authoritative messages for replay and branching. To resume from a loop, reconstruct an AgentContext with the full message history (prior loop messages + these) and call agent_loop_continue.

§turns: Vec<Turn>

Materialized turn records, one per LLM call-response cycle.

Built by [SessionRecorder] from TurnStart/TurnEnd event pairs. Empty for old sessions that predate turn materialization, or for loops that ended before any turn completed (rejected, aborted).

§usage: Usage

Token usage from AgentEnd.usage.

§metadata: Option<Value>

Opaque metadata passed to AgentStart by the caller (e.g. request id).

§events: Vec<LoopEvent>

Ordered event stream for this loop.

MessageUpdate (streaming delta) events are included only when [SessionRecorderConfig::include_streaming_events] is true.

§children_loop_ids: Vec<String>

loop_ids of same-session child loops (continuations / reruns / branches).

This is the parent→children direction of the bidirectional loop tree. The inverse (children → parent) is parent_loop_id.

Does not include cross-session sub-agent children — those are in child_loop_refs.

§child_loop_refs: Vec<ChildLoopRef>

Cross-session links to sub-agent loops spawned by tool calls in this loop.

Each entry corresponds to a ToolExecutionEnd.child_loop_id that is Some(_). Use the child_session_id to load the child Session.

§parallel_group: Option<ParallelGroupRecord>

Set when this loop was part of an evaluational-parallelism group.

§compaction_block: Option<CompactionBlock>

Non-destructive compaction overlay. When Some, the context loader uses this block instead of raw self.messages. The original messages remain untouched.

Implementations§

Source§

impl LoopRecord

Source

pub fn get_turn(&self, turn_index: u32) -> Option<&Turn>

Get a turn by its index. Returns None if turns are not materialized or the index is out of range.

Source

pub fn turn_count(&self) -> usize

Number of materialized turns. Returns 0 if turns are not materialized.

Trait Implementations§

Source§

impl Clone for LoopRecord

Source§

fn clone(&self) -> LoopRecord

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 LoopRecord

Source§

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

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

impl<'de> Deserialize<'de> for LoopRecord

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 LoopRecord

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<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> 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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<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
Source§

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