fix(api): describe the selected replica before inference #6114
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #6114"
general
weight: 0.35
Jackmeson1
An ordinary inference request can select healthy replica 1 while replica 0 is recovering, then fail before inference: healthy selected replica blocked by metadata lookup against recovering replica.
At
13bb1570, unkeyed selection uses the scheduler, butdescribe_modeldefaults to the first active replica. Completions and image edits omit the selected UID; chat supplies it only for keyed requests.Pass the selected actor UID to the metadata lookup in all three handlers. The existing keyed scaling fallback, replica selection policy, and request/response schemas are preserved.
| Request, with healthy replica 1 selected | Before | After |
| --- | --- | --- |
| Unkeyed chat or completion | Metadata lookup fails against recovering replica 0 | Describe replica 1 and serve the request |
| Keyed chat control | Describe replica 1 and serve the request | Same behavior |
| Image edit | Metadata lookup fails against recovering replica 0 | Describe replica 1 and retain the existing image conversion behavior |
Deterministic regressions exercise the real supervisor selection and description methods with two stub workers. LLM cases cover streaming and non-streaming chat/completions plus keyed chat controls. Image cases retain RGB/RGBA conversion and option assertions. Supporting fixtures now expose byte actor UIDs matching production refs, including ordinary replicas and the P/D router, and accept the selected-replica keyword.
The shared REST paths cover supported chat/completion operations for Transformers, vLLM, SGLang, llama.cpp, MLX, and TRT-LLM, and supported image-edit operations for diffusers, transformers, vLLM, and SGLang. The metadata lookup precedes the streaming branches and both image-to-image and inpainting dispatch. Local and supervisor/worker deployments use the same supervisor methods; sharded models retain their first-worker lookup.
P/D keeps its existing worker-metadata lookup because the supervisor ignores the selected router UID for P/D models. Token Router proxy paths are unchanged. Audio, embeddings, rerank, Responses, and Anthropic messages do not perform this post-selection supervisor metadata lookup. Realtime performs its lookup before replica selection for model-type authorization and is outside this change. General unkeyed failover and P/D metadata availability remain outside the scope of this fix.
VALIDATION:
The current branch head is
6fa1fd15. The Linux runs used an identical Git tree. The follow-up changes only the two remaining test modules; production code and assertions are unchanged.xinference/core/tests/test_restful_api.pyandxinference/api/tests/test_non_streaming_request_abort.pysuites on base13bb1570and the tree matching6fa1fd15. Both produced 182 passed, 7 failed, 6 skipped, with identical failure sets. All seven failures are in core REST:test_events,test_lang_chain,test_launch_model_async,test_launch_model_by_version,test_openai,test_restful_api, andtest_restful_api_with_request_limits. Their model launches fail becausexllamacppcannot be imported in that environment, causing downstream response or polling failures. They fail on base as well. Upstream CI installsxllamacpp; the local Linux results are not a claim that upstream CI is already green.types.pyandengine_family.pyfiles.13bb1570produced four failing unkeyed LLM cases, five failing image cases, and two passing keyed controls on Python 3.10.20 and 3.14.6. All eleven passed with the fix. The original Linux fail-before run also failed as expected.The seven changed test modules are
test_llm_request_abort.py,test_qwen_image21_edits.py,test_cache_salt.py,test_model_recommendation.py,test_token_router_dispatch.py, andtest_non_streaming_request_abort.pyunderxinference/api/tests/, plusxinference/core/tests/test_restful_api.py.Windows focused runs used
python -m pytest -p no:cacheprovider -o addopts="" --timeout=300 -vv, one file at a time with a temporaryXINFERENCE_HOME. The base regression selectors were-k test_llm_describes_selected_replicaand-k test_image_edits_alpha_depends_on_model_name.Validation uses stub workers and model actors. Real-engine inference, GPU/model-weight runs, and the full repository suite were not run.
AI disclosure: this was prepared with AI assistance (Claude Opus 5.5 and Claude Sonnet 5.5).
🤖 Generated with Claude Code
https://claude.ai/code/session_01JfvcPZyKcKQUG9fQGYfRMw