-
Notifications
You must be signed in to change notification settings - Fork 15.5k
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Summary
Gateway crashes with unhandled promise rejection when OpenAI embeddings API returns 429 (quota exceeded). The configured openai-codex OAuth accounts are not used as fallback.
Error
[clawdbot] Unhandled promise rejection: Error: openai embeddings failed: 429 {
"error": {
"message": "You exceeded your current quota, please check your plan and billing details.",
"type": "insufficient_quota",
"code": "insufficient_quota"
}
}
at Object.embed [as embedBatch] (file:///Users/oliver/Developer/clawdbot/src/memory/embeddings.ts:1:1562)
at MemoryIndexManager.indexFile (file:///Users/oliver/Developer/clawdbot/src/memory/manager.ts:25:3078)
at MemoryIndexManager.runSync (file:///Users/oliver/Developer/clawdbot/src/memory/manager.ts:25:2016)
error: script "clawdbot" exited with code 1
Environment
- Clawdbot version: 2026.1.15
- macOS (arm64)
- Auth profiles:
openai-codex:oliver,openai-codex:sylvia(both working for chat) OPENAI_API_KEYenv var set but account has no quota
Config
"memorySearch": {
"provider": "openai",
"fallback": "openai",
"model": "text-embedding-3-small",
"sync": { "watch": true }
}Root Cause
- Schema restriction:
memorySearch.provideronly accepts"openai" | "local"— not"openai-codex" - No real fallback: Both provider and fallback are
"openai", so failure just fails again - Credential resolution:
resolveApiKeyForProvider({ provider: "openai" })findsOPENAI_API_KEYenv var (which has no quota) instead of usingopenai-codexOAuth tokens - Crash on 429: Unhandled rejection crashes the gateway instead of graceful degradation
Attempted Fix
Setting "provider": "openai-codex" results in:
Invalid config: - agents.defaults.memorySearch.provider: Invalid input
Suggestion: Support Any OpenAI-Compatible Provider
Instead of hardcoding "openai" | "local", allow any provider that resolves to an OpenAI-compatible API:
// Current (restrictive):
provider: "openai" | "local";
// Suggested (flexible):
provider: "openai" | "openai-codex" | "local" | string;Or better, reuse the existing provider resolution logic:
// In createOpenAiEmbeddingProvider():
const { apiKey } = await resolveApiKeyForProvider({
provider: options.provider, // Pass through as-is
cfg: options.config,
agentDir: options.agentDir,
});This would allow:
"openai"→ uses OPENAI_API_KEY or openai auth profiles"openai-codex"→ uses ChatGPT OAuth tokens (if embeddings are included in scope)"openrouter"→ uses OpenRouter (supports embeddings)- Any custom OpenAI-compatible provider
Additional Issues
- Crash vs graceful degradation: 429 should disable memory search, not crash the gateway
- Fallback is broken:
"fallback": "openai"when provider is already"openai"is a no-op - No warning on startup: If embeddings will fail, warn during config validation
Workaround
Use local embeddings:
"memorySearch": {
"provider": "local",
"fallback": "none"
}Labels
bug, crash, memory, embeddings
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working