Skip to content

Commit 8c01c31

Browse files
committed
Optimize: Check realtime mode early in _on_turn_event TurnEndedEvent
- Add early return for realtime mode after logging the event - Skips unnecessary transcript fetching and participant metadata extraction - Removes redundant realtime_mode check later in the flow - Consistent with _on_transcript optimization
1 parent f4fa0a5 commit 8c01c31

File tree

1 file changed

+5
-1
lines changed
  • agents-core/vision_agents/core/agents

1 file changed

+5
-1
lines changed

agents-core/vision_agents/core/agents/agents.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,10 @@ async def _on_turn_event(self, event: TurnStartedEvent | TurnEndedEvent) -> None
691691
f"👉 Turn ended - participant {event.speaker_id} finished (duration: {event.duration}, confidence: {event.confidence})"
692692
)
693693

694+
# In realtime mode, the LLM handles turn detection and responses itself
695+
if self.realtime_mode:
696+
return
697+
694698
# When turn detection is enabled, trigger LLM response when user's turn ends
695699
# This is the signal that the user has finished speaking and expects a response
696700
if event.speaker_id and event.speaker_id != self.agent_user.id:
@@ -707,7 +711,7 @@ async def _on_turn_event(self, event: TurnStartedEvent | TurnEndedEvent) -> None
707711
participant = event.custom.get('participant')
708712

709713
# Trigger LLM response with the complete transcript
710-
if not self.realtime_mode and self.llm:
714+
if self.llm:
711715
await self.simple_response(transcript, participant)
712716

713717
# Clear the pending transcript for this speaker

0 commit comments

Comments
 (0)