Agents

Agents

In this lesson, you’ll learn how to use GitHub Copilot Agents — your AI teammate that can actually write, commit, and iterate on code for you.

You’ll see how to start an agent session, give it clear instructions, review its pull requests, and request changes, all from within GitHub. By the end, you’ll understand how Agents bridge the gap between planning and production—helping you move from idea to working code safely and efficiently, without leaving the browser.

Problem

Copilot Chat and Spaces help you reason about your code and plan changes, but they still rely on you to do the actual editing. That means switching tools, setting up environments, and manually implementing what you discussed.

Copilot Agents solve this by taking action directly in your repository — creating branches, opening pull requests, and updating code based on your feedback. Instead of copying ideas from chat into your editor, you can delegate the work itself. Agents let you stay focused on reviewing, testing, and guiding — while Copilot handles the mechanics of coding, iteration, and cleanup right in GitHub.

What you need to know

Agents run as special Copilot instances that:

  • Work inside a specific repository and branch.

  • Accept your requests in a chat-style interface.

  • Create a pull request (PR) and open a work session where Copilot performs the changes.

  • Commit updates into that PR until the work is complete.

  • Allow you to review, test, and request further changes — all from GitHub.

With agents, Copilot becomes a true pair programmer that writes code, submits it, and iterates on your feedback.

Think of an agent as a junior developer who never gets tired, always follows your instructions, and works inside your existing GitHub workflows. You tell it what to do, review its PRs, and give feedback right in the comments. It responds with new commits until the job’s done.

Agents are especially powerful for:

  • Rapid prototyping: Ask Copilot to add new pages, endpoints, or utilities and see a working implementation in minutes.

  • Code cleanup and modernization: Have it refactor old patterns, improve typing, or migrate dependencies safely in an isolated branch.

  • Automated maintenance: Assign it issues to handle small fixes, style updates, or doc changes that would otherwise eat up your team’s time.

Ultimately, Agents bridge the gap between planning and production. You can brainstorm and strategize in Copilot Chat or Spaces, then hand off the actual coding to an Agent—all without leaving GitHub or setting up a local environment.

In short: Copilot Agents let you move from idea → implementation → review in a single, seamless workflow: faster, safer, and still under your full control.

Using a GitHub Copilot Agent

Step 1 – Open the Agent Menu

  1. From anywhere on GitHub, click the Copilot icon in the top-right header.

  1. Navigate down to Agents.

Step 2 – Select Repo and Branch

  1. Choose the repository where you want Copilot to work.

  2. Select the branch where Copilot should make changes (usually a feature branch).

Step 3 – Start a Work Session

  1. In the agent’s chat window, describe what you want.

    • Example:

      Add a search bar to the Task List page that filters items by title.
  2. Copilot may ask clarifying questions.

  3. Once ready, it will create a Pull Request and begin a work session.

(Open the PR and find the View Session button)

Step 4 – Monitor the Work Session

  • You can watch Copilot’s progress inside the PR’s work session.

  • Once Copilot finishes its first pass, it will add a commit with the requested changes to the pull request.

  • You can open the commit in a GitHub Codespace directly in your browser to view or run the code. Just select the commit and click “Review in codespace”. This will open up a cloud instance of VS Code where you can interact with the changes.

Step 5 – Request Iterations

  1. If you need adjustments, tag Copilot in a PR comment:

    @copilot Can you make the search case-insensitive?
  2. Copilot will spawn a new work session, make the edit, and push another commit.

  1. Repeat as needed until you’re satisfied.

Step 6 – Test and Finalize

  • Use Codespaces to test the changes directly in the browser.

  • Once everything looks good, merge the PR.


Best Practices & Cautions

Using Copilot Agents is powerful, but it’s important to stay safe and effective:

  • Always review Copilot’s code before merging. Treat its changes like contributions from a junior developer.

  • Use feature branches, not main branches, for agent work. This keeps experiments isolated.

  • Test changes in Codespaces before merging to ensure they behave as expected.

  • Be precise in your instructions. The clearer your request, the better the results.

  • Iterate in small steps. Break large requests into smaller ones, this helps Copilot succeed and makes review easier.

  • Don’t skip human oversight. Copilot may miss subtle bugs, security concerns, or style conventions.

✏️ Exercise

Goal: Experience how an agent creates and iterates on changes in a repo.

Step 1 – Start the Agent

  1. Open the Copilot menu → go to Agents.

  2. Select a test repository

Step 2 – Make a Request

  1. In the agent’s chat, ask Copilot to add a simple feature:

    Create a new “About” page that shows basic project information.
  2. Watch as Copilot spins up a PR and begins its work session.

Step 3 – Review the Commit

  1. Once Copilot commits the change, open it in a Codespace.

  2. View the new file or page Copilot added.

Step 4 – Request a Change

  1. In the PR comments, tag Copilot:

    @copilot Please add a navigation link to the About page in the site header.
  2. Observe Copilot starting another work session and committing the change.

Step 5 – Test and Reflect

  • Run the project in Codespaces to confirm the feature works.

  • Merge or close the PR when finished.

Reflection

  • How did working with the agent feel different from using Copilot Chat?

  • Which best practices did you follow, and which felt most important?

  • What kinds of tasks would you trust an agent to handle end-to-end?

Next Steps

You now know how to automate tasks and complete entire issues using Agents!

Continue to: https://bitovi.atlassian.net/wiki/spaces/AIEnabledDevelopment/pages/1625325573/Assigning+Issues?atlOrigin=eyJpIjoiZjE0MDQ3ZDBmZjBjNDZmOWE3YjAzMmJmNDdjNWIxOGMiLCJwIjoiYyJ9

In the next step, you’ll learn how to assign GitHub issues to Copilot and have it work on them autonomously.