[PR #272] [MERGED] fix: add retry logic for OpenAI embedding API failures #305

Closed
opened 2026-02-15 17:16:46 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/openclaw/clawhub/pull/272
Author: @superlowburn
Created: 2/13/2026
Status: Merged
Merged: 2/13/2026
Merged by: @steipete

Base: mainHead: fix/convex-skill-import


📝 Commits (6)

  • 87cb005 fix: add retry logic for OpenAI embedding API failures
  • c89360f fix: correct retry count and broaden network error catch
  • 4348d2a fix: address retry loop off-by-one, broaden error catch, preserve original error
  • a506797 fix: harden embeddings retry semantics
  • b610b7c style: format embeddings retry changes
  • 554c4f4 merge: resolve main conflicts for embeddings retry

📊 Changes

2 files changed (+222 additions, -33 deletions)

View changed files

convex/lib/embeddings.test.ts (+95 -0)
📝 convex/lib/embeddings.ts (+127 -33)

📄 Description

Fixes #149

Problem

Users encountered "Server Error" when importing or uploading skills. The root cause was transient failures in the OpenAI embedding API call (rate limits, timeouts, network issues) causing the entire import to fail with an unhelpful error message.

Solution

Added retry logic with exponential backoff to generateEmbedding():

  • Retries on: 429 (rate limit), 5xx server errors, network/fetch errors
  • Backoff: 1s, 2s, 4s delays (max 3 retries)
  • Logging: Clear warnings for debugging
  • Failure mode: After retries exhausted, fails with clear error message

Testing

  • All existing tests pass (400 tests)
  • No test assertions changed
  • Verified the fix handles transient API failures gracefully

Notes

This is a defensive fix for a transient issue. The comment from @swairshah on Feb 6 ("This seems fixed now") suggests the underlying API issue may have resolved, but this adds resilience to prevent future occurrences.

Greptile Overview

Greptile Summary

This PR adds retry logic with exponential backoff to convex/lib/embeddings.ts’s generateEmbedding() to make skill import/upload more resilient to transient OpenAI embeddings API failures.

The change wraps the embeddings fetch() in a retry loop, retrying on 429/5xx responses and certain thrown errors, logging warnings and ultimately surfacing a clearer Embedding failed: ... error that upstream publish flows already map into user-friendly messages.

Confidence Score: 3/5

  • This PR is close to mergeable but has a couple of retry-logic correctness issues that should be fixed first.
  • Core idea (retry on 429/5xx) is sound and integrates cleanly with existing publish error formatting, but the loop currently performs more attempts than intended with misleading attempt logging, and the network-error retry predicate is too narrow and can skip retries for common transient failures.
  • convex/lib/embeddings.ts

Last reviewed commit: 87cb005

Context used:

  • Context from dashboard - AGENTS.md (source)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/openclaw/clawhub/pull/272 **Author:** [@superlowburn](https://github.com/superlowburn) **Created:** 2/13/2026 **Status:** ✅ Merged **Merged:** 2/13/2026 **Merged by:** [@steipete](https://github.com/steipete) **Base:** `main` ← **Head:** `fix/convex-skill-import` --- ### 📝 Commits (6) - [`87cb005`](https://github.com/openclaw/clawhub/commit/87cb0050d1719f4876f016793f23b373f1cccdd6) fix: add retry logic for OpenAI embedding API failures - [`c89360f`](https://github.com/openclaw/clawhub/commit/c89360fd44b4336c34ea2731327c0aaa70a86295) fix: correct retry count and broaden network error catch - [`4348d2a`](https://github.com/openclaw/clawhub/commit/4348d2a663434ccc9a4ef9d7a0f026ff10995e22) fix: address retry loop off-by-one, broaden error catch, preserve original error - [`a506797`](https://github.com/openclaw/clawhub/commit/a50679765e266d89dc644e72afe480d4fdf967ae) fix: harden embeddings retry semantics - [`b610b7c`](https://github.com/openclaw/clawhub/commit/b610b7c3aafa6cba74cdfed254e132be300a0155) style: format embeddings retry changes - [`554c4f4`](https://github.com/openclaw/clawhub/commit/554c4f480b57c239a2e22ce653071bae487b888b) merge: resolve main conflicts for embeddings retry ### 📊 Changes **2 files changed** (+222 additions, -33 deletions) <details> <summary>View changed files</summary> ➕ `convex/lib/embeddings.test.ts` (+95 -0) 📝 `convex/lib/embeddings.ts` (+127 -33) </details> ### 📄 Description Fixes #149 ## Problem Users encountered "Server Error" when importing or uploading skills. The root cause was transient failures in the OpenAI embedding API call (rate limits, timeouts, network issues) causing the entire import to fail with an unhelpful error message. ## Solution Added retry logic with exponential backoff to `generateEmbedding()`: - **Retries on:** 429 (rate limit), 5xx server errors, network/fetch errors - **Backoff:** 1s, 2s, 4s delays (max 3 retries) - **Logging:** Clear warnings for debugging - **Failure mode:** After retries exhausted, fails with clear error message ## Testing - ✅ All existing tests pass (400 tests) - ✅ No test assertions changed - ✅ Verified the fix handles transient API failures gracefully ## Notes This is a defensive fix for a transient issue. The comment from @swairshah on Feb 6 ("This seems fixed now") suggests the underlying API issue may have resolved, but this adds resilience to prevent future occurrences. <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR adds retry logic with exponential backoff to `convex/lib/embeddings.ts`’s `generateEmbedding()` to make skill import/upload more resilient to transient OpenAI embeddings API failures. The change wraps the embeddings `fetch()` in a retry loop, retrying on 429/5xx responses and certain thrown errors, logging warnings and ultimately surfacing a clearer `Embedding failed: ...` error that upstream publish flows already map into user-friendly messages. <h3>Confidence Score: 3/5</h3> - This PR is close to mergeable but has a couple of retry-logic correctness issues that should be fixed first. - Core idea (retry on 429/5xx) is sound and integrates cleanly with existing publish error formatting, but the loop currently performs more attempts than intended with misleading attempt logging, and the network-error retry predicate is too narrow and can skip retries for common transient failures. - convex/lib/embeddings.ts <sub>Last reviewed commit: 87cb005</sub> <!-- greptile_other_comments_section --> **Context used:** - Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=a1d58d20-b4dd-4cbb-973a-9fd7824e1921)) <!-- /greptile_comment --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-15 17:16:46 -05:00
yindo closed this issue 2026-02-15 17:16:46 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: openclaw/clawhub#305