|
2 | 2 | import inspect |
3 | 3 | import traceback |
4 | 4 | import time |
| 5 | +from typing import Optional |
5 | 6 | import uuid |
6 | 7 | import weakref |
7 | 8 | from datetime import datetime, timezone |
@@ -41,7 +42,15 @@ def intercept_session_start(self: AgentSession, room, room_name, agent: Agent): |
41 | 42 | The session info along with room_id, agent_id, etc is stored in the thread-local store. |
42 | 43 | """ |
43 | 44 | maxim_logger = get_maxim_logger() |
44 | | - scribe().debug(f"[Internal][{self.__class__.__name__}] Session started") |
| 45 | + |
| 46 | + # Wait for start signal (max ~5s) before proceeding |
| 47 | + for _ in range(500): |
| 48 | + if getattr(self, "_started", False): |
| 49 | + scribe().debug(f"[Internal][{self.__class__.__name__}] Session started") |
| 50 | + break |
| 51 | + time.sleep(0.01) |
| 52 | + else: |
| 53 | + scribe().debug(f"[Internal][{self.__class__.__name__}] start not signaled within timeout; continuing") |
45 | 54 | # getting the room_id |
46 | 55 | if isinstance(room, str): |
47 | 56 | room_id = room |
@@ -100,10 +109,10 @@ def intercept_session_start(self: AgentSession, room, room_name, agent: Agent): |
100 | 109 | ) |
101 | 110 |
|
102 | 111 | current_turn_id = str(uuid.uuid4()) |
103 | | - if self.stt is not None or self._agent.stt is not NOT_GIVEN: |
| 112 | + if self.stt is not None or agent.stt is not NOT_GIVEN: |
104 | 113 | # Only add generation if we are not in realtime session |
105 | | - llm_opts: _LLMOptions = self.llm._opts if self.llm is not None else self._agent.llm._opts |
106 | | - model = self.llm.model if self.llm is not None else self._agent.llm.model |
| 114 | + llm_opts: _LLMOptions = self.llm._opts if self.llm is not None else agent.llm._opts |
| 115 | + model = self.llm.model if self.llm is not None else agent.llm.model |
107 | 116 | if llm_opts is not None: |
108 | 117 | model_parameters = extract_llm_model_parameters(llm_opts) |
109 | 118 | else: |
|
0 commit comments