Repository navigation
Description
Tracking issue
This issue tracks the three PRs of the plan in "Scope & Deliverables". One pull request closes each child issue. No pull request closes this issue. This issue closes when all three PRs are delivered.
- PR1, 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: 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.
- PR2, fix(cache): one circuit breaker with open, cooldown and half-open states guards the valkey cache tier and the rag lookup pause #2073: one circuit breaker with open, cooldown and half-open states guards the Valkey cache tier and the RAG lookup pause.
- PR3, feat(ai): devops ai gateway status reports failover while a route is failover:*, and failover --reset restores the default routes #1986:
devops ai gateway statusreports failover while a route isfailover:*, andfailover --resetrestores the default routes.
PR1 and PR2 got their child issues on 2026-10-24, after #1985 stopped intake from judging a part a duplicate of its source. This issue closes when all of its child issues close.
Context & Rationale
#430 added AIMD recovery to the embedding batch size, marked delivered in the "Capability-Gated Model Failover & AIMD Batch Recovery" item, but three one-way transitions remain. First, _embed_ollama fixes chunk_batch_size once per call (src/devops_cli/ai/rag/embeddings.py:697), and every slow batch in that call halves again (:640, :653) although none was sent at the reduced size. The increase fires on any batch at or under 2.0 s, with none of the cooldown or 0.5x margin vibes proposes (embeddings.py:331-336). Second, one Valkey error nulls the L2 client for the rest of the run (embeddings.py:359,374; security/vulnerability_lookup.py:451,467), pinned by tests/test_security_threat_intel.py:228, while cache/tiered.py:202-222 retries and reconnects on every call during an outage (valkey/pool.py:118-144). Third, trigger_failover persists a failover:* route (ai/gateway.py:487-526) with no failback, and a healthy probe clears the breaker flag but keeps the route (gateway.py:418). #430 also left a backwards-compatible _halve_batch_size alias (embeddings.py:327).
Scope & Deliverables
- Context & Rationale*: feat(ai): capability-gated model failover & aimd batch recovery #430 added AIMD recovery to the embedding batch size, marked delivered in the "Capability-Gated Model Failover & AIMD Batch Recovery" item, but three one-way transitions remain. First,
_embed_ollamafixeschunk_batch_sizeonce per call (src/devops_cli/ai/rag/embeddings.py:697), and every slow batch in that call halves again (:640,:653) although none was sent at the reduced size. The increase fires on any batch at or under 2.0 s, with none of the cooldown or 0.5x margin vibes proposes (embeddings.py:331-336). Second, one Valkey error nulls the L2 client for the rest of the run (embeddings.py:359,374;security/vulnerability_lookup.py:451,467), pinned bytests/test_security_threat_intel.py:228, whilecache/tiered.py:202-222retries and reconnects on every call during an outage (valkey/pool.py:118-144). Third,trigger_failoverpersists afailover:*route (ai/gateway.py:487-526) with no failback, and a healthy probe clears the breaker flag but keeps the route (gateway.py:418). feat(ai): capability-gated model failover & aimd batch recovery #430 also left a backwards-compatible_halve_batch_sizealias (embeddings.py:327). - Deliverable*: Three small PRs. Each PR closes its own child issue, which the section "Tracking issue" lists. PR1: pass the sent size into
_record_batch_latencyand the timeout path, skip a decrease when the sent size exceeds the current one, add a cooldown and a margin below the threshold before any increase, delete the alias, and migratetests/test_rag_embeddings.py:399-407. Test it through_embed_ollamawith a stubbed endpoint and two workers. PR2: adopt pybreaker behind one seam at the Valkey L2 boundary, route the engine, the threat-intel client andTieredCachethrough it, delete everyself._valkey = None, and rewrite the pinning test to cover open, cooldown, half-open and closed. PR3: the route file feeds onlydevops ai gateway status/routes, while live fallback belongs to LiteLLM'sfallbacks(k8s/llm/gateway/configmap.yaml:118-137). Makestatusreport failover while any route isfailover:*, and addfailover --resetto restore default routes. List each knob, its trip, reset and test in the task file. - Constraint*: A naive recovery is worse than the ratchet. Increasing on every healthy batch without a margin can climb straight back to the size that breached, and uncoalesced decreases then undo it in one call. Retrying Valkey on every call makes each call pay a connection attempt during an outage, which the disable avoids, so the breaker needs a real open state. Failback stays explicit: flipping routes on one healthy probe would call the local routes healthy regardless of LiteLLM, which owns traffic. A deliberate trip is recorded as one, not forced to recover.
- Measured*:
PYTHONPATH=src uv run --no-sync python probe/round_probe.py: one_embed_ollamacall with default parallelism and every batch slow drives the size from 32 to 1.PYTHONPATH=src uv run --no-sync python probe/recovery_probe.py: 32 healthy batches climb from 1 back to 32.PYTHONPATH=src uv run --no-sync python probe/l2_probe.py: after one transient Valkey read error, 0 of the next 100 reads reach L2. - Source*: vibes
observations/devops-cli/20-model-failover-capability-cliffs-and-one-way-degradation-ratchets.md
Update 2026-10-08: refinement
PR 1 holds (ai/rag/embeddings.py:847-856, :460-495). #1065 added a second hand-rolled breaker, the RAG lookup pause (ai/rag/investigator.py:116-147); the Valkey sites are embeddings.py:518, :533 and security/vulnerability_lookup.py:401-438.
- One circuit-breaker implementation in
src, used by the Valkey boundary and the lookup pause, tested open, cooldown, half-open and closed.
Proposed design
Problem statement
The issue addresses three one-way transitions that remain from AIMD recovery implementation in #430. First, _embed_ollama does not coalesce decreases and increases without proper cooldown or margin. Second, Valkey errors permanently disable the L2 client instead of using a circuit breaker pattern. Third, failover routes persist without a corresponding failback mechanism.
Acceptance criteria
- Criterion 1: The
_record_batch_latencyfunction properly handles sent size and skips decreases when sent size exceeds current size
Verification: RunPYTHONPATH=src uv run --no-sync python probe/round_probe.pyto verify that one_embed_ollamacall with default parallelism and every batch slow drives the size from 32 to 1, and then runPYTHONPATH=src uv run --no-sync python probe/recovery_probe.pyto verify that 32 healthy batches climb from 1 back to 32. - Criterion 2: A circuit breaker is adopted for Valkey L2 boundary and the engine, threat-intel client and TieredCache route through it
Verification: RunPYTHONPATH=src uv run --no-sync python probe/l2_probe.pyafter implementing the circuit breaker to verify that after one transient Valkey read error, 0 of the next 100 reads reach L2. - Criterion 3: Failover routes report properly in
devops ai gateway statusand can be reset withfailover --reset
Verification: Rundevops ai gateway statusto confirm failover is reported while any route isfailover:*, and executedevops ai gateway failover --resetto verify default routes are restored.
Key questions
- What is the current implementation of
_embed_ollamathat causes uncoalesced decreases?: _embed_ollama fixeschunk_batch_sizeonce per call and every slow batch in that call halves again although none was sent at the reduced size. The increase fires on any batch at or under 2.0 s, with none of the cooldown or 0.5x margin vibes proposes. [sources: src/devops_cli/ai/rag/embeddings.py:697, src/devops_cli/ai/rag/embeddings.py:640, src/devops_cli/ai/rag/embeddings.py:653, src/devops_cli/ai/rag/embeddings.py:331, src/devops_cli/ai/rag/embeddings.py:336] - What is the problem with the current Valkey error handling?: One Valkey error nulls the L2 client for the rest of the run, while
cache/tiered.pyretries and reconnects on every call during an outage. [sources: src/devops_cli/ai/rag/embeddings.py:359, src/devops_cli/ai/rag/embeddings.py:374] - What is the issue with the failover mechanism?:
trigger_failoverpersists afailover:*route with no failback, and a healthy probe clears the breaker flag but keeps the route. [sources: src/devops_cli/ai/gateway.py:487, src/devops_cli/ai/gateway.py:526, src/devops_cli/ai/gateway.py:418] - Should the circuit breaker implementation be reused in a future item?: Yes, the v0.3.4 "Proportional API Rate Budgeting & GraphQL Circuit Breaker Guard" should reuse the implemented circuit breaker. (proposed) [sources: docs/agent/tasks/task-596-recovery-transitions-for-adaptive-knobs-coalesced-decrease-v.md]
Fit
Needs splitting into 3 items:
- PR1: Pass sent size into
_record_batch_latencyand timeout path, skip decrease when sent size exceeds current one, add cooldown and margin before increase, delete alias, and migrate tests - PR2: Adopt pybreaker behind seam at Valkey L2 boundary, route engine, threat-intel client and TieredCache through it, delete
self._valkey = Nonestatements, rewrite pinning test - PR3: Make
statusreport failover while any route isfailover:*, addfailover --resetto restore default routes
Suspected block
None.
Dependencies
None.
Sub-issues
Collapse Sub-issuesSub-issues
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
dan-petty commentedon Oct 1, 2026
Moved from the shipped v0.2.23 to the backlog. It is still valid (checked 2026-10-01), and P2 items don't displace P1 work in the planned releases.
dan-petty commentedon Oct 3, 2026
Lines cited at dcafadf.
#1113 replaces the hand-written Valkey client with Valkey GLIDE (
valkey-glide-sync). Two of its changes meet this item's second PR, the Valkey breaker:devops_cli.cachepackage,TieredCacheincluded, andvalkey/pool.py. Nothing insrcbuilds aTieredCacheoutside tests, so leavecache/tiered.py(:202-222) out of the breaker.self._valkey = None(ai/rag/embeddings.py:412,:427;security/vulnerability_lookup.py:401,:422,:438).This item's breaker replaces that one-way switch with open, cooldown and half-open states. Whichever of the two lands second puts the breaker at the shared store's boundary rather than in each cache. An open breaker closes the store, because GLIDE otherwise keeps reconnecting.
dan-petty commentedon Oct 17, 2026
Proposal needs splitting into 3 items at 3dd7fa6 (see proposed design in issue body).
fix(roadmap): intake judges a split part a duplicate of the issue tha…
dan-petty commentedon Oct 24, 2026
Issue #596 is a tracking issue. The issue body states that no pull request closes this issue. The plan requires three child pull requests. PR3 is child issue #1986. Intake must file child issues for PR1 and PR2. Work can start on each child issue after intake files it.
fix(rag): a slow embedding batch halves the batch size once for the s…
fix(cache): one circuit breaker with open, cooldown and half-open sta…
dan-petty commentedon Oct 24, 2026
All three child issues of this tracker are closed by merged pull requests on 2026-10-24:
devops ai gateway statusreports failover while a route isfailover:*, andfailover --resetrestores the default routes.This issue closes when all of its child issues close, so it closes now.