ExtractReasoningMiddleware

fun ExtractReasoningMiddleware(tagName: String = "reasoning", separator: String = "", startWithReasoning: Boolean = false): LanguageModelMiddleware(source)

Extracts XML-tagged reasoning sections from generated text and surfaces them as separate ReasoningStart/Delta/End events.

For models that emit reasoning inline (<reasoning>...</reasoning>, <think>...</think>) — strips the tags from the visible text and produces typed reasoning events the UI can render in a collapsible.

Mirrors v6's extractReasoningMiddleware. Useful for Gemma-style models that emit thinking inline rather than via dedicated reasoning channels.