|
| 1 | +--- |
| 2 | +title: Customizing the development environment for Copilot coding agent |
| 3 | +shortTitle: Customize the agent environment |
| 4 | +intro: "Learn how to customize {% data variables.product.prodname_copilot %}'s development environment with additional tools." |
| 5 | +versions: |
| 6 | + feature: copilot |
| 7 | +topics: |
| 8 | + - Copilot |
| 9 | +type: how_to |
| 10 | +--- |
| 11 | + |
| 12 | +> [!NOTE] |
| 13 | +> {% data reusables.copilot.coding-agent.preview-note-text %} |
| 14 | +> |
| 15 | +> For more information about {% data variables.copilot.copilot_coding_agent %}, see [AUTOTITLE](/copilot/using-github-copilot/using-copilot-coding-agent-to-work-on-tasks/about-assigning-tasks-to-copilot). |
| 16 | +
|
| 17 | +## About customizing {% data variables.copilot.copilot_coding_agent %}'s development environment |
| 18 | + |
| 19 | +While working on a task, {% data variables.product.prodname_copilot_short %} has access to its own ephemeral development environment, powered by {% data variables.product.prodname_actions %}, where it can explore your code, make changes, execute automated tests and linters and more. |
| 20 | + |
| 21 | +You can customize {% data variables.product.prodname_copilot_short %}'s environment by: |
| 22 | + |
| 23 | +* [Preinstalling tools or dependencies in {% data variables.product.prodname_copilot_short %}'s environment](#preinstalling-tools-or-dependencies-in-copilots-environment). |
| 24 | +* [Upgrading from standard {% data variables.product.prodname_dotcom %}-hosted {% data variables.product.prodname_actions %} runners to larger runners](#upgrading-to-larger-github-hosted-github-actions-runners). |
| 25 | +* [Disabling or customizing the agent's firewall](/copilot/customizing-copilot/customizing-or-disabling-the-firewall-for-copilot-coding-agent). |
| 26 | + |
| 27 | +## Preinstalling tools or dependencies in {% data variables.product.prodname_copilot_short %}'s environment |
| 28 | + |
| 29 | +In its ephemeral development environment, {% data variables.product.prodname_copilot_short %} can build or compile your project and run automated tests, linters and other tools. To do this, it will need to install your project's dependencies. |
| 30 | + |
| 31 | +{% data variables.product.prodname_copilot_short %} can discover and install these dependencies itself via a process of trial and error, but this can be slow and unreliable, given the non-deterministic nature of large language models (LLMs), and in some cases, it may be completely unable to download these dependencies—for example, if they are private. |
| 32 | + |
| 33 | +Instead, you can preconfigure {% data variables.product.prodname_copilot_short %}'s environment before the agent starts by creating a special {% data variables.product.prodname_actions %} workflow file, located at `.github/workflows/copilot-setup-steps.yml` within your repository. |
| 34 | + |
| 35 | +A `copilot-setup-steps.yml` file looks like a normal {% data variables.product.prodname_actions %} workflow file, but must contain a single `copilot-setup-steps` job. This job will be executed in {% data variables.product.prodname_actions %} before {% data variables.product.prodname_copilot_short %} starts working. For more information on {% data variables.product.prodname_actions %} workflow files, see [AUTOTITLE](/actions/using-workflows/workflow-syntax-for-github-actions). |
| 36 | + |
| 37 | +Here is a simple example of a `copilot-setup-steps.yml` file for a TypeScript project that clones the project, installs Node.js and downloads and caches the project's dependencies. You should customize this to fit your own project's language(s) and dependencies: |
| 38 | + |
| 39 | +```yaml copy |
| 40 | +name: "Copilot Setup Steps" |
| 41 | + |
| 42 | +# Allow testing of the setup steps from your repository's "Actions" tab. |
| 43 | +on: workflow_dispatch |
| 44 | + |
| 45 | +jobs: |
| 46 | + # The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot. |
| 47 | + copilot-setup-steps: |
| 48 | + runs-on: ubuntu-latest |
| 49 | + |
| 50 | + # Set the permissions to the lowest permissions possible needed for your steps. |
| 51 | + # Copilot will be given its own token for its operations. |
| 52 | + permissions: |
| 53 | + # If you want to clone the repository as part of your setup steps, for example to install dependencies, you'll need the `contents: read` permission. If you don't clone the repository in your setup steps, Copilot will do this for you automatically after the steps complete. |
| 54 | + contents: read |
| 55 | + |
| 56 | + # You can define any steps you want, and they will run before the agent starts. |
| 57 | + # If you do not check out your code, Copilot will do this for you. |
| 58 | + steps: |
| 59 | + - name: Checkout code |
| 60 | + uses: {% data reusables.actions.action-checkout %} |
| 61 | + |
| 62 | + - name: Set up Node.js |
| 63 | + uses: {% data reusables.actions.action-setup-node %} |
| 64 | + with: |
| 65 | + node-version: "20" |
| 66 | + cache: "npm" |
| 67 | + |
| 68 | + - name: Install JavaScript dependencies |
| 69 | + run: npm ci |
| 70 | +``` |
| 71 | +
|
| 72 | +In your `copilot-setup-steps.yml` file, you can only customize the following settings of the `copilot-setup-steps` job. If you try to customize other settings, your changes will be ignored. |
| 73 | + |
| 74 | +* `steps` (see above) |
| 75 | +* `permissions` (see above) |
| 76 | +* `runs-on` (see below) |
| 77 | +* `container ` |
| 78 | +* `services` |
| 79 | +* `snapshot` |
| 80 | +* `timeout-minutes` (maximum value: `59`) |
| 81 | + |
| 82 | +For more information on these options, see [AUTOTITLE](/actions/writing-workflows/workflow-syntax-for-github-actions#jobs). |
| 83 | + |
| 84 | +Once you have created a `copilot-setup-steps.yml` file and merged it into your default branch, you can manually run the workflow from the repository's **Actions** tab to check that it works. For more information, see [AUTOTITLE](/actions/managing-workflow-runs-and-deployments/managing-workflow-runs/manually-running-a-workflow). |
| 85 | + |
| 86 | +## Upgrading to larger {% data variables.product.prodname_dotcom %}-hosted {% data variables.product.prodname_actions %} runners |
| 87 | + |
| 88 | +By default, {% data variables.product.prodname_copilot_short %} works in a standard {% data variables.product.prodname_actions %} runner with limited resources. |
| 89 | + |
| 90 | +You can choose instead to use larger runners with more advanced features—for example more RAM, CPU and disk space and advanced networking controls. You may want to upgrade to a larger runner if you see poor performance—for example when downloading dependencies or running tests. For more information, see [AUTOTITLE](/actions/using-github-hosted-runners/using-larger-runners/about-larger-runners). |
| 91 | + |
| 92 | +Before {% data variables.product.prodname_copilot_short %} can use larger runners, you must first add one or more larger runners and then configure your repository to use them. See [AUTOTITLE](/actions/using-github-hosted-runners/managing-larger-runners). Once you have done this, you can use the `copilot-setup-steps.yml` file to tell {% data variables.product.prodname_copilot_short %} to use the larger runners. |
| 93 | + |
| 94 | +To use larger runners, set the `runs-on` step of the `copilot-setup-steps` job to the label and/or group for the larger runners you want {% data variables.product.prodname_copilot_short %} to use. For more information on specifying larger runners with `runs-on`, see [AUTOTITLE](/actions/using-github-hosted-runners/running-jobs-on-larger-runners). |
| 95 | + |
| 96 | +```yaml |
| 97 | +# ... |
| 98 | +
|
| 99 | +jobs: |
| 100 | + copilot-setup-steps: |
| 101 | + runs-on: ubuntu-4-core |
| 102 | + # ... |
| 103 | +``` |
| 104 | + |
| 105 | +> [!NOTE] |
| 106 | +> * {% data variables.copilot.copilot_coding_agent %} is only compatible with Ubuntu x86 Linux runners. Runners with Windows, macOS or other operating systems are not supported. |
| 107 | +> * Self-hosted {% data variables.product.prodname_actions %} runners are not supported. |
| 108 | + |
| 109 | +## Further reading |
| 110 | + |
| 111 | +* [AUTOTITLE](/copilot/customizing-copilot/customizing-or-disabling-the-firewall-for-copilot-coding-agent) |
0 commit comments