fix(ai-proxy-multi): preserve request_llm_model across fallback retries [FaaFyfxR9WAQrL7FcAgEHJvztd8cVMxvjHRS55rw1nwH] - #13797
Open
waterWang wants to merge 1 commit into
Open
fix(ai-proxy-multi): preserve request_llm_model across fallback retries [FaaFyfxR9WAQrL7FcAgEHJvztd8cVMxvjHRS55rw1nwH]#13797waterWang wants to merge 1 commit into
waterWang wants to merge 1 commit into
Conversation
**Problem:** When ai-proxy-multi fallback_strategy retries a failed instance, the `request_llm_model` nginx var is overwritten with the retry instance's model instead of keeping the client's original model. **Root cause:** `get_json_request_body_table()` returns a cached request-body table. `build_body` mutates this cached table's `.model` field to the picked instance's model. On the fallback retry, the same cached (now mutated) table is returned, so `request_llm_model = request_body.model` reads the wrong value. **Fix:** Capture the client's original model only on the first attempt via `ctx.ai_request_llm_captured` and preserve it across retries. Fixes apache#13769 [FaaFyfxR9WAQrL7FcAgEHJvztd8cVMxvjHRS55rw1nwH]
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.
Problem: When ai-proxy-multi fallback_strategy retries a failed instance, the
request_llm_modelnginx var is overwritten with the retry instance's model instead of keeping the client's original model.Root cause:
get_json_request_body_table()returns a cached request-body table.build_bodymutates this cached table's.modelfield to the picked instance's model. On the fallback retry, the same cached (now mutated) table is returned, sorequest_llm_model = request_body.modelreads the wrong value.Fix: Capture the client's original model only on the first attempt via
ctx.ai_request_llm_capturedand preserve it across retries.Test: Added TEST 7-8 to
ai-proxy-multi-retry.t— verifiesrequest_llm_model=model_test(client original) after fallback, and norequest_llm_model=gpt-4(instance model).Fixes #13769