ThinkingBlock

org.llm4s.llmconnect.model.ThinkingBlock
See theThinkingBlock companion object
@Stable

One block of the reasoning a model produced before its answer, as carried on AssistantMessage.thinking so that it can be sent back in later requests.

Most providers report thinking as plain text - Ollama's thinking, DeepSeek's and Z.ai's reasoning_content, OpenRouter's reasoning, Mistral's thinking chunks - and a message then holds a single ThinkingBlock.Text with no signature. Anthropic (directly or through Bedrock) returns one or more blocks, each signed, and some redacted; it requires them back unchanged, in order, when a thinking model's turn ends in tool calls. So the blocks are kept as the provider returned them, and a client replays only what its provider accepts: Anthropic and Bedrock send signed and redacted blocks and leave unsigned text out (they would reject it), the other providers send the text.

A provider whose replay data does not fit those two shapes - OpenRouter's reasoning_details, whose items carry ids, formats, indices, summaries and encrypted payloads - is kept as ThinkingBlock.Opaque blocks, which only that provider's client sends back.

Attributes

Companion
object
Graph
Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Members list

Type members

Enum entries

final case class Opaque(provider: String, data: String)

Provider-specific replay data that neither Text nor Redacted can hold without loss, kept exactly as the provider returned it. Only the client of provider sends it back, unchanged and in order; every other client ignores it. It is always sealed (see isSealed): valid only beside the message content, tool calls and history it was produced with, and dropped when the message is unsealed. The reasoning text, when the provider returns it, is carried beside it as a Text block, so it survives unsealing and is what ThinkingBlock.text reports.

Provider-specific replay data that neither Text nor Redacted can hold without loss, kept exactly as the provider returned it. Only the client of provider sends it back, unchanged and in order; every other client ignores it. It is always sealed (see isSealed): valid only beside the message content, tool calls and history it was produced with, and dropped when the message is unsealed. The reasoning text, when the provider returns it, is carried beside it as a Text block, so it survives unsealing and is what ThinkingBlock.text reports.

Value parameters

data

The provider's own encoding, opaque to everything but that client - for OpenRouter, one reasoning_details item rendered as JSON.

provider

The id of the provider that produced it, as its client names itself ("openrouter" for OpenRouter's reasoning_details).

Attributes

final case class Redacted(data: String)

Reasoning the provider encrypted rather than returned (Anthropic's redacted_thinking).

Reasoning the provider encrypted rather than returned (Anthropic's redacted_thinking).

Value parameters

data

Opaque payload, passed back unchanged.

Attributes

final case class Text(text: String, signature: Option[String])

Reasoning text.

Reasoning text.

Value parameters

signature

The provider's signature over text, when it signs it (Anthropic, Bedrock). Opaque: passed back unchanged and never interpreted.

text

The model's reasoning. May be empty when the provider withholds the text but still signs the block, as Anthropic does for omitted thinking.

Attributes