Skip to main content

Module reasoning

Module reasoning 

Source
Expand description

Shared parsing for declared model reasoning protocols.

Structs§

ParsedReasoningResponse

Constants§

GEMMA_THOUGHT_END_TAG
GEMMA_THOUGHT_START_TAG
THINK_END_TAG
THINK_START_TAG

Functions§

has_unclosed_model_reasoning_block
has_unclosed_thinking_block
model_reasoning_markers
The full generated opening header and closing marker of a reasoning block. Harmony owns a separate message protocol rather than a delimited block.
parse_model_reasoning_response
Parse a cumulative generated prefix without exposing partial protocol markers. Gemma accepts only the declared thought channel; ordinary words such as “thought” remain ordinary content outside that channel.
parse_reasoning_response
parse_reasoning_response_for_prompt
parse_reasoning_response_started_in_think
Parse generated text when the rendered prompt already opened <think>. Some reasoning templates emit only the closing tag in generated text.
should_defer_model_reasoning_stream_delta
Hold only prefixes that can still become framing, not complete responses. Callers retain the cumulative input and parse it again when more arrives.