Skip to content

GitHub Copilot auto-approve not recognizing commands because of CLI option order. #281779

Closed

Description

I have GitHub Copilot configured in Agent mode to accept a lot of Bash commands such as mvn compile. When it runs into a new one, it usually asks me if I want to auto-approve the command, such as mvn foobar.

Just now Claude Haiku 4.5 wanted to run this command:

cd /…/globalmentor/globalmentor-base && mvn -DskipIT test -q && echo "✓ All tests passed"

It didn't auto-approve. Worse, it didn't even give me the option to auto-approve in the future.

Expectation A: The command should have run automatically.

Expectation A: If there was a command it hadn't seen before, a button with "Approve", with a choice to "Always allow mvn test in the future" (or echo or whatever command it is that it was seeing for the first time).

Actual: The default button said "Allow", but the choices were "Always Allow Exact Command Line" and "Configure Auto Approve".

Note that there were no commands it hasn't seen. mvn test is already approved in settings.json. I don't think cd and echo need approval.

Was that the problem? Do I need to add cd and echo to settings.json? But I don't think that's the problem; I never have to approve cd and echo.

My hunch is that the real problem here is that the GitHub Copilot Bash command parser is really basic and naive, and only recognizes the form mvn test -DskipIT. If it sees a CLI parameter before the subcommand, such as mvn -DskipIT test, it doesn't know what to do, and doesn't even know what command to suggest for auto-approval.

If that is the issue, GitHub Copilot needs to improve the CLI parser to normalize the command requested. This should be straightforward, as CLIs have become pretty standardized and there are even CLI guidelines for example.

Version: 1.106.3 (user setup)
Commit: bf9252a2fb45be6893dd8870c0bf37e2e1766d61
Date: 2025-11-25T22:28:18.024Z
Electron: 37.7.0
ElectronBuildId: 12781156
Chromium: 138.0.7204.251
Node.js: 22.20.0
V8: 13.8.258.32-electron.0
OS: Windows_NT x64 10.0.26200

Activity

  1. added
    chat-ext-issue
    on Dec 7, 2025
  2. removed
    chat-ext-issue
    on Dec 7, 2025
  3. garretwilson commented on Dec 7, 2025

    @garretwilson
    Author

    My hunch was correct. I coaxed the LLM to produce this equivalent command:

    cd /…/globalmentor/globalmentor-base && mvn test -DskipIT -q && echo "✓ All tests passed"

    GitHub Copilot correctly realized that mvn test had been approved, and so auto-approved the entire command line—even though it was equivalent to the one in this ticket's description, which it did not auto-approve.

    As a workaround I am going to add the following to my prompt instructions:

    Submit CLI commands in normalized form in which the commands and subcommands come before parameters, flage, and options, e.g. mvn test -DskipIT … instead of mvn -DskipIT test ….

    But that is only a workaround until this is fixed. My instructions are already getting bloated. After all, I even have to add instructions to try to work around #274234, which still isn't fixed:

    When running terminal commands, you might notice that a command you request has its first character missing when actually invoked in the terminal, and thus fails. This is an open VS Code bug; to work around it merely repeat the request for the same tool, and it should work on the second try.

    Pretty soon a big chunk of my prompt instructions will just be to try to get the LLM to tiptoe through the VS Code bug minefield! (Still no way to tiptoe around #272987 unfortunately.)

  4. Tyriar commented on Dec 10, 2025

    @Tyriar
    Contributor

    It didn't auto-approve. Worse, it didn't even give me the option to auto-approve in the future.

    My hunch is that the real problem here is that the GitHub Copilot Bash command parser is really basic and naive, and only recognizes the form mvn test -DskipIT. If it sees a CLI parameter before the subcommand, such as mvn -DskipIT test, it doesn't know what to do, and doesn't even know what command to suggest for auto-approval.

    Close, mvn is one of the handful of commands where we suggest subcommands for instead:

    // Commands where we want to suggest the sub-command (eg. `foo bar` instead of `foo`)
    const commandsWithSubcommands = new Set(['git', 'npm', 'npx', 'yarn', 'docker', 'kubectl', 'cargo', 'dotnet', 'mvn', 'gradle']);

    So you're hitting that case and then it's not getting the rules due to this:

    if (commandsWithSubSubCommands.has(baseSubCommand)) {
    if (parts.length >= 3 && !parts[2].startsWith('-')) {
    return `${parts[0]} ${parts[1]} ${parts[2]}`;
    }
    return undefined;
    } else if (commandsWithSubcommands.has(baseCommand)) {
    if (parts.length >= 2 && !parts[1].startsWith('-')) {
    return `${parts[0]} ${parts[1]}`;
    }
    return undefined;
    } else {
    return parts[0];
    }

    The parser was naive before 1.106 but now it uses the bash tree sitter grammar which is so much more capable.

    My normal recommendation would be to either add one of these rules

    {
      "mvn -DskipIT test": true,
      "/^mvn \\-[a-zA-Z]+ test/": true // ⚠️ if you want to approve any flag
    }

    But I'm thinking we can support this case where we look for a single argument between the command and the sub-command and end up suggesting allowing mvn -DskipIT test as a future rule.

  5. added
    bug
    chat-terminal
    on Dec 10, 2025
  6. garretwilson commented on Dec 10, 2025

    @garretwilson
    Author

    But I'm thinking we can support this case where we look for a single argument between the command and the sub-command and end up suggesting allowing mvn -DskipIT test as a future rule.

    As a developer, I think that smells of a lot of special casing that is brittle and hard to maintain. (After all sometimes it may want to use -DskipTests or -Dfoo=bar or something arbitrary.) That's not the way I would do it.

    I would back the logic up into your parsing routine. If your bash-tree-whatever library doesn't do any normalization, and can't figure out that mvn -DskipIT test really should be mvn test -DskipIT, then I would augment the parsing with "hints" These hints would be similar to your existing commandsWithSubcommands, but it would actually be a tree of known commands and subcommands and their subcommands for git, mvn, etc.

    Then, right before or after or during you use this bash-tree parser thing (I would have to look at the API to see how it fits), you run a algorithm on the knownCommandsTree that does a normalization on the command line. It could be very simple: "shift every token starting with - right until it is past the subcommand, from right to left" or something like that. For example it would change knownCommand --foo knownSubCommand -bar knownSubSubCommand to knownCommand knownSubCommand knownSubSubCommand --foo -bar. That would be much more flexible, much more maintainable, and better address the problem directly rather than several effects removed of trying to add tape and safety pins later down the line in the processing.

    In my case the following prompt instruction seems to be working:

    Submit CLI commands in normalized form in which the commands and subcommands come before parameters, flags, and options, e.g. mvn test -DskipIT … instead of mvn -DskipIT test ….

    But my instructions are starting to get big, especially when some of them are just there to work around GitHub Copilot bugs.

  7. Tyriar commented on Dec 10, 2025

    @Tyriar
    Contributor

    If your bash-tree-whatever library doesn't do any normalization, and can't figure out that mvn -DskipIT test really should be mvn test -DskipIT

    This would be nice, but the problem is this is a maven thing; not all CLIs work like that so we can't normalize across the board. It often works like this cmd -cmd-only-flags subcmd -subcmd-only-flags. A concrete example is git --no-pager log works but git log --no-pager does not. I also wanted to keep the CLI-specific logic to an absolute minimum as it's a pain to maintain and I I'm not an expert in everything (I personally have touched maven, but barely and not for 8 years or so?). I'm also not even sure if this normalization you're suggestion is valid for mvn itself or just a sub-set of flags. We need to be absolutely certain the commands are equivalent when we mess with what the agent wants to run or we're going to have much bigger problems than needing to manually configure an auto approve rule.

    But my instructions are starting to get big, especially when some of them are just there to work around GitHub Copilot bugs.

    I wouldn't call this a bug though as above. The auto approve dropdown isn't meant to always be exactly what the user will want but a starting point, from there they can go into settings and tweak as appropriate.

  8. added
    unreleased
    insiders-released
    and removed
    unreleased
    on Jan 2, 2026
  9. amunger commented on Jan 7, 2026

    @amunger
    Collaborator

    Daniel Imms (@Tyriar) it's not clear what behavior changed to be verified here

  10. added
    verification-steps-needed
    and removed
    verified
    on Jan 7, 2026
  11. Tyriar commented on Jan 8, 2026

    @Tyriar
    Contributor

    Verification is the args show up here:

    Image
  12. added
    verified
    and removed
    verification-steps-needed
    chat-terminal
    on Jan 8, 2026
  13. garretwilson commented on Jan 26, 2026

    @garretwilson
    Author

    I'm still getting a prompt for:

    cd /c/projects/foo && mvn -pl foo-bar test -q

    I'll try to add to the instructions, but they are getting pretty large.

  14. locked and limited conversation to collaborators on Feb 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

buginsiders-releasedverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions