Repository navigation
fix(api): prepare the auto-combo candidate pool once in GET /api/combos/auto - #14925
Merged
diegosouzapw merged 1 commit intoSep 29, 2026
Conversation
…os/auto The route listed every auto variant by calling createVirtualAutoCombo() for each one, and createVirtualAutoCombo() runs prepareVirtualAutoComboInputs() every time. One request therefore rebuilt the whole candidate pool once per listed variant (47 times on this branch). Prepare the pool once at the top of the handler and build every variant with createVirtualAutoComboFromPrepared(), the same prepare-once pattern the model catalog already uses. The prepared inputs do not depend on the variant or spec, and createVirtualAutoComboFromPrepared() works on a copy of the candidates, so the listed combos are unchanged. Closes diegosouzapw#14889
diegosouzapw
merged commit Sep 29, 2026
e59590d
into
diegosouzapw:release/v3.8.51
11 of 16 checks passed
4 of 5 tasks
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.
Summary
GET /api/combos/autobuilt every listed auto variant withcreateVirtualAutoCombo(), which runsprepareVirtualAutoComboInputs()on every call, so one request prepared the candidate pool once per variant (47 times on this branch).createVirtualAutoComboFromPrepared(), the same prepare-once patterncatalog.tsalready uses. The prepared inputs do not depend on the variant or spec, andcreateVirtualAutoComboFromPrepared()works on a copy of the candidates, so the response is unchanged.catch {}blocks and the other items listed in the issue are left for separate changes.Related Issues
Validation
tests/unit/*.test.tswithautoorcomboin its name (316 files): 2,079 pass, 7 skipped, 1 local-only failure.combos-quota-protected.test.tsopens a source file through a URL path and gets ENOENT because my checkout path contains a space (%20); it does not touch this route.npm run lint: exits 2 with "suppressions left that do not occur anymore", the same as on the base branch without this change.npx eslinton the two changed files is clean, andnpm run typecheck:coreis clean.release/v3.8.51ata58000c7)Tests Added Or Updated
tests/unit/14889-combos-auto-prepare-once.test.ts(new): seeds six API-key providers, counts the preparation yields (setImmediate, one every four candidates) for oneprepareVirtualAutoComboInputs()call and for oneGET /api/combos/auto, and asserts they are equal. Before this change it fails with 658 against 14 (47 preparations).Coverage Notes
src/app/api/combos/auto/route.tsis covered by the new test and by the existingauto-combos-free-models-routes.test.ts(6 pass) andauto-combo-context-advertising.test.ts(16 pass).Reviewer Notes
auto/chaos'sjudgeModelwhen the top candidates tie on weight, already differ from one process to the next on the base branch. In three separate processes the two handlers agreed each time (onkimi-k3,kimi-k3andzai-glm-4.7), so this change does not alter either.catch {}, and the request ended with{ combos: [] }after 47 identical failures. Now the single preparation fails once, reaches the outer catch, is logged withconsole.error, and the response is still{ combos: [] }.