Skip to content

feat(ai): OpenAI retry parity — typed error + tests (closes #69)#99

Merged
gh-simili-bot merged 2 commits intomainfrom
feature/openai-retry-parity-issue-69
Mar 5, 2026
Merged

feat(ai): OpenAI retry parity — typed error + tests (closes #69)#99
gh-simili-bot merged 2 commits intomainfrom
feature/openai-retry-parity-issue-69

Conversation

@Kavirubc
Copy link
Copy Markdown
Contributor

@Kavirubc Kavirubc commented Mar 5, 2026

Summary

  • Bug fix: isRetryableError previously never retried OpenAI calls because errors from callOpenAIJSON were plain fmt.Errorf strings with no typed carrier. Introduced *openAIStatusError (carries HTTP status code) so errors.As can detect 429/5xx and retry them identically to Gemini.
  • Testability: Added baseURL string field to both Embedder and LLMClient (empty = production) and a matching parameter to callOpenAIJSON, allowing tests to inject an httptest.Server URL without any mocking framework.
  • Tests: 8 new tests in openai_retry_test.go covering retry-on-429, retry-on-500, no-retry-on-400, and retry exhaustion for both embedOpenAI and generateOpenAIText.

Files changed

File Change
internal/integrations/ai/retry.go Add openAIStatusError; update isRetryableError
internal/integrations/ai/provider.go Return *openAIStatusError; add baseURL param to callOpenAIJSON
internal/integrations/ai/embedder.go Add baseURL field; pass to callOpenAIJSON
internal/integrations/ai/llm.go Add baseURL field; pass to callOpenAIJSON
internal/integrations/ai/openai_retry_test.go New — all 8 retry tests

Test plan

  • go test ./internal/integrations/ai/... -run TestEmbedOpenAI -v — all 4 pass
  • go test ./internal/integrations/ai/... -run TestGenerateOpenAIText -v — all 4 pass
  • go test ./... — full suite passes (12/12 packages)
  • go build ./... — no compilation errors
  • go vet ./... — no issues

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 5, 2026

Warning

Rate limit exceeded

@Kavirubc has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 5 minutes and 23 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 18090923-a445-4c11-b593-4c4971892b06

📥 Commits

Reviewing files that changed from the base of the PR and between 3fb471a and 8ec0698.

📒 Files selected for processing (5)
  • internal/integrations/ai/embedder.go
  • internal/integrations/ai/llm.go
  • internal/integrations/ai/openai_retry_test.go
  • internal/integrations/ai/provider.go
  • internal/integrations/ai/retry.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/openai-retry-parity-issue-69

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Kavirubc added 2 commits March 5, 2026 13:09
…retry parity

- Introduce *openAIStatusError in retry.go so isRetryableError recognises
  OpenAI 429/5xx responses and retries them (previously unretried)
- Add baseURL param to callOpenAIJSON (empty = production openAIBaseURL)
- Add unexported baseURL field to Embedder and LLMClient for test injection

Signed-off-by: Kavirubc <hapuarachchikaviru@gmail.com>
8 httptest-based tests covering 429/5xx retry, non-retryable 400,
and retry exhaustion for both embedOpenAI and generateOpenAIText.

Signed-off-by: Kavirubc <hapuarachchikaviru@gmail.com>
@Kavirubc Kavirubc force-pushed the feature/openai-retry-parity-issue-69 branch from 3156ea6 to 8ec0698 Compare March 5, 2026 07:40
@gh-simili-bot
Copy link
Copy Markdown
Contributor

Simili Triage Report

Note

Quality Score: 9.5/10 (Excellent)
The issue could be improved. See suggestions below.

Classification

Category Value
Labels
Quality Improvements
Similar Threads
Similarity Type Thread Status
86% 🔀 #66 fix: harden retry logic - typed error checking ... Open
83% 📝 #69 feat: add retry logic for OpenAI API calls (par... Open
79% 📝 #50 [Reliability]: Implement Exponential Backoff fo...

Warning

Possible Duplicate (Confidence: 98%)
This pull request might be a duplicate of #69.
Reason: The current issue's title explicitly states 'closes #69'. Issue #69's title 'feat: add retry logic for OpenAI API calls (parity with Gemini)' perfectly matches the summary of the current issue, which describes implementing typed error handling and tests to enable OpenAI retry parity with Gemini. They describe the exact same feature/bug fix, and fixing the current issue fully resolves #69.

This pull request will be automatically closed in 72 hours if no objections are raised. If you believe this is not a duplicate, please leave a comment explaining why.


Generated by Simili Bot

@gh-simili-bot
Copy link
Copy Markdown
Contributor

🧪 E2E Test

Bot responded: yes

| Auto-closer (dry-run) | processed: 0 closed: 0 grace: 0 human: 0 |

Test repo → gh-simili-bot/simili-e2e-22707564014
Run → logs

Auto-generated by E2E pipeline

@gh-simili-bot gh-simili-bot merged commit 93e8d90 into main Mar 5, 2026
9 checks passed
@gh-simili-bot gh-simili-bot deleted the feature/openai-retry-parity-issue-69 branch March 5, 2026 07:48
@github-project-automation github-project-automation Bot moved this from Todo to Done in simili-bot-v1-release Mar 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working e2e enhancement New feature or request tests

Projects

No open projects

Development

Successfully merging this pull request may close these issues.

2 participants