← Back to Pull requests

fix(ai): keep request options and hold the useChat queue while sendAutomaticallyWhen decides #24857

Closed
unknown closed this pull request without merging on Nov 10, 2026 18:03 UTC
View on GitHub
unknown unknown commented on Nov 10, 2026 17:25 UTC
Author

background

follow-up to #24595 for the two bot comments

  • when sending a message made the queue send an answered tool approval first, that request dropped the headers and body the user passed, same for send now

  • while an async sendAutomaticallyWhen was still deciding, the chat looked idle, so a new message went out right away and a second request could start when the decision came back true
  • summary

  • pass the sending message's request options to the approval request, in the send path and in send now

  • count a pending sendAutomaticallyWhen decision as in progress for the queue, so messages sent meanwhile wait and go out once it settles

  • a stop drops the decisions that were pending, so they can't hold the queue after send now
  • verification

    before: the approval request had no x-tenant header or tenant body, and a message sent during a slow sendAutomaticallyWhen started a second request. after: the approval request keeps both, and the message waits in the queue with one request at a time

    <details>
    <summary>live run with the e2e routes and the real api</summary>

    approval route, approve then send with { headers: { 'x-tenant': 't1' }, body: { tenant: 't1' } }

    user: What is the weather in Berlin? Use the t | x-tenant=- body.tenant=-
    assistant: [tool-weather:approval-responded] | x-tenant=t1 body.tenant=t1
    user: Do not use any tools. Reply with only th | x-tenant=t1 body.tenant=t1
    

    queue route with a sendAutomaticallyWhen that takes 2s

    during the decision: requests 1 queue [ 'Reply with only the word two.' ]
    user: Reply with only the word one.
    user: Reply with only the word two.
    max requests in flight at once: 1
    

    </details>

    checklist

  • tests have been added / updated (for bug fixes / features)

  • documentation has been added / updated (for bug fixes / features)

  • a _patch_ changeset for relevant packages has been added (run pnpm changeset in root)

  • i have reviewed this pull request (self-review)
  • related issues

    follow-up to #24595

    Diff: 254 lines (+190 / -64) across 3 files Reviewer: mangeshraut712 Review duration: 37m
    All Vouch review confidence checks passed
    Residual risk 0.15 = Change Risk (0.39) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.39 · 254 lines diff across 3 files
    0.39
    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.332
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #24857"
    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: 39.1% (MEDIUM) · Higher = larger blast radius
    39.1%
    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: 15.4% · Safe to merge
    15.4%
    Repository