Enable circuit_breaker, pinch, and pinch.relevance by default (with budget-gate) #10

Merged
alee merged 4 commits from neuralwatt-router-service into main 2026-08-30 16:57:20 +00:00
Owner

What & why

Flip three config knobs from disabled-by-default to enabled-by-default, update the tests to expect the ON state, and update the one live doc that still said pinch "ships disabled".

  • circuit_breaker.enabled: a model that 5xxes is temporarily skipped with exponential backoff (passive recovery). Low-risk availability win; worst case if wrong is briefly avoiding a healthy model.
  • pinch.enabled: relevance-based context pruning on long sessions (trims old tool results upstream to cut the token spend that dominates this router's cost).
  • pinch.relevance.enabled: makes pinch trim the LEAST relevant tool results first instead of blindly by recency.

Safety fix caught by dual high-accuracy plan review (Oracle)

The relevance embed was NOT gated by budget_tokens — it fired synchronously on the hot path for ANY request with 2+ old tool results, even under budget. This PR adds a minimal budget-gate to _relevance_order_for (signature takes budget_tokens, early-returns None when the conversation is under budget using the same token measure prune_context uses), so the embed only runs when a prune will actually happen. User chose "gate it properly".

The backup-regex fix in the admin config test is also comment-immune (switched to yaml.safe_load parse) after review caught that a real regex would break on the comment block between circuit_breaker: and enabled:.

Scope

  • Code defaults False -> True in src/config.py for the three knobs; values false -> true in config/config.yaml; stale "off by default" text updated.
  • Tests updated tests-first to expect ON; _relevance_order_for budget-gate + both call sites; new budget-gate test; test_admin_config.py YAML-parse backup assertion; AGENTS.md on-by-default wording.
  • Not touched: escalation.preemptive_on_low_confidence, routing.min_tool_proficiency, pinch value knobs, session_cache behavior.

Verification

  • Targeted tests (test_config_endpoints, test_admin_config, test_dispatcher_helpers) green.
  • Full suite python -m pytest: 734 passed, 0 failed.
  • F3 real-QA independently reproduced: shipped config loads all three enabled=True; budget gate fires (0 embed calls) under budget and engages over budget.
  • nomic-embed-text already pulled on local Ollama — no setup cost.

Commits

  • 69662f0 feat: enable circuit_breaker, pinch, and pinch.relevance by default
  • e289f50 docs: mark pinch on-by-default in AGENTS.md
  • 6c8151f test: isolate session_cache in chat fixture; import subprocess/sys in health test
## What & why Flip three config knobs from disabled-by-default to enabled-by-default, update the tests to expect the ON state, and update the one live doc that still said pinch "ships disabled". - `circuit_breaker.enabled`: a model that 5xxes is temporarily skipped with exponential backoff (passive recovery). Low-risk availability win; worst case if wrong is briefly avoiding a healthy model. - `pinch.enabled`: relevance-based context pruning on long sessions (trims old tool results upstream to cut the token spend that dominates this router's cost). - `pinch.relevance.enabled`: makes pinch trim the LEAST relevant tool results first instead of blindly by recency. ### Safety fix caught by dual high-accuracy plan review (Oracle) The relevance embed was NOT gated by `budget_tokens` — it fired synchronously on the hot path for ANY request with 2+ old tool results, even under budget. This PR adds a minimal budget-gate to `_relevance_order_for` (signature takes `budget_tokens`, early-returns `None` when the conversation is under budget using the same token measure `prune_context` uses), so the embed only runs when a prune will actually happen. User chose "gate it properly". The backup-regex fix in the admin config test is also comment-immune (switched to `yaml.safe_load` parse) after review caught that a real regex would break on the comment block between `circuit_breaker:` and `enabled:`. ### Scope - Code defaults `False -> True` in `src/config.py` for the three knobs; values `false -> true` in `config/config.yaml`; stale "off by default" text updated. - Tests updated tests-first to expect ON; `_relevance_order_for` budget-gate + both call sites; new budget-gate test; `test_admin_config.py` YAML-parse backup assertion; `AGENTS.md` on-by-default wording. - Not touched: `escalation.preemptive_on_low_confidence`, `routing.min_tool_proficiency`, pinch value knobs, session_cache behavior. ## Verification - Targeted tests (`test_config_endpoints`, `test_admin_config`, `test_dispatcher_helpers`) green. - Full suite `python -m pytest`: **734 passed, 0 failed**. - F3 real-QA independently reproduced: shipped config loads all three `enabled=True`; budget gate fires (0 embed calls) under budget and engages over budget. - `nomic-embed-text` already pulled on local Ollama — no setup cost. ## Commits - `69662f0` feat: enable circuit_breaker, pinch, and pinch.relevance by default - `e289f50` docs: mark pinch on-by-default in AGENTS.md - `6c8151f` test: isolate session_cache in chat fixture; import subprocess/sys in health test
alee added 4 commits 2026-08-30 15:07:32 +00:00
alee merged commit ca92ccdacd into main 2026-08-30 16:57:20 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: alee/6krrt#10