Skip to content

Scope /ai/relevant_files requests to the window's team - #15559

Merged
IsaiahWitzke merged 3 commits into
masterfrom
factory/team-header-relevant-files
Aug 26, 2026
Merged

Scope /ai/relevant_files requests to the window's team#15559
IsaiahWitzke merged 3 commits into
masterfrom
factory/team-header-relevant-files

Conversation

@warp-agent-staging

@warp-agent-staging warp-agent-staging Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Description

ServerApi::get_relevant_files (backing POST /ai/relevant_files, used by codebase search when picking relevant files for the outline-based index) sent no team scope. The server falls through GetActiveTeamOrFallbackToPrincipalGetTeamForPrincipal, 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 TeamScope through to the request as the X-Warp-Team-Uid header, following the pattern established in #15355 for /ai/multi-agent. No server change is needed — SetActiveTeamFromHeader already runs on /ai/*.

The scope comes from BlocklistAIActionExecutor's existing TeamContextResolver (already resolved from the window via UserWorkspaces::team_context_resolver), the same live scope it already uses to decide whether a SearchCodebase action can auto-execute. It's resolved once, immediately before executing the action, and threaded as a RequestTeamScope through SearchCodebaseExecutor::executeGetRelevantFilesController::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 --lib

  • cargo clippy -p warp --lib --tests -- -D warnings

  • cargo test -p warp --lib --features local_fs for get_relevant_files, search_codebase, and action_model (192 tests, all passing)

  • ./script/format

  • I have manually tested my changes locally with ./script/run

Agent Mode

  • Warp Agent Mode - This PR was created via Warp's AI Agent Mode

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.
@warp-agent-staging

Copy link
Copy Markdown
Contributor Author

This PR was generated with Warp.

Comment @warp-factory on this PR to send it follow-up work.

View run View conversation View on Slack

Comment thread app/src/ai/get_relevant_files/controller.rs Outdated
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
IsaiahWitzke enabled auto-merge (squash) August 26, 2026 04:45
@IsaiahWitzke
IsaiahWitzke merged commit a45efa0 into master Aug 26, 2026
28 checks passed
@IsaiahWitzke
IsaiahWitzke deleted the factory/team-header-relevant-files branch August 26, 2026 05:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant