← Back to Pull requests

feat: support async client tools (#332) #428

Closed
unknown closed this pull request without merging on Oct 16, 2026 04:25 UTC
View on GitHub
unknown unknown commented on Oct 09, 2026 10:18 UTC
Author

Summary

Closes #332.

Async client tools on the Responses API, matching the recorded OpenAI contract:

  • async: true is accepted on function tools, custom tools, and function members of a Codex namespace. On a

  • namespace itself, client shell, client tool_search, and every gateway-executed tool it returns 400
    unknown_parameter with param: "tools[i].async", as OpenAI does.
  • An OpenAI model keeps answering after an async call; a vLLM-served model stops at the call. When a round's only

  • client calls are async, the gateway runs another round with the calls pending, so the call (marked async: true)
    and the answer arrive in one response. A synchronous client call still ends the response. After two async-only
    continuations in a row, the response (or multi-agent turn) completes with the calls pending.
  • Two upstream-only hints keep the model from inventing the pending result: a suffix on the async tool's description,

  • and a developer note after each pending call. The async marker is stripped upstream. The hints are never stored
    or returned; response.created and response.completed echo the client's own declarations. Sampled against
    Qwen/Qwen3.6-35B-A3B, 24 runs per mode: without hints, 14 of the 19 runs that made the call invented a result;
    with hints, 0 of 18.
  • A pending async call may stay unanswered on later requests. Repeated or conflicting outputs for an async call are

  • accepted and all reach the model; synchronous calls keep the existing rejection. An output for an unknown call_id
    returns 400 with OpenAI's message.
  • Async calls carry async: true in blocking output, in streamed output_item.added / output_item.done, in stored

  • items, and over WebSocket.
  • Compaction (automatic, compaction_trigger, and /compact) keeps pending async calls; each response stores only

  • the pending calls from its own input.
  • Multi-agent: an async call does not make its owner wait. A late async output resumes a settled root in a

  • continuation request, and an idle root when it arrives as live WebSocket input. parallel_tool_calls: true with an async tool returns 400
    unsupported_value with param: "multi_agent", as OpenAI does.
  • max_tool_calls is unaffected: async calls are client-owned and are not counted.

  • One deliberate difference: OpenAI rejects async for some models (unsupported_value, param: "tools"); the

  • gateway accepts it for every model it serves.

    Structure. tool/async_execution.rs holds the hint texts and lower_async_calls, applied in
    RequestPayload::to_upstream_request. executor/engine/agent_turn/round_policy.rs holds ClientCalls and
    classify_round, including the continuation cap. types/io/input/window.rs holds the compaction-window helpers that
    keep open async calls. The async parameter is typed on every declaration: async_execution on function and custom
    tools, and unsupported_async on the others so validation can reject it. Calls carry a typed async_execution
    (FunctionToolCall, CustomToolCall, InputFunctionToolCall), written only when true; null reads as false.
    ToolDeclaration::declares_async / declares_unsupported_async and the borrowing tool::declares_async answer
    which declarations are async. New errors: ToolError::UnknownCallOutput, ToolError::UnknownParameter, and
    ExecutorError::UnsupportedValue. ARCHITECTURE.md and docs/api/index.md (new "Async client tools" section) are
    updated.

    Recordings. tests/cassettes/async_tools/ (see its README) holds an OpenAI reference set (gpt-6-astra, 9
    scenarios) and a gateway set (Qwen/Qwen3.6-35B-A3B) for every scenario except web-search-mixed. They are driven by
    the scripted record_async_tool_cassettes.py through the shared recording proxy, with an x-run-id per step.
    async_tool_cassette_test.rs compares the gateway with OpenAI step by step: status, and error type, code, param and
    message.

    File-size exceptions, for reviewer approval (reasons in .rust-file-sizes.json): tool/registry.rs 567,
    types/io/output.rs 1119, types/tools/params.rs 622.

    Known gaps:

  • web-search-mixed is not recorded through the gateway; it needs a configured web-search provider.

  • The model sometimes says it has started the lookup without making the call (about 1 start in 3 or 4). The rate is

  • the same with and without the hints.
  • The model's reasoning may quote or paraphrase the hints, including a namespace member's flattened model-visible

  • name. The gateway does not filter reasoning.
  • A subagent that reaches the async continuation cap reports an empty final answer to its parent.

  • The streamed marker is added to translated SSE frames in the dispatcher, not set on a typed item.
  • Test Plan

  • cargo fmt -- --check, cargo clippy --all-targets -- -D warnings, and pre-commit run --all-files pass.

  • cargo test --workspace: 98 suites, 2334 passed, 0 failed. New coverage: async_tool_test.rs (end to end through

  • the executor with a mock upstream, blocking and streaming), async_tool_cassette_test.rs (gateway vs. OpenAI, step
    by step), and unit tests for the round policy, hints, pending calls, multi-agent, and WebSocket input.
  • Real model (Qwen/Qwen3.6-35B-A3B behind the gateway): every recorded step matched OpenAI's status and error

  • envelope, no hint text reached the client, and async calls carried async: true.

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: franciscojavierarceo Review duration: 9726m
    All Vouch review confidence checks passed
    Residual risk 0.23 = Change Risk (0.57) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.57 · 650 lines diff across 8 files
    0.57
    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.388
    Shallow Review Depth shallow_review_depth
    0.289
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #428"
    general weight: 0.35
    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: 57% (MEDIUM) · Higher = larger blast radius
    57%
    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: 22.5% · Safe to merge
    22.5%