Skip to content

v0.5.0 — Performance & Reliability Optimizations

Choose a tag to compare

@BANG404 BANG404 released this 20 Mar 04:26
· 9 commits to main since this release

What's New in v0.5.0

Bug Fixes

  • Thread safety: replaced the boolean _sync_token_refresh_lock flag with a proper threading.Lock, eliminating the race condition where two threads could concurrently enter _refresh_token_sync.
  • Exception specificity: auth.py cache operations now catch OSError / FileNotFoundError / json.JSONDecodeError explicitly instead of bare except Exception, preventing silent swallowing of unexpected errors.

Performance Improvements

  • Proactive token expiry: _token property now checks token expiration with a 60-second buffer, preventing 401 errors near expiry boundaries.
  • Retry jitter: exponential backoff in all retry loops (ChatGithubCopilot and GithubcopilotChatEmbeddings) now adds up to 25% random jitter to avoid thundering-herd retry storms.
  • Embeddings retry sleep: GithubcopilotChatEmbeddings now sleeps between retries (previously retried immediately with no delay).
  • Module-level imports: asyncio, logging, random, and time moved from function-level late imports to module-level in chat_models.py.

Code Quality

  • Structured logging: logger.warning / logger.debug added to token cache operations for better observability.
  • Deduplication: _make_usage_chunk() static method extracted to eliminate duplicated usage-chunk construction between _stream and _astream.
  • Token expiry propagation: expires_at is now stored in _cached_copilot_token_expires_at across 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_chunk fields, and auth cache logging.

Full Changelog: https://github.com/BANG404/langchain-githubcopilot-chat/blob/main/CHANGELOG.md