#[non_exhaustive]pub enum AssistantBlock {
Text {
text: String,
cache_control: Option<CacheControl>,
},
ToolCall {
id: String,
name: String,
args: Value,
cache_control: Option<CacheControl>,
},
Reasoning {
text: String,
signature: Option<String>,
},
RedactedReasoning {
data: String,
},
}Expand description
One block inside a Message::Assistant turn.
Block ordering is preserved on replay because some providers (Anthropic extended thinking) require the original sequence on every subsequent request.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Text
Visible model-authored text.
Fields
cache_control: Option<CacheControl>ToolCall
A tool invocation request from the model. Pair with a
UserBlock::ToolResult in the next user turn that matches
id to call_id.
Fields
id: StringProvider-assigned id; mirrors back as call_id on the
matching UserBlock::ToolResult.
name: StringTool name as registered in the crate::ChatRequest::tools
list.
args: ValueJSON arguments. Adapters serialize this through to the provider verbatim; the engine does not validate the schema.
cache_control: Option<CacheControl>Reasoning
Visible reasoning emitted by the model. signature is provider-issued
material that must be replayed verbatim on subsequent turns when tools
are involved (Anthropic extended thinking). Providers without a
signature concept (e.g. OpenAI reasoning) leave it None.
Reasoning blocks intentionally have no cache_control slot:
Anthropic does not accept the field on thinking /
redacted_thinking blocks. Place breakpoints on adjacent text or
tool blocks instead.
Fields
RedactedReasoning
Opaque reasoning block whose content the provider chose to hide.
data is verbatim provider material — store it untouched and replay
it back when the next request continues a tool-use chain.
Implementations§
Source§impl AssistantBlock
impl AssistantBlock
Sourcepub fn text(text: impl Into<String>) -> Self
pub fn text(text: impl Into<String>) -> Self
Build an AssistantBlock::Text with no cache breakpoint.
Sourcepub fn tool_call(
id: impl Into<String>,
name: impl Into<String>,
args: Value,
) -> Self
pub fn tool_call( id: impl Into<String>, name: impl Into<String>, args: Value, ) -> Self
Build an AssistantBlock::ToolCall with no cache breakpoint.
Sourcepub fn with_cache_control(self, cache_control: Option<CacheControl>) -> Self
pub fn with_cache_control(self, cache_control: Option<CacheControl>) -> Self
Builder-style helper: set or replace the cache breakpoint on this block. No-op for reasoning variants (they do not carry cache breakpoints on the wire).
Sourcepub fn cache_control(&self) -> Option<&CacheControl>
pub fn cache_control(&self) -> Option<&CacheControl>
Read the current cache breakpoint. Always None for the
reasoning variants (they do not carry breakpoints on the wire).
Trait Implementations§
Source§impl Clone for AssistantBlock
impl Clone for AssistantBlock
Source§fn clone(&self) -> AssistantBlock
fn clone(&self) -> AssistantBlock
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AssistantBlock
impl Debug for AssistantBlock
Source§impl<'de> Deserialize<'de> for AssistantBlock
impl<'de> Deserialize<'de> for AssistantBlock
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for AssistantBlock
impl PartialEq for AssistantBlock
Source§fn eq(&self, other: &AssistantBlock) -> bool
fn eq(&self, other: &AssistantBlock) -> bool
self and other values to be equal, and is used by ==.