Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 17, 2025

Why

Transient httpx.ConnectError exceptions cause OpenAI API calls to fail unnecessarily.

How

  • Added tenacity dependency for retry mechanism
  • Wrapped all OpenAI API calls in OpenAIModelClass with @retry decorator
    • _retry_models_list(), _retry_chat_completions_create(), _retry_images_generate(), _retry_embeddings_create(), _retry_responses_create()
    • Retries up to 3 times with exponential backoff (4-10s) on httpx.ConnectError
  • Extended MockOpenAIClient test fixture with missing methods:
    • models.list() for model discovery and health checks
    • images.generate() for image generation endpoint
    • embeddings.create() for embeddings endpoint

Tests

Existing test suite validates retry logic through mock client methods. Tests now pass with retry-wrapped API calls.

Notes


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI self-assigned this Dec 17, 2025
Add models.list(), images.generate(), and embeddings.create() mock methods to MockOpenAIClient to support the retry logic that was added to OpenAIModelClass.

Co-authored-by: patricklundquist <[email protected]>
Copilot AI changed the title [WIP] Add retry logic for OpenAI API calls [EAGLE-7083]: Add retry logic to OpenAI API calls and fix test mocks Dec 17, 2025
@patricklundquist patricklundquist marked this pull request as ready for review December 18, 2025 18:17
@patricklundquist patricklundquist merged commit 50a61e0 into feat-add-retry-logic-4482978964553140365 Dec 18, 2025
1 check passed
@patricklundquist patricklundquist deleted the copilot/sub-pr-878 branch December 18, 2025 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants