yetone / avante.nvim

Use your Neovim like using Cursor AI IDE!
Apache License 2.0
6.28k stars 230 forks source link

bug: "API request failed with status 400" when using auto suggestions with Copilot provider #697

Open famiu opened 1 week ago

famiu commented 1 week ago

Describe the bug

When trying to use auto_suggestions with the Copilot provider in a large C file, I get the following errors:

API request failed with status 400
Error while suggesting: "API request failed with status 400. Body: '{\"error\":{\"message\":\"prompt token count of 82225 exceeds the limit of 20000\",\"param\":\"\",\"code\":\"\",\"type\":\"\"}}'"
Error while suggesting: "API request failed with status 400. Body: '{\"error\":{\"message\":\"prompt token count of 82226 exceeds the limit of 20000\",\"param\":\"\",\"code\":\"\",\"type\":\"\"}}'"

To reproduce

  1. Use Avante with Copilot provider and with auto-suggestions on
  2. Edit a large file
  3. Type stuff to trigger a Copilot auto suggestion
  4. See error message

Expected behavior

No error message, Copilot shows suggestions.

Installation method

{
    'yetone/avante.nvim',
    build = require('utilities.os').is_windows()
            and 'powershell -ExecutionPolicy Bypass -File Build -BuildFromSource false'
        or 'make',
    opts = {
        provider = 'copilot',
        auto_suggestions_provider = 'copilot',
        behaviour = {
            auto_suggestions = true,
        },
    },
    dependencies = {
        'nvim-treesitter/nvim-treesitter',
        'stevearc/dressing.nvim',
        'nvim-lua/plenary.nvim',
        'MunifTanjim/nui.nvim',
        'nvim-tree/nvim-web-devicons',
        { 'zbirenbaum/copilot.lua', opts = {} }, -- for providers='copilot'
    },
}

Environment

Neovim version: NVIM v0.11.0-dev-932+g7737f89206 OS: Fedora Linux 41 Beta

Repro

vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()

require("lazy.minit").repro({
  spec = {
    {
        'yetone/avante.nvim',
        build = require('utilities.os').is_windows()
                and 'powershell -ExecutionPolicy Bypass -File Build -BuildFromSource false'
            or 'make',
        opts = {
            provider = 'copilot',
            auto_suggestions_provider = 'copilot',
            behaviour = {
                auto_suggestions = true,
            },
        },
        dependencies = {
            'nvim-treesitter/nvim-treesitter',
            'stevearc/dressing.nvim',
            'nvim-lua/plenary.nvim',
            'MunifTanjim/nui.nvim',
            'nvim-tree/nvim-web-devicons',
            { 'zbirenbaum/copilot.lua', opts = {} }, -- for providers='copilot'
        },
    },
  },
})
leoatchina commented 1 week ago

This bug usually happend after you keep avante.nvim idol a long time.

famiu commented 1 week ago

This bug usually happend after you keep avante.nvim idol a long time.

Nope, happens with me right away even if I use avante.nvim right after starting Neovim