← Back to Pull requests

test(external-router): the MCP tests share their orchestrator and session set-up #4531

Open
unknown opened this pull request with 468 lines diff across 5 files
View on GitHub
unknown unknown commented on Oct 25, 2026 19:03 UTC
Author

What

The responses utils tests spelled out the same request thirteen times (one text input, no tools of its own), and eleven of them, with two tests of the tool loop, built the same orchestrator, filled its tool inventory by hand and opened the same session over it: a dozen lines each, identical modulo the tool names and the built-in route.

The MCP test support, which already held the orchestrator and the binding, gains the two steps after them, and the tests call them.

Tests only; no production code.

Changes

  • crates/external_router/src/openai/mcp/test_support.rs (cfg(test)): internal_orchestrator_serving(builtin, tools), the orchestrator from internal_orchestrator with each given tool in its inventory as a tool of the internal server, and internal_session(&orchestrator), the session a request that names the internal server through internal_binding opens over it; the module doc names the session.

  • crates/external_router/src/openai/responses/utils.rs (tests): hello_request() replaces the ten plain request literals, and the three with fields of their own (tools, a conversation ref) spread it; the eleven set-ups go through the two helpers (one test built the orchestrator without a tool and keeps internal_orchestrator(None)); the McpToolSession and ToolEntry imports go with the hand-written set-ups.

  • crates/external_router/src/openai/mcp/tool_loop.rs (tests): the two internal-filter tests go through the same two helpers; the module's other sessions (over function_tool_session's bindings) stay as they are.

  • Left as they are: each module keeps its own test_tool, whose schemas differ (a query property in the utils tests, none in the tool loop's), and function_tool_session in the tool loop's tests builds a different orchestrator (a function tool, its own bindings).
  • Test plan

  • cargo test -p smg-external-router --lib -- openai::responses::utils::tests openai::mcp::tool_loop::tests: 0 listed and passed on this head, 0 listed and passed on the base commit (the same names both sides).

  • cargo clippy -p smg-external-router --lib --tests -- -D warnings and cargo +nightly fmt -p smg-external-router -- --check: clean.
  • Owed

    Nothing.

    Release note

    Internal: the external router's MCP tests build their orchestrator, tool inventory and session through the crate's test support instead of spelling the set-up out per test; no change in behaviour.

    Numbers

    | metric | before | after | setup |
    |---|---|---|---|
    | request literals spelled out in full in the responses utils tests | 13 | 0 | grep -c 'input: ResponseInput::Text("hello".to_string())' crates/external_router/src/openai/responses/utils.rs, base commit (13) vs this head (1, the helper) |
    | MCP sessions opened by hand in the two test modules | 13 | 0 | grep -c 'vec!\[test_support::internal_binding()\]' over crates/external_router/src/openai/responses/utils.rs and crates/external_router/src/openai/mcp/tool_loop.rs, base commit (11 + 2) vs this head (0 + 0) |
    | tool-inventory inserts written out in the two test modules | 14 | 0 | grep -c 'insert_entry(ToolEntry::from_server_tool(' over the same two files, base commit (11 + 3) vs this head (0 + 0; the helper's loop is the one left, in the test support) |
    | identical ten-line-plus runs inside the crate's tests | 14 | 0 | the test-code shingle census (K=10) over crates/external_router, base commit vs this head |
    | tests under the two module filters | 0 passed | 0 passed | cargo test -p smg-external-router --lib -- openai::responses::utils::tests openai::mcp::tool_loop::tests, base commit and this head |
    | lines changed | 0 | 349 | git diff --shortstat against the base commit: +107/-242, three files, tests only |

    Diff: 468 lines (+351 / -117) across 5 files Reviewer: claude[bot] Review duration: 18m
    All Vouch review confidence checks passed
    Residual risk 0.27 = Change Risk (0.51) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.51 · 468 lines diff across 5 files
    0.51
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    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.368
    Shallow Review Depth shallow_review_depth
    0.344
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #4531"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% 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: 50.6% (MEDIUM) · Higher = larger blast radius
    50.6%
    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: 46.7% · Lower = rushed or shallow review
    46.7%
    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: 27% · Safe to merge
    27%