Repository navigation
Closed
Labels
bugSomething isn't working
Description
Problem
cortex embed ollama/all-minilm (and ollama/nomic-embed-text) hangs indefinitely when processing certain memories. The embed worker starts, reports worker_running=true, but never writes vectors. embed --status shows embeddings=0 remaining=N forever.
Ollama responds fine to direct API calls — the issue is in the Cortex embed loop, not Ollama.
Reproduction
# Fresh DB with 500+ memories
cortex embed ollama/all-minilm --batch-size 50
# Hangs at 0 embeddings written
# Meanwhile, direct Ollama call works:
curl -s -X POST http://localhost:11434/api/embeddings \
-d "{\"model\":\"all-minilm\",\"prompt\":\"test\"}" | jq .embedding | head -1
# Returns 384 dims instantlyRoot Cause
The embed goroutine sends memory content to Ollama without a per-request timeout. When Ollama takes >30s on a long/malformed memory, the goroutine blocks. Since workers share a connection pool or semaphore, one stuck request blocks the entire batch and all subsequent batches.
Memories that trigger this:
- Long metadata-heavy content (JSON blocks, conversation headers)
- Content >2000 chars with special characters
- Unicode-heavy content
Impact
- Production blocker: fresh installs cannot complete embedding
- Autoresearch runner blocked: cannot benchmark the shipping embedder path
- Workaround exists: Python bypass script with per-memory 8s timeout (scripts/embed-fast.py)
Fix
- Add per-memory HTTP timeout to the Ollama embed client (8-10s)
- On timeout: log warning, skip the memory (or insert zero-vector), continue to next
- Add
--timeoutflag tocortex embed(default 10s) - Add retry logic: retry once with truncated content (first 1000 chars) before skipping
- Report skip count in
embed --status
Acceptance
cortex embed ollama/all-minilmcompletes on a 500-memory DB in <5 minutes- No hangs on any memory content
embed --statusshows skip count- Skipped memories are logged with IDs for manual review
Refs
- Observed across multiple sessions (2026-03-22, 2026-03-23, 2026-03-24)
- Blocks autoresearch runner (cortex-ide artifacts/research/)
- Blocks issue feat: Local ONNX embedder — ship all-MiniLM or nomic without Ollama #360 (ONNX embedder) and feat: auto-detect embedder — ship all-minilm default, respect existing #361 (auto-detect embedder)
Metadata
Metadata
Assignees
Labels
bugSomething isn't working
Activity