Embedding 402 is retried via batch shrink; doctor still reports ready
Description
When the embedding API returns HTTP 402 (or other non-retryable billing/quota errors), Memorix:
- Treats it as “temporarily unavailable”
- Shrinks the batch (
12 → 6 → 3 → 2 → 1) and retries each size - Eventually falls back to fulltext (search survives)
memorix doctorstill reports Embedding Status: ready / hybrid search
This burns many sequential HTTP calls per store/search and can add tens of seconds (or worse if the upstream is slow). Combined with memorix_store + active formation it contributes to host-visible stalls.
Steps to Reproduce
- Point
[embedding]at an OpenAI-compatible URL that returns 402 for/v1/embeddings(e.g. unpaid Mistral subscription behind a proxy). - Call
memorix_searchormemorix_store. - Watch
background.log.
Expected Behavior
- 402 / 401 / invalid_api_key should fail once, mark the provider unavailable, and fall back to fulltext immediately.
- Do not shrink-and-retry a batch that the provider rejected for billing.
memorix doctorshould show degraded / 402, notready.
Actual Behavior
[memorix] API embedding 12/12 texts (cache hit: 0.0%)
[memorix] Embedding batch too large for provider, retrying in chunks of 6
[memorix] Embedding batch too large for provider, retrying in chunks of 3
[memorix] Embedding batch too large for provider, retrying in chunks of 2
[memorix] Embedding batch too large for provider, retrying in chunks of 1
[memorix] Embedding provider temporarily unavailable at runtime: Embedding API error (402): {"error":{"message":"Check your subscription ..."}}
[memorix] Embedding failed or timed out, falling back to fulltext search
Doctor:
[OK] Mode: api
[OK] Provider: api-mistral-mistral-embed (1024d)
[OK] Status: ready
Search: hybrid (BM25 + vector)
Environment
- Memorix 1.4.3
- Embedding:
provider = "api", modelmistral/mistral-embedvia OpenAI-compatible proxy - Search still works (fulltext)
Additional Context
isRetryableEmbeddingError in 1.4.3 matches embedding api error (402|429|5xx). 402 is not retryable. Batch-size fallback is the wrong diagnosis for a 402.
Same investigation as #196 / #200. 402 retries can keep store/search busy after formation timeout.
1.6.1 已发。运行中的 HTTP 控制面会暴露真实 embedding 状态;授权、账单、超时和上游故障都会显示为 degraded,doctor 不会再用一次新的本地探测把已退化的服务说成 ready。