Skip to main content

TranscriptMessage

Enum TranscriptMessage 

Source
pub enum TranscriptMessage {
    System {
        id: String,
        created_at: String,
        content: String,
        pinned: bool,
    },
    User {
        id: String,
        created_at: String,
        content: String,
        trust: Option<TrustEnvelope>,
        pinned: bool,
        attachments: Vec<ReferenceMeta>,
    },
    Assistant {
        id: String,
        created_at: String,
        content: String,
        reasoning_content: Option<String>,
        tool_calls: Vec<ToolCall>,
        pinned: bool,
    },
    Tool {
        id: String,
        created_at: String,
        tool_call_id: String,
        summary: String,
        output: Option<OutputRef>,
        trust: Option<TrustEnvelope>,
        is_error: bool,
        pinned: bool,
        process_id: Option<String>,
    },
    Compact {
        id: String,
        created_at: String,
        summary: String,
        dropped_count: i32,
        pinned: bool,
    },
    Fold {
        id: String,
        created_at: String,
        subtask_id: String,
        summary: String,
        dropped_count: i32,
        archive_ref: String,
        pinned: bool,
    },
}
Expand description

A transcript entry. Discriminated union over the conversation roles plus the compaction boundary marker. Reasoning content is a normalized channel on Assistant — never folded into ordinary content, because per-provider re-feed rules differ (DeepSeek forbids re-feeding CoT; Kimi requires echoing it in tool-call turns).

Variants§

§

System

Fields

§created_at: String
§content: String
§pinned: bool
§

User

Fields

§created_at: String
§content: String
§pinned: bool
§attachments: Vec<ReferenceMeta>

D2 — typed, persisted references attached to this user turn. Metadata-only on the wire (no image bytes — those continue to travel through the legacy Attachment channel). serde-default

  • skip-when-empty keeps every pre-D2 transcript row wire- compatible: rows written before D2 deserialize into an empty vec, rows written after D2 skip the key when no references are attached (so an empty user turn still serializes to the legacy 5-field shape).
§

Assistant

Fields

§created_at: String
§content: String
§reasoning_content: Option<String>
§tool_calls: Vec<ToolCall>
§pinned: bool
§

Tool

The result of a tool call. summary is the compact transcript line; the full (possibly large) payload is referenced by output and kept out of context.

Fields

§created_at: String
§tool_call_id: String
§summary: String
§is_error: bool
§pinned: bool
§process_id: Option<String>
§

Compact

A compaction/tombstone boundary (G7). Marks where older turns were summarized and dropped. Visible in the transcript — compaction is never silent.

Fields

§created_at: String
§summary: String
§dropped_count: i32
§pinned: bool
§

Fold

A context-fold boundary. Marks where a subtask’s sub-trajectory was folded into a summary. The full sub-trajectory is archived to disk and retrievable via archive_ref. Structural (per-subtask), complementary to the 70% emergency compactor.

Fields

§created_at: String
§subtask_id: String
§summary: String
§dropped_count: i32
§archive_ref: String

Reference to the archived sub-trajectory on disk.

§pinned: bool

Implementations§

Source§

impl TranscriptMessage

Source

pub fn set_id(&mut self, value: String)

Rewrite the message id. Used at the storage boundary to migrate legacy constant IDs (tr, final, etc.) to the row-derived canonical form and by the live engine when a re-emitted assistant completion disagrees with the persisted row sequence.

Source

pub fn id(&self) -> &str

Read the message id without disturbing the variant.

Source

pub fn created_at(&self) -> &str

Created-at timestamp; same regardless of variant.

Source

pub fn user( id: impl Into<String>, created_at: impl Into<String>, content: impl Into<String>, trust: Option<TrustEnvelope>, pinned: bool, ) -> Self

Canonical constructor for a User transcript row. Defaults attachments to empty so the many call sites that don’t carry references don’t have to spell out the field. Callers that DO attach references should use TranscriptMessage::user_with_attachments.

Source

pub fn user_with_attachments( id: impl Into<String>, created_at: impl Into<String>, content: impl Into<String>, trust: Option<TrustEnvelope>, pinned: bool, attachments: Vec<ReferenceMeta>, ) -> Self

Canonical constructor for a User transcript row that carries typed D2 references. Use this at the canonical write path (transcript.rs) and the message-submission entry point (api_sessions.rs); all other call sites should use TranscriptMessage::user.

Source

pub fn is_provider_visible(&self) -> bool

Source

pub fn user_attachments(&self) -> &[ReferenceMeta]

Borrow the user-row attachments (empty vec for any non-user variant). Used by the persistence layer to round-trip references across write / read boundaries without coupling to .. destructure shape.

Source

pub fn into_user_attachments(self) -> Vec<ReferenceMeta>

Owned copy of the user-row attachments (empty vec for any non-user variant). Useful at submission time when the row needs to forward attachments to a downstream consumer.

Trait Implementations§

Source§

impl Clone for TranscriptMessage

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 TranscriptMessage

Source§

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

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

impl<'de> Deserialize<'de> for TranscriptMessage

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 TranscriptMessage

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> 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, 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.