-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Copy of PR #435 - make start_session non blocking #2
Conversation
Co-authored-by: Howard Gil <[email protected]>
🔍 Code Review Summary❗ Attention Required: This push has potential issues. 🚨 Overview
🚨 Critical IssuesPerformance (2 issues)1. Optimize session start and stop handling📁 File: agentops/session.py 💡 Solution: Current Code: ["[LINE 364][UPDATED] def _run(self, callback: Optional[Callable[['Session'], None]] = None) -> None:", '[LINE 365][UPDATED] self.is_running = self._start_session()', '[LINE 366][UPDATED] ', '[LINE 367][UPDATED] if callback:', '[LINE 368][UPDATED] callback(self)', '[LINE 369][UPDATED] ', '[LINE 370][UPDATED] if self.is_running == False:', '[LINE 371][UPDATED] self.stop_flag.set()', '[LINE 372][UPDATED] self.thread.join(timeout=1)'] Suggested Code: ["[LINE 364] def _run(self, callback: Optional[Callable[['Session'], None]] = None) -> None:", '[LINE 365] self.is_running = self._start_session_async(callback)', '[LINE 366] ', '[LINE 367] while not self.stop_flag.is_set():', '[LINE 368] time.sleep(self.config.max_wait_time / 1000)', '[LINE 369] if self.queue and self.jwt is not None:', '[LINE 370] self._flush_queue()', '[LINE 371] ', '[LINE 372] self._stop_session()', '[LINE 373] ', "[LINE 374] def _start_session_async(self, callback: Optional[Callable[['Session'], None]] = None) -> bool:", '[LINE 375] self.thread = threading.Thread(target=self._start_session_worker, args=(callback,))', '[LINE 376] self.thread.daemon = True', '[LINE 377] self.thread.start()', '[LINE 378] return True', '[LINE 379] ', '[LINE 380] def _stop_session(self) -> None:', '[LINE 381] self.stop_flag.set()', '[LINE 382] self.thread.join(timeout=1)'] 2. Ensure API key is not logged in error messages📁 File: agentops/session.py 💡 Solution: Current Code: ['[LINE 286][UPDATED] logger.error(f"Could not start session - server could not authenticate your API Key")'] Suggested Code: ['[LINE 286] logger.error("Could not start session - server could not authenticate your API Key")']
Useful Commands
|
Enhance Client Initialization and Session Management
Improve the initialization process of the Client and enhance session management capabilities.
_initialize_autogen_logger()
method to configure logging for autogen.Session
class to handle session state changes.These changes streamline the session management process and improve logging, potentially enhancing debugging and monitoring capabilities.
Original Description
## 📥 Pull Request📘 Description
Make start session non-blocking
(This PR was copied from AgentOps-AI/agentops PR AgentOps-AI#435)