agentscope-ai/agentscope · error · RuntimeError
Failed to call embedding model {self.model} after {self.max_
Error message
Failed to call embedding model {self.model} after {self.max_retries + 1} retries. What it means
Raised by EmbeddingModelBase._call_with_retry when the embedded provider call raised no exception on the final pass but also produced no usable outcome path (defensive terminal error after max_retries+1 attempts), reporting the model name and retry count.
Source
Thrown at src/agentscope/embedding/_embedding_base.py:354
"Batch attempt %d failed for embedding model "
"%s: %s. Retrying in %.1fs...",
attempt + 1,
self.model,
str(e),
self.retry_delay,
)
await asyncio.sleep(self.retry_delay)
else:
logger.warning(
"All %d attempt(s) failed for a batch of "
"embedding model %s.",
self.max_retries + 1,
self.model,
)
if last_error is not None:
raise last_error
raise RuntimeError(
f"Failed to call embedding model {self.model} after "
f"{self.max_retries + 1} retries.",
)
# ------------------------------------------------------------------
# Abstract — subclasses implement this for a single batch
# ------------------------------------------------------------------
@abstractmethod
async def _call_api(
self,
inputs: list[Any],
**kwargs: Any,
) -> EmbeddingResponse:
"""Call the underlying embedding API for a **single batch**.
Subclasses must implement this method. The batch splitting,
concurrency, and retry logic are handled by :meth:`__call__`View on GitHub (pinned to e90f1c7592)
Solutions
- Inspect the underlying provider error (last_error / logs) and fix credentials, quota, or batch size
- Increase max_retries and use exponential backoff for flaky networks
- Cache embeddings and enqueue failures for later replay instead of retrying inline forever
Example fix
# before
vecs = await model(texts)
# after
try:
vecs = await model(texts)
except RuntimeError:
vecs = await replay_later(texts) # queue and degrade gracefully Defensive patterns
Strategy: retry
Try / catch
for attempt in range(N):\n try:\n vecs = await model(texts); break\n except RuntimeError as e:\n if \"after\" in str(e) and \"retries\" in str(e) and attempt < N - 1:\n await asyncio.sleep(2 ** attempt); continue\n raise
Prevention
- Persist failed batches to a dead-letter queue
- Tune max_retries and backoff per workload
- Monitor provider health before large embedding jobs
When it happens
Trigger: Exhausting all retry attempts for __call__ on an embedding model — each attempt failing (network/API errors) — after which the wrapper gives up; also reachable if retries complete without success and without a captured last_error.
Common situations: Sustained provider outages or rate limiting; invalid credentials causing every retry to fail; very large batches that consistently time out.
Related errors
- DashScope text embedding API error: {response}
- DashScope multimodal embedding API error: {res}
- Failed to fetch bytes from URL `{url}` after {max_retries} r
- Model call failed after retries, but no exception was raised
- Text embedding model {self.model!r} only accepts str inputs,
AI-assisted analysis of agentscope-ai/agentscope@e90f1c7592 (2026-08-28).
Data as JSON: /api/errors/b12893ccd3c1c333.
Report an issue: GitHub.