Fix turn completion mixin not resetting state after each LLM response

This commit is contained in:
radhikagpt1208
2026-03-08 13:01:59 +05:30
committed by Mark Backman
parent edd568b002
commit b14c8e0e94
3 changed files with 44 additions and 5 deletions

View File

@@ -332,14 +332,25 @@ class UserTurnCompletionLLMServiceMixin:
if isinstance(frame, InterruptionFrame):
await self._cancel_incomplete_timeout()
await self._turn_reset()
# Reset turn state at end of LLM response (but don't cancel timeout -
# incomplete timeouts should continue running)
elif isinstance(frame, LLMFullResponseEndFrame):
await self._turn_reset()
# Pass frame to parent
await super().process_frame(frame, direction)
async def push_frame(self, frame: Frame, direction: FrameDirection = FrameDirection.DOWNSTREAM):
"""Push a frame downstream, resetting turn state at end of each LLM response.
``LLMFullResponseEndFrame`` is generated by the LLM service itself (pushed,
not received), so it must be handled here rather than in ``process_frame``.
Args:
frame: The frame to push downstream.
direction: The direction of frame flow. Defaults to downstream.
"""
if isinstance(frame, LLMFullResponseEndFrame):
await self._turn_reset()
await super().push_frame(frame, direction)
async def _push_turn_text(self, text: str):
"""Push LLM text with turn completion detection.