fix(embedding): enable retry backoff for embedding API calls (#173)

MAX_RETRIES was hardcoded to 0, making the existing exponential
backoff retry logic dead code. Transient errors (network jitter,
429 rate limits, DNS failures) caused immediate embedding failure,
contributing to JSONL/SQLite drift (issue #156).

Changed MAX_RETRIES from 0 to 3, matching the retry strategy
already used by tcvdb-client.ts.

Closes #159

Signed-off-by: WSL_zhangxiaoshuai <zhangxiaoshuai@wsl.com>
Co-authored-by: WSL_zhangxiaoshuai <zhangxiaoshuai@wsl.com>
This commit is contained in:
zhangxiaoshuai
2026-06-24 17:17:03 +08:00
committed by GitHub
parent 9fac8bc998
commit 38673b5d2b
2 changed files with 6 additions and 3 deletions
+5 -2
View File
@@ -365,8 +365,11 @@ export class LocalEmbeddingService implements EmbeddingService {
/** Max texts per batch (OpenAI limit is 2048, we use a safe value) */
const MAX_BATCH_SIZE = 256;
/** Max retries for API calls */
const MAX_RETRIES = 0;
/**
* Max retries for embedding API calls (transient errors: network, 429, DNS).
* Total attempts = MAX_RETRIES + 1. Exponential backoff: 500ms × attempt.
*/
const MAX_RETRIES = 3;
/** Default timeout per API call in milliseconds */
const DEFAULT_API_TIMEOUT_MS = 10_000;