Skip to content

Gemini Bad Request with Github Copilot #8417

Closed as not planned
Closed as not planned

Description

@ngt-sg

Description

No matter which Gemini model I use with Github Copilot authentication I get a Bad Request: Bad Request error

It works for a colleague with the same Github Copilot license from our company.

I can prompt Gemini from the Copilot CLI

EDIT:
Found the issue. Gemini models fail with the Docker Gateway MCP with the Linear plugin enabled

Plugins

Tried both with and without "opencode-openai-codex-auth" installed

OpenCode version

1.1.19

Steps to reproduce

  1. Authenticate with Github Copilot
  2. Have Docker MCP gateway with Linear plugin enabled
  3. Select any Gemini model
  4. Write any prompt
  5. Receive Bad Request: Bad Request error

Screenshot and/or share link

Image Image

Operating System

macOS 26.1

Terminal

Ghostty and macOS Terminal

Activity

  1. github-actions commented on Jan 14, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    The root cause appears to be related to request body transformation when using Gemini models with Copilot authentication. Issues #5161 and #4816 are particularly similar to your case.

    Feel free to ignore if none of these address your specific case.

  2. ngt-sg commented on Jan 14, 2026

    @ngt-sg
    Author

    I found configuration causing the problem. I updated the description.

    In my case it was the Docker Gateway MCP with the Linear plugin enabled. It might be the Linear MCP by itself. It works fine with the other plugins I have in the Docker MCP toolkit. But removing the Linear plugin fixed the issue on my end.

  3. smerrill commented on Jan 29, 2026

    @smerrill

    I have the same issue with chrome-devtools-mcp@latest.

  4. smerrill commented on Jan 29, 2026

    @smerrill

    Although interestingly starting that MCP with --no-category-emulation lets it work with GitHub-hosted Gemini 3 models. Very odd.

  5. NateSmyth commented on Jan 29, 2026

    @NateSmyth
    Contributor

    @smerrill

    Gemini models require nullable types to use OpenAPI 3.0 nullable keyword instead of JSON Schema union types

    (from vscode copilot extension)

    Had the same issue with chrome_devtools and this ended up being the reason.
    --no-category-emulation disables emulate which is the only tool with nullable types

  6. fujunchao commented on Jan 31, 2026

    @fujunchao

    I'm having the same problem with Chrome DevTools,After configuring the same parameters, the problem is solved with --no-category-emulation。

  7. rekram1-node commented on Jan 31, 2026

    @rekram1-node
    Contributor

    ah yeah ig we need to sanitize the tools more aggressively for gemini

  8. smerrill commented on Jan 31, 2026

    @smerrill

    The strange thing is that this is only a problem for Copilot Gemini 3, not directly via the gemini-auth plugin.

  9. dinhphieu commented on Feb 2, 2026

    @dinhphieu

    Yup, can confirm. Running from a directory without MCP configs (no chrome-devtools-mcp especially) allowed Copilot Gemini to work

  10. mattleong commented on Feb 2, 2026

    @mattleong

    Yup, can confirm. Running from a directory without MCP configs (no chrome-devtools-mcp especially) allowed Copilot Gemini to work

    Yup, I can confirm that the sentry mcp server is also causing this issue for me.

  11. alvinometric commented on Feb 3, 2026

    @alvinometric

    Same here, with the Linear MCP

    It looks like there is an attempted fix here: #11968

  12. rekram1-node commented on Feb 3, 2026

    @rekram1-node
    Contributor

    I believe this should be fixed in next release

  13. 2 remaining items

  14. MPThLee commented on Feb 23, 2026

    @MPThLee

    These seem to be also related to #14509 in recent conditions.
    I have no Chrome DevTools MCP, but I am still getting a Bad Request too.

  15. lightrao commented on Feb 23, 2026

    @lightrao

    add '--no-category-emulation' for chrome-devtools mcp:

    "chrome-devtools": {
                "type": "local",
                "command": [
                    "npx",
                    "-y",
                    "chrome-devtools-mcp@latest",
                    "--no-category-emulation" 
                ],
                "enabled": true
            },
    
  16. raymelon commented on Feb 23, 2026

    @raymelon

    instagit mcp also introduces the same issue

  17. Levyrii commented on Mar 6, 2026

    @Levyrii

    I have the same issue with zereight/mcp-gitlab

  18. Tetrahedrite commented on Mar 11, 2026

    @Tetrahedrite

    I got same issue with Notion official remote MCP server.

    {
      "$schema": "https://opencode.ai/config.json",
      "mcp": {
        "notion": {
          "type": "remote",
          "url": "https://mcp.notion.com/mcp",
          "enabled": true
        }
      }
    }
  19. kvn1351 commented on Mar 13, 2026

    @kvn1351

    Still an issue on Opencode 1.2.25. Chrome devtools mcp breaks both Gemini flash 3.0 (copilot) and GLM5 (nanogpt).

  20. Tetrahedrite commented on Mar 19, 2026

    @Tetrahedrite

    I'm not sure when this was fixed, but the issue no longer seems to occur in the current version 1.2.27. How about everyone else? I don't think Notion MCP was suddenly patched or anything...

  21. iamniels commented on Apr 1, 2026

    @iamniels

    I still have this issue with the Jetbrains built-in MCP server on Opencode 1.3.13

    jetbrains_opencode_mcp_bad_request.webm
  22. removed
    bugSomething isn't working
    on May 3, 2026
  23. ricardo-markiewicz-cs commented on Jun 9, 2026

    @ricardo-markiewicz-cs

    To me it was working really good last week but not it does not work anymore, just a Bad Request for any Gemini model on Copilot. All Gemini models are enabled in https://github.com/settings/copilot/features and I've "unlimited" budget for now (this an enterprise account).

    Image

    Last week usage from opencode stats:

    Image

    Logs:

    $ opencode --version
    1.16.2
    
    INFO  2026-06-09T11:16:51 +0ms service=bus type=session.status publishing
    INFO  2026-06-09T11:16:51 +1ms service=llm providerID=github-copilot modelID=gemini-3-flash-preview session.id=ses_153e68fa7ffet8Tfjdff8dTyMa small=false agent=build mode=primary stream
    INFO  2026-06-09T11:16:51 +0ms service=provider status=started providerID=github-copilot getSDK
    INFO  2026-06-09T11:16:51 +0ms service=provider status=completed duration=0 providerID=github-copilot getSDK
    INFO  2026-06-09T11:16:51 +6ms service=default llm.runtime=ai-sdk llm.provider=github-copilot llm.model=gemini-3-flash-preview llm runtime selected
    INFO  2026-06-09T11:16:52 +592ms service=bus type=session.updated publishing
    ERROR 2026-06-09T11:16:52 +93ms service=llm providerID=github-copilot modelID=gemini-3-flash-preview session.id=ses_153e68fa7ffet8Tfjdff8dTyMa small=false agent=build mode=primary error={"error":{"name":"AI_APICallError","url":"https://api.githubcopilot.com/chat/completions","requestBodyValues":{"model":"gemini-3-flash-preview","max_tokens":32000,"temperature":1,"top_p":0.95,"messages":[...],"tool_choice":"auto","stream":true},"statusCode":400,"responseHeaders":{"cache-control":"no-cache","content-security-policy":"default-src 'none'; sandbox","content-type":"text/plain; charset=utf-8","date":"Tue, 09 Jun 2026 11:16:52 GMT","strict-transport-security":"max-age=31536000","transfer-encoding":"chunked","x-content-type-options":"nosniff","x-copilot-api-exp-assignment-context":"5133j383:1109202;c_a15ch289:1165001;","x-copilot-service-request-id":"dbb73113-bccc-4129-ab84-c746ae27e505","x-github-backend":"Kubernetes","x-github-request-id":"F0DE:1AC31E:426470B:46D8DA6:6A27F622","x-request-id":"00000-745affe7-5b90-4fc5-9375-a0d6a42c329c"},"responseBody":"Bad Request\n","isRetryable":false}} stream error
    ERROR 2026-06-09T11:16:52 +6ms service=session.processor session.id=ses_153e68fa7ffet8Tfjdff8dTyMa messageID=msg_eac19734c0014A3U1O5hjV8CuC error=Bad Request stack=AI_APICallError: Bad Request
        at <anonymous> (/$bunfs/root/chunk-w4xmcxp8.js:6:14766)
        at async <anonymous> (/$bunfs/root/chunk-w4xmcxp8.js:6:12790)
        at processTicksAndRejections (native:7:39) process
    INFO  2026-06-09T11:16:52 +0ms service=bus type=session.error publishing
    INFO  2026-06-09T11:16:52 +0ms service=bus type=session.status publishing
    INFO  2026-06-09T11:16:52 +0ms service=bus type=session.idle publishing
    INFO  2026-06-09T11:16:52 +2ms service=bus type=message.updated publishing
    INFO  2026-06-09T11:16:52 +1ms service=bus type=session.status publishing
    INFO  2026-06-09T11:16:52 +0ms service=bus type=session.idle publishing
    Error: Bad Request: Bad Request
    

    UPDATE

    Removing the Github MCP seems to solve the problem:

    This is the github MCP I was using

            "github": {
              "type": "remote",
              "url": "https://api.githubcopilot.com/mcp/",
              "headers": {
                "Authorization": "Bearer <token>"
              }
            }
    
  24. Kjaer commented on Jun 9, 2026

    @Kjaer

    hmm, I am using 2 MCP, engram and public-browser. I disabled them and error still occurs.

    ERROR 2026-06-09T14:58:04 +258ms service=llm providerID=github-copilot modelID=gemini-3.5-flash session.id=ses_15330b0b6ffevY1sDxQDY9tDZ3 small=false agent=plan mode=primary error={"error":{}} stream error
    ERROR 2026-06-09T14:58:04 +2ms service=session.processor session.id=ses_15330b0b6ffevY1sDxQDY9tDZ3 messageID=msg_eace3fdbf002QXzLglc5GKWzb8 error=Copilot token exchange failed (404): {"message":"Not Found","documentation_url":"https://docs.github.com/rest","status":"404"} stack=Error: Copilot token exchange failed (404): {"message":"Not Found","documentation_url":"https://docs.github.com/rest","status":"404"}
        at <anonymous> (/Users/u132515/.cache/opencode/packages/opencode-copilot-enhanced@latest/node_modules/opencode-copilot-enhanced/dist/index.js:59:19)
        at processTicksAndRejections (native:7:39) process
    

    I installed copilot enhanced plugin and now error is more visible rather than 400-Bad request

    Image
  25. Kjaer commented on Jun 11, 2026

    @Kjaer

    I just tried using Gemini models with Crush(https://github.com/charmbracelet/crush) and it's working there.

    Image

    Can we say, something broken in opencode?


    I am using 2 MCP: public-browser, engram

  26. Kjaer commented on Jun 16, 2026

    @Kjaer

    Gemini models started to working. I just tried Gemini 3.1. pro and it worked. I wanted to let you know. Since my last message i didn't change anything.

  27. github-actions commented on Aug 16, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions