v0.5.0 — Performance & Reliability Optimizations
What's New in v0.5.0
Bug Fixes
- Thread safety: replaced the boolean
_sync_token_refresh_lockflag with a properthreading.Lock, eliminating the race condition where two threads could concurrently enter_refresh_token_sync. - Exception specificity:
auth.pycache operations now catchOSError/FileNotFoundError/json.JSONDecodeErrorexplicitly instead of bareexcept Exception, preventing silent swallowing of unexpected errors.
Performance Improvements
- Proactive token expiry:
_tokenproperty now checks token expiration with a 60-second buffer, preventing 401 errors near expiry boundaries. - Retry jitter: exponential backoff in all retry loops (
ChatGithubCopilotandGithubcopilotChatEmbeddings) now adds up to 25% random jitter to avoid thundering-herd retry storms. - Embeddings retry sleep:
GithubcopilotChatEmbeddingsnow sleeps between retries (previously retried immediately with no delay). - Module-level imports:
asyncio,logging,random, andtimemoved from function-level late imports to module-level inchat_models.py.
Code Quality
- Structured logging:
logger.warning/logger.debugadded to token cache operations for better observability. - Deduplication:
_make_usage_chunk()static method extracted to eliminate duplicated usage-chunk construction between_streamand_astream. - Token expiry propagation:
expires_atis now stored in_cached_copilot_token_expires_atacross all token paths (refresh sync/async, cache load).
Tests
- 20 new unit tests covering: thread lock type, lock-held skip behavior, token expiry pre-check, cache expiry propagation, retry jitter (sync + async),
_make_usage_chunkfields, and auth cache logging.
Full Changelog: https://github.com/BANG404/langchain-githubcopilot-chat/blob/main/CHANGELOG.md