Skip to content

Switch from Copilot Proxy to CAPI#318443

Merged
24anisha merged 4 commits into
microsoft:mainfrom
guomaggie:maggie/search-subagent-copilot-proxy-to-capi
Jun 6, 2026
Merged

Switch from Copilot Proxy to CAPI#318443
24anisha merged 4 commits into
microsoft:mainfrom
guomaggie:maggie/search-subagent-copilot-proxy-to-capi

Conversation

@guomaggie

@guomaggie guomaggie commented May 26, 2026

Copy link
Copy Markdown
Contributor

Currently, we use copilot-proxy as a go-between to get access from VS Code to models hosted in Fireworks. This PR covers changes needed to switch to CAPI:

  • CAPI returns a list of models available based on a user's SKU, FSI status, etc. We disabled the search subagent tool (for explore as well) if the search subagent models are not in the list of models returned by CAPI. So, if a user is blocked from using Qwen models, they're blocked from using our subagent tool.
  • Updated the search subagent tool to use a CAPI endpoint, instead of proxyAgenticEndpoint

Copilot AI review requested due to automatic review settings May 26, 2026 21:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Replaces the hardcoded ProxyAgenticEndpoint (with model vscode-agentic-search-router-a) used by the search subagent with a new SearchAgentChatEndpoint based on a CAPI-advertised search-agent family model, and gates the SearchSubagent/ExploreSubagent tools on availability of that model.

Changes:

  • Introduce SearchAgentChatEndpoint extending CopilotChatEndpoint with custom token limits (260000 prompt / 16000 output) and a SEARCH_AGENT_FAMILY constant.
  • Update SearchSubagentToolCallingLoop to discover the search-agent endpoint from endpointProvider.getAllChatEndpoints() instead of constructing ProxyAgenticEndpoint, falling back to the main agent endpoint on failure.
  • Gate SearchSubagent and ExploreSubagent tool availability in agentIntent on the presence of a search-agent family endpoint.
Show a summary per file
File Description
extensions/copilot/src/platform/endpoint/node/searchAgentChatEndpoint.ts New endpoint class wrapping CopilotChatEndpoint with search-agent-specific token limits.
extensions/copilot/src/extension/prompt/node/searchSubagentToolCallingLoop.ts Switches endpoint resolution from ProxyAgenticEndpoint to CAPI-discovered SearchAgentChatEndpoint with fallback.
extensions/copilot/src/extension/intents/node/agentIntent.ts Adds availability check for the search-agent family to gate subagent tools.

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 3

Comment on lines +97 to +109
// Use the CAPI search-agent model. Fall back to the main agent endpoint if the model
// is not available for this user
try {
const allEndpoints = await this.endpointProvider.getAllChatEndpoints();
const searchAgentEndpoint = allEndpoints.find(e => e.family === SEARCH_AGENT_FAMILY);
if (searchAgentEndpoint instanceof ChatEndpoint) {
return this.instantiationService.createInstance(SearchAgentChatEndpoint, searchAgentEndpoint.modelMetadata);
}
this._logService.warn(`Search-agent model not available in CAPI, falling back to main agent endpoint`);
} catch (error) {
this._logService.warn(`Failed to get search-agent endpoint from CAPI, falling back to main agent: ${error}`);
}
return await this.endpointProvider.getChatEndpoint(this.options.request);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping both paths; the checks happen at different times - agentIntent.ts for whether we expose the tool when the req starts, and getEndpoint for when we pick the endpoint at fetch time.

Comment on lines +150 to +151
const allEndpoints = await endpointProvider.getAllChatEndpoints().catch(() => [] as IChatEndpoint[]);
const searchAgentAvailable = allEndpoints.some(e => e.family === SEARCH_AGENT_FAMILY);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

} catch (error) {
this._logService.warn(`Failed to get search-agent endpoint from CAPI, falling back to main agent: ${error}`);
}
return await this.endpointProvider.getChatEndpoint(this.options.request);
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noticed during testing that the switch will cause backgroundToDoAgent to fail because it requests copilot-fast, which isn't available to free users. Should this change be covered by this PR too (the current PR focuses on supporting search subagent)?

Image

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you elaborate on this? your changes should only apply to search agent, not to the background todo tool

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^ just something I noticed, changes should be unrelated to this PR!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, thanks for noticing that, I'll be pushing a fix for this

@guomaggie guomaggie marked this pull request as draft May 26, 2026 22:55
@24anisha 24anisha marked this pull request as ready for review June 4, 2026 02:42
@guomaggie guomaggie force-pushed the maggie/search-subagent-copilot-proxy-to-capi branch from 21c046c to dbfc90f Compare June 4, 2026 16:12
@24anisha 24anisha requested review from bhavyaus and vritant24 June 4, 2026 16:34
} catch (error) {
this._logService.warn(`Failed to get search-agent endpoint from CAPI, falling back to main agent: ${error}`);
}
return await this.endpointProvider.getChatEndpoint(this.options.request);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct me if I'm wrong, but I thought we shouldn't be using the main agent in the search subagent if the model isn't available as it can end up charging the users much more now with UBB enabled. We should throw an error/gracefully exit the search subagent if the model isn't available

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the search subagent model isn't in the CAPI model list, we remove the tool (which is the behavior we agreed upon). If, however, we fall into the situation where the model is available but there's an error, falling back to the main agent should be ok. The CoGS delta when using the main agent as the search subagent model wasn't stat sig IIRC. And this case should be happening very rarely --only when the search model is available but erroring.

We could change it to just fail immediately with a message back to the main agent model, but sometimes the model will keep trying to call the tool because it's available, and having it return errors over and over might actually increase costs more than substituting the main agent model for the subagent model so the system still works. I don't think one is clearly better from a CoGS perspective than the other.

@24anisha 24anisha enabled auto-merge June 4, 2026 22:49
@24anisha 24anisha merged commit c983dda into microsoft:main Jun 6, 2026
25 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.124.0 milestone Jun 6, 2026
@alexdima

alexdima commented Jun 6, 2026

Copy link
Copy Markdown
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants