pub struct ReasoningContentPart {
pub provider: String,
pub item_id: Option<String>,
pub signature: Option<String>,
pub encrypted: Option<String>,
pub text: Option<ReasoningText>,
pub tokens: Option<u32>,
pub bound_tool_call_id: Option<String>,
}Expand description
One provider-issued reasoning artifact, ordered in Message.content
alongside text and tool calls.
Ordering is the point. Providers interleave reasoning with text and tool
calls, and every current provider requires its artifacts replayed in the
position it issued them: Anthropic verifies each thinking block against its
own signature, OpenAI keys reasoning items by the item_id it issued and
expects them adjacent to the item they precede, and Gemini binds a
thoughtSignature to a specific function call. A flattened per-message
field cannot express any of that, so this is a content part.
signature and encrypted are opaque provider artifacts. They are carried
verbatim and never interpreted, never rendered, and never published on an
API surface — see ReasoningContentPart::to_public.
Fields§
§provider: StringProvider that produced this artifact (e.g. anthropic, openai).
Replay is only valid against the provider that issued it.
item_id: Option<String>Provider-assigned identifier, carried verbatim (e.g. OpenAI rs_…).
signature: Option<String>Provider signature over this specific block (Anthropic thinking
signature, Gemini thoughtSignature). Opaque.
encrypted: Option<String>Provider-encrypted reasoning context (OpenAI encrypted_content).
Opaque.
text: Option<ReasoningText>Readable reasoning, when the provider exposes any.
tokens: Option<u32>Reasoning tokens attributed to this artifact, when reported.
bound_tool_call_id: Option<String>Id of the tool call this artifact is bound to, when the provider scopes it that way (Gemini attaches a thought signature to one function call).
Implementations§
Source§impl ReasoningContentPart
impl ReasoningContentPart
Sourcepub fn opaque(provider: impl Into<String>) -> Self
pub fn opaque(provider: impl Into<String>) -> Self
A reasoning part carrying only opaque replay state.
pub fn with_item_id(self, item_id: impl Into<String>) -> Self
pub fn with_signature(self, signature: impl Into<String>) -> Self
pub fn with_encrypted(self, encrypted: impl Into<String>) -> Self
pub fn with_text(self, text: ReasoningText) -> Self
pub fn with_tokens(self, tokens: u32) -> Self
pub fn with_bound_tool_call_id(self, tool_call_id: impl Into<String>) -> Self
Sourcepub fn display_text(&self) -> Option<String>
pub fn display_text(&self) -> Option<String>
Text safe to render on a reasoning channel, if any.
Sourcepub fn has_replay_state(&self) -> bool
pub fn has_replay_state(&self) -> bool
Whether this part carries provider state that must be replayed.
Sourcepub fn to_public(&self) -> Self
pub fn to_public(&self) -> Self
Projection safe to publish on an API surface: opaque provider artifacts removed, readable reasoning kept.
signature and encrypted are replay state, not content. Publishing
them leaks provider-internal material through an API and invites clients
to round-trip values they cannot validate.
Trait Implementations§
Source§impl Clone for ReasoningContentPart
impl Clone for ReasoningContentPart
Source§fn clone(&self) -> ReasoningContentPart
fn clone(&self) -> ReasoningContentPart
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more