Skip to main content

Module text_complete

Module text_complete 

Source
Expand description

Heuristic check for whether an LLM response text “looks complete”.

Used to distinguish two situations that look identical on the wire when a stream ends without [DONE] / MessageStop:

  1. Connection truly dropped mid-response — the text ends in the middle of a sentence, mid-word, with an unclosed code fence, etc. The right reaction is to retry the request.

  2. Provider doesn’t honour [DONE] — the stream delivered a full coherent response, then the TCP connection closed without an explicit termination marker. Observed on dialagram + qwen-3.7-max-thinking (2026-05-30). Retrying here regenerates the same content and pegs the “is responding…” indicator for minutes.

Returning true from text_looks_complete lets the caller synthesise a StopReason::EndTurn and proceed; false keeps the existing retry path for genuinely truncated streams.

Conservative by design: we’d rather over-retry a slightly awkward complete response than under-retry a real truncation that needs another shot.

Functions§

text_looks_complete
True when the response text looks structurally complete and safe to accept without a [DONE] marker.