Skip to content

Delete pycache/egg files + fix computer use model - #11

Merged
rm-openai merged 2 commits into
mainfrom
rm/ignores
Mar 11, 2025
Merged

Delete pycache/egg files + fix computer use model#11
rm-openai merged 2 commits into
mainfrom
rm/ignores

Conversation

@rm-openai

@rm-openai rm-openai commented Mar 11, 2025

Copy link
Copy Markdown
Collaborator

These slipped in because I forgot to add the gitignore initially. Remove them.

Also fixed computer use model

@rm-openai rm-openai changed the title Delete pycache/egg files Delete pycache/egg files + fix computer use model Mar 11, 2025
@rm-openai
rm-openai merged commit 829ebc5 into main Mar 11, 2025
@sbera77

sbera77 commented Mar 11, 2025

Copy link
Copy Markdown
Contributor

I noticed that the pycache folders haven't been completely removed yet . I previously submitted a PR #4 that covers all of them

@rm-openai
rm-openai deleted the rm/ignores branch March 13, 2025 01:15
DIZ-admin pushed a commit to DIZ-admin/openai-agents-python that referenced this pull request Nov 18, 2025
Implemented comprehensive session lifecycle management:
- SessionManager class with LRU eviction policy
- Automatic cleanup of expired sessions
- Connection pooling and reuse
- Memory leak prevention

Features:
- LRU cache with configurable max_sessions limit
- Automatic eviction of least recently used sessions
- TTL-based session expiration (default: 1 hour)
- Background cleanup task (default: 5 minutes interval)
- Thread-safe session access with asyncio.Lock
- Statistics tracking (cache hits, misses, evictions)

Session Lifecycle:
1. get_session() - Get or create session (lazy initialization)
2. Session pooling - Reuse existing sessions
3. LRU eviction - Remove oldest when at capacity
4. TTL expiration - Cleanup inactive sessions
5. Graceful shutdown - Close all sessions on shutdown

Memory Leak Prevention:
- Proper connection cleanup via clear_session()
- Automatic eviction prevents unbounded growth
- Background task removes expired sessions
- Shutdown closes all active sessions

Integration:
- Added to DIContainer with lazy initialization
- Integrated into initialize() and shutdown() lifecycle
- Configurable via ErniConfig.data_dir

Configuration:
- max_sessions: 100 (prevents memory exhaustion)
- session_ttl: 3600 seconds (1 hour)
- cleanup_interval: 300 seconds (5 minutes)
- db_path: data/sessions.db (persistent storage)

Benefits:
- Prevents memory leaks from unclosed connections
- Reduces database connection overhead
- Improves performance with session reuse
- Automatic cleanup of stale sessions
- Thread-safe concurrent access

Tests:
- 13 comprehensive unit tests
- Test LRU eviction, TTL expiration, cleanup
- Test concurrent access, statistics
- All tests passing (13/13)

Before:
- Sessions created but never cleaned up
- Database connections left open
- Memory usage grows unbounded
- No session reuse

After:
- Automatic session lifecycle management
- Proper connection cleanup
- Bounded memory usage (max 100 sessions)
- Session pooling and reuse
- Background cleanup task

Resolves: openai#11 (HIGH priority)
Impact: Eliminates memory leaks and improves stability
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants