Skip to content

Commit 4f60ab2

Browse files
committed
fix: remove duplicate track publishing code and initialize error counters
- Remove duplicate track publishing and audio/video listening code in join() method - Initialize timeout_errors and consecutive_errors before video processing loop - Increment timeout_errors in TimeoutError exception handler - Fixes potential crash when error counters are referenced but not initialized
1 parent b121bc6 commit 4f60ab2

File tree

1 file changed

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

1 file changed

+5
-11
lines changed

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

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -241,17 +241,6 @@ async def join(self, call: Call) -> "AgentSessionContextManager":
241241
audio_track = self._audio_track if self.publish_audio else None
242242
video_track = self._video_track if self.publish_video else None
243243

244-
if audio_track or video_track:
245-
with self.tracer.start_as_current_span("edge.publish_tracks"):
246-
await self.edge.publish_tracks(audio_track, video_track)
247-
await self._listen_to_audio_and_video()
248-
249-
self.logger.info(f"🤖 Agent joined call: {call.id}")
250-
251-
# Set up audio and video tracks together to avoid SDP issues
252-
audio_track = self._audio_track if self.publish_audio else None
253-
video_track = self._video_track if self.publish_video else None
254-
255244
if audio_track or video_track:
256245
with self.tracer.start_as_current_span("edge.publish_tracks"):
257246
await self.edge.publish_tracks(audio_track, video_track)
@@ -631,6 +620,10 @@ async def _process_track(self, track_id: str, track_type: str, participant):
631620
self.logger.info("No image processors, video processing handled by video processors only")
632621
return
633622

623+
# Initialize error tracking counters
624+
timeout_errors = 0
625+
consecutive_errors = 0
626+
634627
while True:
635628
try:
636629
# Use the shared forwarder instead of competing for track.recv()
@@ -660,6 +653,7 @@ async def _process_track(self, track_id: str, track_type: str, participant):
660653

661654
except asyncio.TimeoutError:
662655
# Exponential backoff for timeout errors
656+
timeout_errors += 1
663657
backoff_delay = min(2.0 ** min(timeout_errors, 5), 30.0)
664658
self.logger.debug(
665659
f"🎥VDP: Applying backoff delay: {backoff_delay:.1f}s"

0 commit comments

Comments
 (0)