fix: thread outcomes through router fallback, widen response cache key - #162
Open
shrdgn wants to merge 1 commit into
Open
fix: thread outcomes through router fallback, widen response cache key#162shrdgn wants to merge 1 commit into
shrdgn wants to merge 1 commit into
Conversation
- router.route_async dropped its `outcomes` argument on both classifier fallback paths (classifier error, unrecognized reply), silently disabling the routing learning loop for any request that hit those paths instead of falling back to the heuristic with the learned nudge intact. - responsecache.cache_key omitted self_fusion (n/temperature_spread/ seed_offset) and debate.rounds, so two configs differing only in those fields could serve each other's cached answer despite running a different number of upstream calls. Found via an automated repo-review scheduled task; verified by reading both code paths directly and adding regression tests that fail without the fix.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Two small, unrelated correctness fixes found during a scheduled repo review, bundled together since each is a one-line-cause / self-contained change:
1.
router.route_asyncsilently disabled the routing learning loop on classifier fallbackrouter._call_classifier's two fallback paths — a classifier error (text is None) and an unrecognized classifier reply — both calledroute(body, config)without theoutcomesargument, even thoughroute_asyncitself receivesoutcomesand the normal (non-model-mode) heuristic path passes it through correctly. Sinceroute_request()(the server's actual entry point) always goes throughroute_async, any timerouter.mode: model's classifier errored or replied with neitherSOLOnorFUSE, that request's routing decision silently bypassed the EMA-based learning nudge (openfusion.outcomes.OutcomeStore) instead of falling back to the heuristic with the learned nudge still active.Fix: pass
outcomesthrough on both fallback call sites (openfusion/router.py).2.
responsecache.cache_keyomitted self-fusion and debate config fieldscache_keyalready accounts for strategy, aggregator, panel/judge models, tools, and sampling params, but notconfig.self_fusion.n/temperature_spread/seed_offset, norconfig.debate.rounds. Two server configs differing only in self-fusion sample count/spread or debate round count produce identical cache keys and can serve each other's cached answer, even though they make a different number of upstream calls and synthesize differently — the same class of staleness bug as the already-open #153/#155 (which coversToolsConfigfields specifically; this covers a different, still-missing set of fields).Fix: add the four omitted fields to the
payloaddict incache_key(openfusion/responsecache.py).Both fixes include regression tests that fail on
mainand pass with the fix.How it was tested
ruff check .passespytest -qpasses (493 passed, no live network)tests/test_router.py::test_route_async_classifier_error_still_consults_outcomes,::test_route_async_unrecognized_response_still_consults_outcomes,tests/test_responsecache.py::test_cache_key_differs_on_self_fusion_and_debate_config)Fixedentries)bench/run.pynumber — not applicable, no quality/cost behavior changeNotes for reviewers
Neither fix touches request/response shape or config schema — both are pure bug fixes within existing modules (
router.py,responsecache.py). No follow-ups needed; this closes both gaps completely as scoped.Generated by Claude Code