Skip to content

SDK with BYOK providers: short model names aren't matched to the provider's models (custom agents fail; a short session model fails with a misleading "No GitHub OAuth token" error) #5127

Open

Description

@SivaKesava1

Describe the bug

When an SDK session configures BYOK providers and models, its models are only known as
provider-qualified ids such as copilot/gpt-5.4-mini. Any model given by its short name is not
matched to them, even when exactly one configured provider serves that model:

  1. Custom agents. An agent whose model is a short name fails when the main agent starts it.
    The tool call returns
    Model 'gpt-5.4-mini' is not available. Available models: copilot/gpt-5.6-sol, copilot/gpt-5.6-luna, copilot/gpt-5.4-mini, copilot/gpt-5.6-sol, copilot/gpt-5.6-luna, copilot/gpt-5.4-mini.
    The list itself names the model, and also lists every model twice. This happens for agents
    passed as customAgents and for .github/agents/*.agent.md files loaded with
    enableConfigDiscovery: true.

  2. Session model. createSession accepts a short model (session.start reports
    selectedModel: "gpt-5.6-sol"), but the first turn fails with
    Execution failed: InvalidArg, No GitHub OAuth token or Copilot HMAC key provided. The debug log
    shows the turn quietly switched to claude-sonnet-4, a model that isn't configured, on GitHub's
    own inference:

    [WARNING] model resolution before the turn did not commit a new selection {"error":"No model available. Check policy enablement under GitHub Settings > Copilot"}
    [WARNING] turn model is in neither the picker nor the unfiltered catalog, ...; falling back to default capabilities and the chat-completions wire {"model":"claude-sonnet-4",...}
    

    The error points at authentication, not at the model name. When the user is also signed in to
    GitHub, the request would presumably go to GitHub's own inference instead of the configured
    provider, without any error.

Why it matters. Agent files are shared between Copilot CLI and SDK sessions. In CLI BYOK mode
the same .agent.md must use the short name, and a file can't know which provider name an SDK host
chose. With discovery on, the main agent sometimes recovers by retrying with the qualified name. That
costs a failed tool call, depends on the model noticing, and in our runs a retry sometimes picked a
different model instead. GitHub Agentic Workflows currently rewrites every agent's model to a
qualified name before creating the session; we'd rather not keep that workaround.

This short-name matching is probably also the SDK-mode cause of #5126 (built-in agents' default
models never match).

Affected version

@github/copilot-sdk 1.0.19 against copilot --headless from Copilot CLI 1.0.96. Also seen with SDK 1.0.16 and CLI 1.0.90.

Steps to reproduce the behavior

Start copilot --headless --port <port> with no GitHub sign-in, and use one BYOK provider:

{
  "providers": [{ "name": "copilot", "type": "openai", "wireApi": "responses",
                  "baseUrl": "https://api.githubcopilot.com", "bearerToken": "<token>",
                  "headers": { "Copilot-Integration-Id": "copilot-developer-cli" } }],
  "models": [{ "id": "gpt-5.6-sol", "provider": "copilot" },
             { "id": "gpt-5.6-luna", "provider": "copilot" },
             { "id": "gpt-5.4-mini", "provider": "copilot" }]
}

All models are on the same wire API, so #5103 doesn't apply.

  1. Custom agent with a short model: session model: "copilot/gpt-5.6-sol", plus
    customAgents: [{ "name": "quick-checker", "description": "Finds where a function is defined", "prompt": "...", "model": "gpt-5.4-mini" }].
    Prompt: Use the task tool with agent_type "quick-checker" to find which file defines add_numbers.
    Observed: the first task call fails with Model 'gpt-5.4-mini' is not available. Available models: ...copilot/gpt-5.4-mini....
  2. Same agent from a file: no customAgents, enableConfigDiscovery: true, and
    .github/agents/quick-checker.agent.md with model: gpt-5.4-mini in its front matter. Observed:
    the same error.
  3. Control: the same agent with "model": "copilot/gpt-5.4-mini" runs on mini
    (modelSelectionSource: "agent_definition_default").
  4. Short session model: model: "gpt-5.6-sol" and prompt Reply with the single word OK.
    Observed: session.error Execution failed: InvalidArg, No GitHub OAuth token or Copilot HMAC key provided,
    with the claude-sonnet-4 warnings above in the debug log.

Expected behavior

  1. A short model name resolves to the configured provider model with that id when exactly one
    provider serves it: gpt-5.4-mini → copilot/gpt-5.4-mini. This applies to the session model,
    custom agents from customAgents or discovered files, and built-in agent defaults (BYOK: built-in agents (explore, task, research) never use their default models and silently run on the session model #5126).
  2. If several providers serve the id, pick deterministically (for example, the provider whose wire
    API the model supports), or report the ambiguity and list the qualified choices.
  3. A session model that can't be resolved fails at createSession with an error that names the
    model and the available ids. It isn't silently replaced by another model, and the error doesn't
    point at authentication.

Additional context

Activity

  1. added theissue type on Oct 12, 2026
  2. rishidevcli54-mcp commented on Oct 13, 2026

    @rishidevcli54-mcp
  3. added
    area:agentsSub-agents, fleet, autopilot, plan mode, background agents, and custom agents
    area:modelsModel selection, availability, switching, rate limits, and model-specific behavior
    area:non-interactiveNon-interactive mode (-p), CI/CD, ACP protocol, and headless automation
    and removed on Oct 13, 2026
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 behaviorarea:non-interactiveNon-interactive mode (-p), CI/CD, ACP protocol, and headless automation

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions