Skip to main content

Python class

ReasoningSpan

ReasoningSpan

class max.interfaces.ReasoningSpan(reasoning_with_delimiters, reasoning)

source

Bases: object

Identifies a reasoning span within a token ID sequence.

A reasoning span is a contiguous span of tokens near the start of a reasoning model’s output. In streaming mode with multiple chunks, the reasoning section may consist of one or more reasoning spans across multiple initial chunks.

Tracks both the delimited reasoning span (including delimiter tokens like <think> and </think>) and the reasoning span (excluding delimiters). Uses standard Python slice semantics: [start, end).

Parameters:

  • reasoning_with_delimiters (tuple[int, int]) – The full span including delimiter tokens.
  • reasoning (tuple[int, int]) – The span excluding delimiter tokens. Must be contained within reasoning_with_delimiters.

extract_content()

extract_content(seq)

source

Extracts the non-reasoning elements from a sequence.

Parameters:

seq (Sequence[T]) – The sequence from which to extract non-reasoning elements.

Returns:

The elements outside the delimited reasoning span.

Return type:

list[T]

extract_reasoning()

extract_reasoning(seq)

source

Extracts the reasoning elements from a sequence.

Parameters:

seq (Sequence[T]) – The sequence from which to extract reasoning elements.

Returns:

The elements within the reasoning span, excluding delimiters.

Return type:

list[T]