Skip to content

Documentation / @agentick/openai / ThinkTagParser

Class: ThinkTagParser ​

Defined in: think-tag-parser.ts:20

Streaming parser that extracts <think>...</think> blocks from text deltas and converts them to reasoning deltas.

For OpenAI-compatible servers (LM Studio, ollama) that don't extract reasoning content server-side and instead emit raw think tags in delta.content.

State machine with two modes:

  • "text": content outside think tags → emitted as text deltas
  • "reasoning": content inside think tags → emitted as reasoning deltas

Handles tags that span chunk boundaries via an internal buffer.

Constructors ​

Constructor ​

new ThinkTagParser(): ThinkTagParser

Returns ​

ThinkTagParser

Methods ​

flush() ​

flush(): AdapterDelta[]

Defined in: think-tag-parser.ts:39

Flush any remaining buffered content at stream end.

Returns ​

AdapterDelta[]


process() ​

process(delta): AdapterDelta[]

Defined in: think-tag-parser.ts:28

Process an AdapterDelta. Non-text deltas pass through unchanged. Text deltas are parsed for think tags.

Parameters ​

delta ​

AdapterDelta

Returns ​

AdapterDelta[]

Released under the ISC License.