You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
GitHub Copilot auto-approve not recognizing commands because of CLI option order. #281779
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.
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.)
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:
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.
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.
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.
Activity
garretwilson commentedon Dec 7, 2025
My hunch was correct. I coaxed the LLM to produce this equivalent command:
GitHub Copilot correctly realized that
mvn testhad 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:
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:
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.)
Tyriar commentedon Dec 10, 2025
Close,
mvnis one of the handful of commands where we suggest subcommands for instead:vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/runInTerminalHelpers.ts
Lines 101 to 102 in 26b983f
So you're hitting that case and then it's not getting the rules due to this:
vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/runInTerminalHelpers.ts
Lines 121 to 133 in 26b983f
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 testas a future rule.garretwilson commentedon Dec 10, 2025
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
-DskipTestsor-Dfoo=baror 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 testreally should bemvn test -DskipIT, then I would augment the parsing with "hints" These hints would be similar to your existingcommandsWithSubcommands, but it would actually be a tree of known commands and subcommands and their subcommands forgit,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
knownCommandsTreethat 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 changeknownCommand --foo knownSubCommand -bar knownSubSubCommandtoknownCommand 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:
But my instructions are starting to get big, especially when some of them are just there to work around GitHub Copilot bugs.
Tyriar commentedon Dec 10, 2025
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 isgit --no-pager logworks butgit log --no-pagerdoes 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 formvnitself 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.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.
amunger commentedon Jan 7, 2026
Daniel Imms (@Tyriar) it's not clear what behavior changed to be verified here
Tyriar commentedon Jan 8, 2026
Verification is the args show up here:
garretwilson commentedon Jan 26, 2026
I'm still getting a prompt for:
I'll try to add to the instructions, but they are getting pretty large.