Scope /ai/predict_am_queries to the window's team - #15555
Merged
Conversation
Send X-Warp-Team-Uid on POST /ai/predict_am_queries, resolved from the input view's window via RequestTeamScope, so the server no longer falls back to GetTeamForPrincipal's lowest-team-id default when a member is on multiple teams.
Contributor
Author
|
This PR was generated with Warp. Comment |
IsaiahWitzke
approved these changes
Aug 26, 2026
IsaiahWitzke
enabled auto-merge (squash)
August 26, 2026 03:57
The scope resolution on the preceding line already says it's pinned at send; the comment only restated that.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
POST /ai/predict_am_queries(Agent Mode next-query prediction) sent no team context. The/aigroup'sSetActiveTeamFromHeadermiddleware only picks up the header, so omitting it silently falls throughGetActiveTeamOrFallbackToPrincipal→GetTeamForPrincipal, which resolves to whichever team happens to have the lowest id — an arbitrary, and possibly wrong, team for a member of more than one.Changes
ServerApi::predict_am_queriesnow takes aRequestTeamScopeand sends it asX-Warp-Team-Uidwhen present, following the/ai/multi-agentpattern ([multi-team] Scope multi-agent requests to a team #15355).Input::predict_am_queryresolves the scope from the live window viaUserWorkspaces::team_context_for_operation, pinning it at send time (this call spawns an async request, same as the existing multi-agent send path).Verification
./script/formatcargo clippy -p warp --lib --tests -- -D warnings(clean)ViewContext<Input>available at the call site.