Skip to content

fix(ai-proxy-multi): preserve request_llm_model across fallback retries [FaaFyfxR9WAQrL7FcAgEHJvztd8cVMxvjHRS55rw1nwH] - #13797

Open
waterWang wants to merge 1 commit into
apache:masterfrom
waterWang:master
Open

fix(ai-proxy-multi): preserve request_llm_model across fallback retries [FaaFyfxR9WAQrL7FcAgEHJvztd8cVMxvjHRS55rw1nwH]#13797
waterWang wants to merge 1 commit into
apache:masterfrom
waterWang:master

Conversation

@waterWang

Copy link
Copy Markdown

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.

Test: Added TEST 7-8 to ai-proxy-multi-retry.t — verifies request_llm_model=model_test (client original) after fallback, and no request_llm_model=gpt-4 (instance model).

Fixes #13769

**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]
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. bug Something isn't working labels Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: ai-proxy-multi: Variable $request_llm_model reset in fallback_strategy

1 participant