#41372·sglang

[Bug]: scheduler Req.decoded_text is never written: dead stop-string fallback at schedule_batch.py:1846 and empty DecodeStatus seed on eviction re-init

Author: ptimizeroracleCreated Sep 26, 2026Updated Sep 30, 2026

description

Req.decoded_text is initialized to "" at python/sglang/srt/managers/schedule_batch.py:1163 and never written anywhere in the tree. it has three readers:

  1. scheduler stop-string fallback, python/sglang/srt/managers/schedule_batch.py:1846:
if stop_str_in_tail or stop_str in self.decoded_text:

under the _stop_match_tail_len window (python/sglang/srt/managers/schedule_batch.py:1735-1745, sized from stop_str_max_len, which normalize() sets to the max stop length, python/sglang/srt/sampling/sampling_params.py:317-323), any live match ends inside tail_str, so the self.decoded_text clause is unreachable. dead check on the finish hot path.

  1. the output streamer forwards it to the detokenizer payload, python/sglang/srt/managers/scheduler_components/output_streamer.py:478 -> :693 (decoded_texts=self.decoded_texts).

  2. the detokenizer seeds DecodeStatus.decoded_text from it on first registration, python/sglang/srt/managers/detokenizer_manager.py:313. for a fresh request "" is correct. but first registration also happens after decode-status eviction (the SGLANG_DETOKENIZER_MAX_STATES path, #2812, same territory as #41236/#41237), so the re-initialized status loses the accumulated-text base. at finish, trim_matched_stop runs over s.get_decoded_text() + new_text (python/sglang/srt/managers/detokenizer_manager.py:407-410), i.e. post-eviction text only. a stop string that completed partly before eviction and partly after escapes the trim. only incremental_output is emitted downstream (python/sglang/srt/managers/detokenizer_manager.py:417), so the full-text truncation itself is contained today.

question

was the scheduler supposed to maintain decoded_text (the writer looks never implemented rather than removed), or should the field and its readers be dropped? i can send either fix:

  • remove the field, the dead fallback clause at :1846, and the payload plumb-through, or
  • maintain the accumulated text on the scheduler side so the eviction re-init and the fallback get real data (hot-path cost: an append per step).

verified on current main fc9e1c8d. no test pins the current behavior (no test references decoded_text on the scheduler Req).