Skip to content

Per-agent provider selection for custom agents #4703

Description

@Starefossen

I know about BYOK (COPILOT_PROVIDER_BASE_URL plus COPILOT_MODEL), /model, and the model field in custom-agent frontmatter. We use all three. None of them lets two agents in one session talk to two different endpoints, because COPILOT_PROVIDER_BASE_URL is process-wide and nothing scopes it to an agent. That is the difference between this and #3624 and copilot-sdk#1545, both closed within hours pointing at the BYOK docs.

The ask

A provider field in custom-agent frontmatter. Or the per-agent env/env_file scoping that #2879 proposes for secrets, which would do the same job. The main agent keeps the session provider. The subagent gets its own base URL.

What the runtime already does

I put a recording HTTP server at COPILOT_PROVIDER_BASE_URL on 1.0.83-3 and dispatched a custom agent through the task tool. Three requests came out of one session:

1  model=local-worker-model  tools=24  main agent
2  model=ROUTE-ME-LOCAL      tools=1   subagent; model from its .agent.md frontmatter,
                                       its own instructions in the system prompt
3  model=local-worker-model  tools=24  main agent

The model override on the task tool arrives the same way. The per-agent model id already reaches the provider, and v1.0.62 ("Keep custom agents on their configured model when using BYOK providers") and v1.0.65 for subagents made that deliberate. What it cannot carry is an endpoint to send that id to.

Use case

A cloud main agent plans and reviews. It hands renames, comment edits, log lines and single-file changes to a subagent running a 27B model on the developer's Mac (MLX, 48 GB). Those tokens cost nothing. I am not claiming the local model matches the cloud one. On our own eight-task benchmark two local models came out indistinguishable from each other, and the only claim I will stand behind is free tokens for mechanical work. Judgement stays in the cloud.

What we tried

A routing proxy at COPILOT_PROVIDER_BASE_URL, keyed on the model id. Known local ids go to the MLX server and the proxy forwards the rest to GitHub. Two problems killed it. It puts the main agent's traffic through GitHub endpoints that are not documented for that use. And the docs say "A declared model or effort that can't be honored falls back to the session's value instead of failing the dispatch", so any proxy error on a local id sends that task to the session model instead. You find out from the bill rather than from an error.

Related

Activity

  1. added
    area:agentsSub-agents, fleet, autopilot, plan mode, background agents, and custom agents
    area:modelsModel selection, availability, switching, rate limits, and model-specific behavior
    on Sep 3, 2026
  2. rveznaver commented on Sep 17, 2026

    @rveznaver

    I had the same use case as above: a cloud main agent orchestrating whilst a local-worker subagent runs against a local endpoint. The problem is that the session.provider.add (the BYOK provider-registration surface) is only reachable session-wide today, through the process-wide COPILOT_PROVIDER_BASE_URL, so nothing lets two agents in one session talk to two endpoints.

    The pieces are there (as per the GitHub SDK), they are just not enabled in the CLI:

    • provider.add({ providers: [...], models: [...] }) gives you a selection ID like local/subagent
    • custom agents already take a model: field, and the CLI already has a per-subagent model target picker

    So the only missing piece is connecting the provider to an agent instead of the whole session (the runtime supports more than one provider in a session, it is just not exposed).

    proposed provider: field in agent yaml

    The smallest change would probably be a provider: block (or a provider/model selection ID) alongside model:, like so:

    ---
    name: local-worker
    model: local/subagent
    provider:
      name: local
      type: openai
      baseUrl: http://127.0.0.1:8888/v1
    ---

    The alternative (described in #2879) is per-agent scoping of COPILOT_PROVIDER_BASE_URL and its key, set only for the delegated agent, either works.

    benefits

    The cloud frontier main agent orchestrates and reviews, whilst the local-worker subagent on a local ~27B model does the mechanical, well-scoped work (renames, edits, log/grep triage). The high-token bulk reading runs locally for free and only a small distilled result crosses back to the cloud model, so routine delegated work gets a large token/cost reduction whilst the main agent stays on the copilot hosted model for judgement and final review.

    PoC

    I have confirmed two providers can work in one session end-to-end (main on a GitHub-hosted model, subagent on a loopback OpenAI-compatible endpoint), so the runtime already supports this. The mechanism is exactly the one from the SDK docs: a provider.add at session start, plus the agent model: selecting the resulting local/subagent ID. To note: this was a local proof-of-concept; the how shall be left as an exercise for the reader.

  3. patniko commented on Oct 26, 2026

    @patniko
    Collaborator

    Thanks for the report. We've shipped fixes in this area since this was filed (most recently in Copilot CLI v1.0.100), and we believe this may now be resolved. Could you retest on the latest release (Copilot CLI v1.0.103) and let us know whether you still see it? If we don't hear back in a couple of weeks, we may close this issue — you can always reopen it.

    Triaged as part of a Copilot SDK backlog review, with help from GitHub Copilot.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:agentsSub-agents, fleet, autopilot, plan mode, background agents, and custom agentsarea:modelsModel selection, availability, switching, rate limits, and model-specific behaviormore-info-needed

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions