Skip to main content

AssistantBlock

Enum AssistantBlock 

Source
pub enum AssistantBlock {
    Text(TextContent),
    Thinking(TextContent),
    Reasoning(TextContent),
    ReasoningDetails(ReasoningDetailsContent),
    ToolCall(ToolCall),
}
Expand description

Blocks an assistant message can carry.

§Channel separation contract

Thinking and Reasoning are two independent channels and the loop must never mix them:

  • Thinking is prompt-elicited tag-text. The model wraps reasoning inside <thought>...</thought> (or one of the synonym tags handled by crate::ThinkingTagStreamFilter) inside its visible text stream. The bridge parses those tags out of the visible-text channel and stores the captured content here. On the next provider request it is rewoven into the content field as a <thought>...</thought> tag — never as the wire reasoning field.

  • Reasoning and ReasoningDetails are provider-native reasoning. They arrive on a dedicated sideband (delta.reasoning / delta.reasoning_details on the OpenRouter wire) and represent the provider’s own chain-of-thought tokens. On the next provider request they are replayed verbatim through the typed reasoning / reasoning_details fields — never wrapped in a <thought>...</thought> tag in the content field.

The two processes are not interchangeable: tag-elicited scratch is the model writing into its visible output by convention, and the loop strips it before the user sees anything. Provider-native reasoning is the upstream API delivering structured thinking alongside the message. Conflating them risks (a) shipping the model’s hidden scratch as if it were native reasoning (some providers reject unknown content there or refuse to bill it as cached input) and (b) leaking native reasoning into visible text by way of <thought> rewrap (would round-trip native tokens through the visible channel and double-count them).

The invariants are pinned by tests in openrouter_request_tests.rs::channel_separation_invariants and openrouter_stream::tests::stream_chunk_routing_invariants.

Variants§

§

Text(TextContent)

§

Thinking(TextContent)

Prompt-elicited hidden scratchpad. Captured from <thought>...</thought> tags the model writes inside its visible text stream; rewoven into the wire content field as <thought>...</thought> on the next request. Never flows into the wire reasoning field — see the type-level docs for the channel-separation contract.

§

Reasoning(TextContent)

Provider-native reasoning (xAI Grok, OpenAI o-series, Anthropic native thinking). Arrives on the dedicated delta.reasoning sideband and replayed via the wire reasoning field. Never wrapped in a <thought>...</thought> tag inside the content field — see the type-level docs.

§

ReasoningDetails(ReasoningDetailsContent)

Native provider reasoning detail blocks (xAI’s reasoning.encrypted envelopes, etc.). Replayed unmodified on tool-continuation requests for reasoning models that rely on signed/encrypted thinking continuity. Same channel contract as Reasoning.

§

ToolCall(ToolCall)

Tool call request. Loop dispatches via the registry.

Trait Implementations§

Source§

impl Clone for AssistantBlock

Source§

fn clone(&self) -> AssistantBlock

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 AssistantBlock

Source§

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

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

impl<'de> Deserialize<'de> for AssistantBlock

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 PartialEq for AssistantBlock

Source§

fn eq(&self, other: &AssistantBlock) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for AssistantBlock

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
Source§

impl StructuralPartialEq for AssistantBlock

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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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