fix(api): avoid routing turns for audio capability queries #6141
All Vouch review confidence checks passed
Residual risk 0.25 = Change Risk (0.47) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.47 · 333 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 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.348
Shallow Review Depth
shallow_review_depth
0.344
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #6141"
general
weight: 0.35
Jackmeson1
With two replicas and autoscaling disabled, querying audio capabilities immediately before each realtime connection repeatedly selects the same session replica. When the first session remains open at the default one-session limit, the second connection receives
capacity_exceededwhile the other replica is idle. The capabilities preflight is already documented indoc/source/user_guide/realtime.rst.The capabilities lookup advances the same round-robin scheduler as realtime discovery, so each preflight/connection pair consumes two turns.
Add an inspection option to the existing model lookup and use it for audio capabilities. Inspection follows the current replica-selection policy without advancing the shared scheduler, preserving its draining and avoidance checks. Capabilities still come from the loaded adapter. If the first inspected replica is still loading, the probe tries the remaining eligible replicas in policy order without advancing the inference cursor. Default inference routing, P/D lookup behavior, and adapter implementations remain unchanged. General capacity-aware session retries are outside this change.
| Two-replica request pattern | Before | After |
| --- | --- | --- |
| Session-opening lookups only |
0, 1, 0, 1|0, 1, 0, 1|| Capabilities before each lookup |
1, 1, 1, 1|0, 1, 0, 1|| Two connections with preflights, first kept open | Second refused | Both start, one per replica |
Regression coverage in
xinference/api/tests/test_audio_capabilities.pychecks unchanged response/access behavior, alternation through two realtime runtimes, and preservation of replica selection when replica 0 is unavailable or draining.xinference/api/tests/test_realtime_api.pychecks that the second session starts on the other replica while the first remains open.VALIDATION: On Ubuntu 24.04.5 at
eb2f5880(base4615ec0d; the last commit was checked againste585c1e1),xinference/api/tests/test_audio_capabilities.pypasses 10/10 on Python 3.12.3 with Transformers 5.23.0, on Python 3.12.3 with the Transformers 4.57.6 CI pin, and on Python 3.10.22; with the production file reverted toe585c1e1, the new readiness cases fail. On Python 3.12, the test modules that exercise the changed module, including the real-clusterxinference/core/tests/test_restful_api.py, give 2013 passed, 7 failed and 24 skipped; no test fails there that does not also fail on the previous head in that environment. Pre-commit (isort, mypy, codespell) passes on the changed files, and mypy over all 1176 source files reports no issues.AI disclosure: this was prepared with AI assistance (Claude Opus 5.5 and Claude Sonnet 5.5).