|
| 1 | +[← Back to Module Overview](README.md) | [Next: Custom Instructions and Code Review →](2-Instructions-and-Review.md) |
| 2 | + |
| 3 | +# Assigning Tasks and Tracking Agent Sessions |
| 4 | + |
| 5 | +## 🗒️ Part 1: Assigning Tasks to GitHub Copilot Coding Agent |
| 6 | + |
| 7 | +### 🎯 Learning Goals |
| 8 | + |
| 9 | +- Understand how the coding agent differs from IDE agent mode. |
| 10 | +- Assign a GitHub Issue to Copilot coding agent. |
| 11 | +- Trigger Copilot coding agent from multiple surfaces: issues, pull request comments, and the agents panel. |
| 12 | + |
| 13 | +### What is the Copilot Coding Agent? |
| 14 | + |
| 15 | +The **GitHub Copilot coding agent** works autonomously in the background using a GitHub Actions-powered ephemeral development environment. When you give it a task, it: |
| 16 | + |
| 17 | +1. Reads your codebase and issue context. |
| 18 | +2. Creates a `copilot/` branch. |
| 19 | +3. Writes code, runs your tests and linters, and iterates on errors. |
| 20 | +4. Opens a pull request and requests your review. |
| 21 | + |
| 22 | +This is distinct from **agent mode in your IDE**, which edits your local files interactively. The coding agent is fully asynchronous — you can close your laptop while it works. |
| 23 | + |
| 24 | +### Exercise 1A: Assign an Issue to Copilot |
| 25 | + |
| 26 | +1. Navigate to your repository's **Issues** tab on GitHub.com. |
| 27 | +2. Create a new issue with a clear, well-scoped description. For example: |
| 28 | + |
| 29 | + ``` |
| 30 | + Title: Add the ability to delete a recipe |
| 31 | +
|
| 32 | + Description: |
| 33 | + Users should be able to delete a recipe from the recipe list. |
| 34 | + - Add a DELETE /recipes/:id endpoint in src/routes.js |
| 35 | + - Remove the recipe row from the SQLite database |
| 36 | + - Add a "Delete" button to the recipe detail view |
| 37 | + - Write a test that confirms a deleted recipe returns 404 |
| 38 | + ``` |
| 39 | + |
| 40 | +3. On the issue page, click **Assignees** and select **Copilot** from the assignee list. |
| 41 | + |
| 42 | + > Copilot will begin working immediately. You'll see the issue label update to indicate an agent session is in progress. |
| 43 | +
|
| 44 | +4. Observe that Copilot creates a new branch named `copilot/<issue-number>-<slug>` and begins opening commits. |
| 45 | + |
| 46 | +### Exercise 1B: Trigger Copilot from a Pull Request Comment |
| 47 | + |
| 48 | +You can also invoke the coding agent on an *existing pull request* by mentioning `@copilot` in a PR comment. |
| 49 | + |
| 50 | +1. Open any open pull request in your repository. |
| 51 | +2. In a comment, type a specific request, for example: |
| 52 | + |
| 53 | + ``` |
| 54 | + @copilot Please add input validation to the recipe creation form |
| 55 | + and return a 400 status code with an error message if the title field is empty. |
| 56 | + ``` |
| 57 | + |
| 58 | +3. Copilot will respond in the PR thread, then push additional commits to address your request. |
| 59 | + |
| 60 | +### Exercise 1C: Trigger Copilot from the Agents Panel |
| 61 | + |
| 62 | +The **agents panel** is available on every page on GitHub.com. |
| 63 | + |
| 64 | +1. Click the agent icon (looks like a hexagon/robot) in the top navigation bar on any GitHub page. |
| 65 | +2. Click **New task**. |
| 66 | +3. Select your repository and describe the work you want done. |
| 67 | +4. Submit the task. Copilot will open a new pull request with the changes. |
| 68 | + |
| 69 | +In the above exercises we achieved the following: |
| 70 | +- ✅ Assigned a GitHub issue to the coding agent |
| 71 | +- ✅ Invoked the agent via a PR comment using `@copilot` |
| 72 | +- ✅ Started a new coding agent task from the agents panel |
| 73 | + |
| 74 | +--- |
| 75 | + |
| 76 | +## 🗒️ Part 2: Tracking and Steering Agent Sessions |
| 77 | + |
| 78 | +### 🎯 Learning Goals |
| 79 | + |
| 80 | +- Track the progress of Copilot's work across multiple surfaces. |
| 81 | +- Read and interpret session logs. |
| 82 | +- Steer Copilot mid-session when you want to redirect its approach. |
| 83 | +- Stop a session that has gone off-track. |
| 84 | + |
| 85 | +### The Agents Tab |
| 86 | + |
| 87 | +1. Open the [agents tab](https://github.com/copilot/agents) by clicking the agent icon in the GitHub navigation bar, then selecting **View all**. |
| 88 | +2. You'll see a list of all your running and past agent sessions. |
| 89 | +3. Click on a session to open the **session log and overview**, which shows: |
| 90 | + - Session status (running, completed, stopped) |
| 91 | + - Token usage and session duration |
| 92 | + - A step-by-step internal log showing how Copilot approached your task |
| 93 | + |
| 94 | +### Reading Session Logs |
| 95 | + |
| 96 | +Session logs show Copilot's internal reasoning and tool usage. You can see: |
| 97 | + |
| 98 | +- Which files Copilot read to understand the codebase. |
| 99 | +- What commands it ran (e.g., test runners, linters). |
| 100 | +- How it iterated to fix errors before pushing. |
| 101 | +- Which security checks it performed (CodeQL, secret scanning, dependency vulnerability checks). |
| 102 | + |
| 103 | +> **Tip:** Session logs are also accessible from Visual Studio Code via the GitHub Pull Requests extension. Click on a pull request in the Copilot sessions list, then click **View Session**. |
| 104 | +
|
| 105 | +### Exercise 2A: Steer a Running Session |
| 106 | + |
| 107 | +While Copilot is working, you can give it additional guidance from the agents tab: |
| 108 | + |
| 109 | +1. Open the [agents tab](https://github.com/copilot/agents) and select an **in-progress** session. |
| 110 | +2. Type a steering message in the prompt box, for example: |
| 111 | + |
| 112 | + ``` |
| 113 | + Use our existing ErrorHandler utility instead of writing custom |
| 114 | + try-catch blocks for the new endpoints. |
| 115 | + ``` |
| 116 | + |
| 117 | +3. Submit the message. Copilot will incorporate your guidance after finishing its current tool call. |
| 118 | + |
| 119 | +> **Note:** Steering consumes one premium request per message. |
| 120 | +
|
| 121 | +### Exercise 2B: Stop a Session |
| 122 | + |
| 123 | +If Copilot is going in a wrong direction or you have changed your mind about a task: |
| 124 | + |
| 125 | +1. Open the session log viewer from the agents tab. |
| 126 | +2. Click **Stop session**. |
| 127 | + |
| 128 | +The agent stops immediately. The branch and any commits made so far are preserved, so you can inspect them. |
| 129 | + |
| 130 | +### Tracking Across Other Surfaces |
| 131 | + |
| 132 | +| Surface | How to access | |
| 133 | +|---|---| |
| 134 | +| **GitHub CLI** | `gh agent-task list` / `gh agent-task view --repo owner/repo <pr-number>` (requires CLI v2.80.0+) | |
| 135 | +| **VS Code** | GitHub Pull Requests extension → Copilot sessions list in the sidebar | |
| 136 | +| **JetBrains IDEs** | GitHub Copilot Chat extension → **GitHub Coding Agent Jobs** button (public preview) | |
| 137 | +| **Eclipse** | GitHub Copilot Chat extension → agent icon in chat window (public preview) | |
| 138 | +| **GitHub Mobile** | Home page → Agents section → **Agent Tasks** | |
| 139 | +| **Raycast** | GitHub Copilot extension for Raycast → **View Tasks** command | |
| 140 | + |
| 141 | +In the above exercises we achieved the following: |
| 142 | +- ✅ Navigated the agents tab to track sessions |
| 143 | +- ✅ Read and interpreted a Copilot session log |
| 144 | +- ✅ Steered a running session with additional guidance |
| 145 | +- ✅ Stopped an off-track session |
| 146 | + |
| 147 | +--- |
| 148 | + |
| 149 | +[← Back to Module Overview](README.md) | [Next: Custom Instructions and Code Review →](2-Instructions-and-Review.md) |
0 commit comments