Skip to content

Commit f4fa0a5

Browse files
committed
Optimize: Check realtime mode early in _on_transcript
- Add early return if in realtime mode to skip LLM triggering logic - In realtime mode, the LLM handles STT, turn detection, and responses itself - Removes redundant check in else branch - Improves code clarity and efficiency
1 parent 12b1638 commit f4fa0a5

File tree

1 file changed

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

1 file changed

+6
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,11 @@ async def _on_transcript(self, event: STTTranscriptEvent | RealtimeTranscriptEve
767767
self.conversation.complete_message(self._user_conversation_handle)
768768
self._user_conversation_handle = None
769769

770+
# In realtime mode, the LLM handles everything itself (STT, turn detection, responses)
771+
# Skip our manual LLM triggering logic
772+
if self.realtime_mode:
773+
return
774+
770775
# Determine how to handle LLM triggering based on turn detection
771776
if self.turn_detection is not None:
772777
# With turn detection: accumulate transcripts and wait for TurnEndedEvent
@@ -784,7 +789,7 @@ async def _on_transcript(self, event: STTTranscriptEvent | RealtimeTranscriptEve
784789
else:
785790
# Without turn detection: trigger LLM immediately on transcript completion
786791
# This is the traditional STT -> LLM flow
787-
if not self.realtime_mode and self.llm:
792+
if self.llm:
788793
self.logger.info(f"🤖 Triggering LLM response immediately (no turn detection)")
789794

790795
# Get participant from event metadata

0 commit comments

Comments
 (0)