You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(rag): a slow embedding batch halves the batch size once for the size it was sent at, and the size grows back only after a cooldown and below a margin #2072
The embedding batch size of the direct Ollama path has one-way and wrong transitions. _embed_ollama (src/devops_cli/ai/rag/embeddings.py) fixes chunk_batch_size once per call, and every slow batch in that call halves the size again, although none was sent at the reduced size. The increase fires on any batch at or under 2.0 s, with no cooldown and no margin below the threshold. #430 also left a backward-compatible alias, _halve_batch_size, which the project's no-shim rule forbids.
Evidence
Checked on main on 2026-10-24: _halve_batch_size (embeddings.py:531), _record_batch_latency (:535) and the per-call chunk_batch_size in _embed_ollama (:951-960) are all present. This is PR1 of tracking issue #596.
Proposed remedy
Pass the size that each batch was sent at into _record_batch_latency and the timeout path, and skip a decrease when the sent size is larger than the current one.
Add a cooldown and a margin below the threshold before any increase.
Delete _halve_batch_size and migrate its tests.
Test it through _embed_ollama with the shared HTTP fake and two workers.
Activity
dan-petty commentedon Oct 24, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones on the board.
The candidate fixes a bug in the embedding batch size handling logic.This fix improves performance and reliability of embeddings but is not critical.Improves efficiency of embedding processing for users of the AI features.Requires changes to batch size tracking and timing logic with tests.Both items involve embedding batches in Ollama path but address different problems: one fixes batch size logic and the other fixes client closure.