fix(compression): anchor merged-replay detection on the last summary marker
_has_merged_inflight_replay partitioned on the FIRST end marker. A merged-into-tail carrier can embed an older carrier (marker + replay header + task) in its prior-context block, ahead of the new summary's own marker, so a carrier with nothing after its real boundary was misread as already carrying the active request. _find_inflight_user_task would stop there and the reappend would drag the new summary body into the task text. rpartition anchors on the real boundary; summary bodies never keep an inner marker and the _force_user_leading layout has exactly one, so every legitimate layout still matches. Also compute the stripped remainder once and use removeprefix instead of a manual length slice. Co-authored-by: ppazosp <pablopazosp3@gmail.com>
This commit is contained in:
@@ -4762,11 +4762,15 @@ Write only the summary body. Do not include any preamble or prefix."""
|
||||
if not cls._is_context_summary_message(message):
|
||||
return False
|
||||
text = _content_text_for_contains(message.get("content"))
|
||||
_, boundary, remainder = text.partition(_SUMMARY_END_MARKER)
|
||||
# The LAST end marker is the real handoff boundary: a merged-into-tail
|
||||
# carrier can embed an older carrier (marker + replay) in its prior
|
||||
# context, ahead of the new summary's own marker.
|
||||
_, boundary, remainder = text.rpartition(_SUMMARY_END_MARKER)
|
||||
rest = remainder.lstrip()
|
||||
return bool(
|
||||
boundary
|
||||
and remainder.lstrip().startswith(_INFLIGHT_TASK_REPLAY_HEADER)
|
||||
and remainder.lstrip()[len(_INFLIGHT_TASK_REPLAY_HEADER):].strip()
|
||||
and rest.startswith(_INFLIGHT_TASK_REPLAY_HEADER)
|
||||
and rest.removeprefix(_INFLIGHT_TASK_REPLAY_HEADER).strip()
|
||||
)
|
||||
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user