← Back to Pull requests

fix(api): use the selected replica's tool capability for chat completions #6228

Closed
unknown closed this pull request without merging on Nov 30, 2026 03:18 UTC
View on GitHub
unknown unknown commented on Nov 29, 2026 14:59 UTC
Author

Fixes #6227

What happens

After a catalog refresh, a newly launched model can accept plain chat but return HTTP 400 for a tool declaration or a tool-result continuation. A refresh between matching and subprocess startup can also leave a replica advertising tool support while its prompt omits the schema. A Qwen alias admitted with its parser unset can return raw <tool_call> markup.

Change

  • Resolve the effective parser when the Worker matches the replica. Carry an inherited parser and the architecture its renderer needs across launch. Each engine keeps its existing tool-rendering rules.

  • Use the selected replica’s supports_chat_tools value for both request forms, including an explicit False. Older descriptions use the API’s existing family check.

  • Return HTTP 503 with Retry-After: 30 when a routed tool request loses its selected replica. This also covers the interval after the Worker removes the description and before the Supervisor removes the route. Unsupported families and unrelated description errors keep their existing HTTP 400 responses.
  • Tests

  • Windows, Python 3.10 and 3.14. All 96 chat-tool cases passed at 8015982d. Against 7fbf1b31, three prompt checks found the schema missing, the admitted Qwen alias returned raw markup, and both Worker-first requests returned 400. The other 90 cases passed. The vLLM chat suite had the same seven failing test IDs on both revisions.

  • Windows, Python 3.14. A broader LLM and API comparison before the fixture fix found six new failures. All six were continuous-usage cases with tools on MLX chat, vLLM chat, or vLLM multimodal.

  • Linux, Ubuntu 24.04. I checked b098c0bf on Ubuntu. The pushed e54f9a20 differs from it only by dropping a three-byte model.bin test artifact and by importing a helper lazily in the continuous-usage fixture; I ran that fixture on Windows Python 3.10 and 3.14 (48 passed). In my Ubuntu runs the changed tests had 607 passed, 6 skipped, and 2 pre-existing vLLM streaming failures in each run. These covered Python 3.12 with Transformers 5.24.1 and 4.57.6, plus Python 3.10. The passing cases included the repaired continuous-usage fixtures and the DeepSeek V4.1 alias test that checks schema and image-part delivery to the native tokenizer.

  • Linux consumer and type checks. The Python 3.12 consumer run had 41 failures, all also present on the base. Whole-repository mypy passed on 1,227 files. Changed-files pre-commit failed on both revisions. The earlier Linux fail-before run reached the missing-schema assertion. On b098c0bf my run of the new tests against base production code stopped during collection because base production code lacked get_tool_parser_group; the lazy import in e54f9a20 removes that, and the fixture collects and passes against 7fbf1b31.
  • AI disclosure: this was prepared with AI assistance (Claude Code with Claude Fable 5.2 and Claude Opus 5.5, and OpenAI Codex with GPT-6.2).

    🤖 Generated with Claude Code

    Diff: 377 lines (+282 / -95) across 4 files Reviewer: Jackmeson1 Review duration: 738m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.43) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.43 · 377 lines diff across 4 files
    0.43
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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.355
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #6228"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 42.9% (MEDIUM) · Higher = larger blast radius
    42.9%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 16.9% · Safe to merge
    16.9%