×

注意!页面内容来自https://docs.github.com/en/copilot/concepts/agents/copilot-cli/autopilot,本站不储存任何内容,为了更好的阅读体验进行在线解析,若有广告出现,请及时反馈。若您觉得侵犯了您的利益,请通知我们进行删除,然后访问 原网页

Skip to main content

Allowing GitHub Copilot CLI to work autonomously

The CLI's autopilot mode lets Copilot CLI work autonomously on a taskcarrying out multiple steps until the task is complete.

Overview

Typicallywhen you use Copilot CLI interactivelyyou submit a prompt and then wait for Copilot CLI to respond before giving the next instruction. This back-and-forth interaction continues until the task is done.

Autopilot mode allows Copilot CLI to work through a task without waiting for your input after each step. Once you give the initial instructionCopilot CLI works through each step autonomously until it determines the task is complete.

The difference between the CLI's standard interactive mode and autopilot mode is like the difference between working on a task with a coworkerwhere they do most of the workbut check back with you periodicallyversus handing the task over to your colleaguesaying "Here's what I need—let me know when you're finished."

In autopilot modeCopilot keeps on going until one of these happens:

  • The agent determines that the task is complete.
  • A problem occurs that prevents further progress.
  • You press Ctrl+C to stop the agent from continuing.
  • The maximum continuation limit is reached (if set).

To switch into autopilot mode during an interactive sessionpress Shift+Tab and cycle through the available modes until you reach autopilot modethen enter your prompt. Use the same keypress to switch from autopilot mode back to the standard interactive mode.

Benefits of autopilot mode

  • Hands-off automation: Copilot completes tasks without needing your input after the initial instruction.
  • Efficiency: Ideal for well-defined tasks like writing testsrefactoring filesor fixing CI failures. Autopilot is particularly suited for large tasks that require long-runningmulti-step sessions.
  • Batch operations: Useful for scripting and CI workflows where you want Copilot to run to completion.
  • Safety: Autopilot mode allows Copilot to take multiple self-directed steps to finish your task. --max-autopilot-continues limits how many steps it can take before stoppingto avoid infinite loops. Alsoin autopilot modeCopilot cannot carry out any actions that require permission unless you explicitly grant it full permissions.

Things to consider

  • Task suitability: Autopilot mode is best for well-defined tasks. It is not ideal for open-ended explorationfeature development without a clear goalor tasks where you want to guide the ongoing work.

    Copilot will do its best to complete any taskbut it may struggle with vague or ambiguous instructions or tasks that require nuanced judgment calls along the way. This may result in a set of code changes that aren't what you expected and can't be used without remedial work.

  • Trust: You need to trust Copilot to make reasonable decisions. Autopilot mode works best when you grant it approval for all permissions. This is equivalent to running Copilot CLI with the --allow-all option. You should be aware that this gives the CLI permission to make any changes it deems necessary to complete the taskincluding altering and deleting files.

  • Cost: Autopilot mode uses premium requests in the same way that these are used when you are working in the standard interactive interface. In the standard modeone premium request is used when you submit your initial promptand then an additional premium request is used each time you reply to a question in the CLI and the agent uses your response to interact with the AI model. The same applies in autopilot modeexcept that you are not involved in initiating the next stepso the use of additional premium requests happens without your direct involvement.

    The billable premium request usage is determined using a multiplier. The multiplier varies depending on which model you use. Use the /model slash command to see the currently selected model and its multiplierand change the model if required. For more informationsee Requests in GitHub Copilot and About billing for individual GitHub Copilot plans.

    Each time the agent continues autonomously it will display a message in the CLI telling you how many premium requests have been used by that continuation step—taking account of the model multiplier—for example: Continuing autonomously (3 premium requests).

Permissions

When entering autopilot modeif you have not already granted Copilot all permissionsa message is displayed prompting you to choose between three options:

1. Enable all permissions (recommended)
2. Continue with limited permissions
3. Cancel (Esc)

You will get the best results from autopilot mode if you enable all permissions. If you choose to continue with limited permissionsCopilot will automatically deny any tool requests that require approvalwhich may prevent it from completing certain tasks. You can change your mind later and grant full permissionsduring an autopilot sessionby using the /allow-all command (or its alias /yolo).

Comparing autopilot mode--allow-alland --no-ask-user

--allow-alland its alias --yoloare permissions-related options that you can pass to the copilot command when you start an interactive session. For a full list of available optionssee GitHub Copilot CLI command reference.

The --allow-all and --yolo options allow the CLI agent to use all toolspathsand URLs. You can also set these permissions during an interactive sessionby using the /allow-all or /yolo slash commands.

Note

Entering /allow-all and /yolo enables permissions for the current session. Entering these slash commands again does not disable permissions—in other wordsthese commands don't toggle permissions on and off.

With --allow-allyou are still in the normal interactive flow. Copilot will still stop and ask you what you want it to do when it reaches a decision point. Howeverwhen Copilot CLI needs to do something that would normally require approvalsuch as using toolspathsor URLsit will go ahead without asking for permission.

The --no-ask-user option suppresses clarifying questions that Copilot would normally ask. Instead the agent must make decisions on its ownrather than asking for your input. This provides a degree of autonomy. Howeverunlike autopilot mode--no-ask-user does not allow the agent to continue working on a task through successive steps where interaction with the AI model is required. With this optionthe CLI won't use additional premium requestsafter your initial promptwithout your involvement.

Typical workflow for using autopilot mode

Autopilot mode is ideal for implementing a largedetailed plan of work. Often you will find it useful to switch to autopilot mode after working with Copilot in plan mode to create an implementation plan. For more information about plan modesee Best practices for GitHub Copilot CLI.

For example:

  • Start an interactive Copilot CLI session.

    Optionallyyou can include the --allow-all option to grant permissionsand the --max-autopilot-continues option to set a maximum continuation limit for autopilot mode during the session. For exampleyou could start the session with copilot --allow-all --max-autopilot-continues 10 to give the agent permission to use all toolspathsand URLsand set a maximum continuation limit for autopilot to 10.

  • When the interactive session startsif you're prompted to trust the files in the current folderaccept this option.

  • Press Shift+Tab to switch to plan modeenter a prompt describing what you want to achievethen work with Copilot to create a detailed plan.

  • Once you have a plan that you are happy withuse the option that the CLI presents to "Accept plan and build on autopilot".

  • If you're prompted about permissionschoose the option to enable all permissions.

  • Leave Copilot to implement the plan. You can check in on its progress periodically.

Using autopilot mode programmatically

You can use autopilot mode when you run Copilot CLI programmaticallyfor example when you pass Copilot a prompt on the command lineor when you use the CLI as part of a script or CI workflow. Doing so allows you to automate tasks end-to-end without needing to interact with the CLI after the initial command.

Use the --allow-all (or --yolo) option to grant Copilot permission to use all toolspathsand URLs. You can include the --max-autopilot-continues option to set a maximum continuation limit to prevent runaway loops. This is especially important in programmatic contexts where you won't be there to intervene if something goes wrong.

Example usage:

copilot --autopilot --yolo --max-autopilot-continues 10 -p "YOUR PROMPT HERE"

Summary

Use autopilot mode when you want Copilot to take over a task and work to completion without your involvement. It's best for clearwell-defined tasks where you trust Copilot to make reasonable decisions.

Further reading