Scope /ai/relevant_files requests to the window's team - #15559
Merged
Conversation
Send X-Warp-Team-Uid on the outline-based get_relevant_files request so the server resolves cost against the team the requesting window is actually scoped to, instead of falling back through GetTeamForPrincipal (lowest team id) for members on multiple teams. The scope is threaded from BlocklistAIActionExecutor's existing TeamContextResolver -- the same live, window-derived scope already used to decide whether a SearchCodebase action can auto-execute -- through SearchCodebaseExecutor and GetRelevantFilesController to the server_api call.
Contributor
Author
|
This PR was generated with Warp. Comment |
Per review: the comment on team_scope's routing just restated what the code already shows by following send_request into send_local_request vs send_remote_request.
IsaiahWitzke
approved these changes
Aug 26, 2026
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.



Description
ServerApi::get_relevant_files(backingPOST /ai/relevant_files, used by codebase search when picking relevant files for the outline-based index) sent no team scope. The server falls throughGetActiveTeamOrFallbackToPrincipal→GetTeamForPrincipal, which resolves to the member's lowest team id rather than the team the requesting window is actually on. Since this endpoint's cost is billed to the AI group, members on more than one team could have this request billed to the wrong team.This threads the live, window-derived
TeamScopethrough to the request as theX-Warp-Team-Uidheader, following the pattern established in #15355 for/ai/multi-agent. No server change is needed —SetActiveTeamFromHeaderalready runs on/ai/*.The scope comes from
BlocklistAIActionExecutor's existingTeamContextResolver(already resolved from the window viaUserWorkspaces::team_context_resolver), the same live scope it already uses to decide whether aSearchCodebaseaction can auto-execute. It's resolved once, immediately before executing the action, and threaded as aRequestTeamScopethroughSearchCodebaseExecutor::execute→GetRelevantFilesController::send_request(local, outline-based path only — the remote path resolves relevant files through the remote host's own indexing service and isn't affected) →ServerApi::get_relevant_files.Linked Issue
No linked GitHub issue — this is one of several call sites being migrated to send an explicit team scope instead of relying on the server's team-resolution fallback.
Testing
This is a plumbing change (adds a parameter, sets a header) with no new externally observable branching logic, so no new unit test was added — consistent with the reference implementation in #15355. Verified:
cargo check -p warp --libcargo clippy -p warp --lib --tests -- -D warningscargo test -p warp --lib --features local_fsforget_relevant_files,search_codebase, andaction_model(192 tests, all passing)./script/formatI have manually tested my changes locally with
./script/runAgent Mode