GitHub Copilot 101Beginner14 min

Chat Modes and How Context Works

Ask, Edit, and Agent are three different contracts with Copilot. Learn to pick the least powerful one that does the job, supply the smallest useful context, and trace a suggestion from your keystroke to your review.


What you'll learn

  • Match Ask, Edit, and Agent to the outcome you need
  • Supply the smallest context that can answer the request
  • Trace a suggestion through its lifecycle from input to human validation
  • Explain why accepting a suggestion never proves it correct
On this page

A failing test points to a helper you've never seen. You don't know where it lives or what behavior it owns. If you choose a mode before you know what you need, Copilot may explain when you wanted a patch, or edit several files when you only needed an explanation. The mode sets the kind of work you're asking it to do.

A mode is a work contract

Ask, Edit, and Agent are three levels of action. Choosing one means choosing how much you're authorizing Copilot to do. Treat the mode plus your prompt as a contract:

Mode You want Boundary you set What you review
Ask An explanation or analysis No file changes The reasoning, assumptions, and options
Edit A specific, bounded change Named files or selected code The proposed diff and its effect
Agent A multi-step completed task Allowed files, tools, checks, stop conditions Tool actions, the diff, and verification output

Use the least action that can produce the result you need. Start with Ask when you still need to understand the behavior. Choose Edit when you can describe the change and name the files, which gives you a smaller diff to inspect. Use Agent when the task requires investigation and commands, and give it a stopping condition. The mode changes the work Copilot may attempt. You still own the result.

Reach for the least powerful mode first

Choosing Agent for a question you could have asked wastes actions and autonomy while you're still deciding what you even want. Start with Ask to settle the behavior, move to Edit once the scope is known, and escalate to Agent only when the task needs tools and multiple steps.

Ask for understanding before you change anything· github-copilot
Bad example

Explain src/order-total.ts and tell me what should be fixed.

Good example

Explain the function in src/order-total.ts. Return: the calculation in plain language, its assumptions about each parameter, four boundary or invalid-input cases, and two validation policies with tradeoffs. Label inferred business rules as assumptions. Do not edit files.

Why this works: A plain-language explanation plus a short menu of edge cases and validation options, with nothing changed, so you decide the intended behavior before any code moves.

Edit handles diffs. Agent handles tasks.

Once you know the behavior you want, the question is how much autonomy the job needs. Reach for Edit when you can name the files that may change and describe the change precisely: the required behavior, what must stay the same, the error policy, and the tests that would prove it. A good Edit prompt produces a small diff you can read line by line.

"Bounded" describes the scope your request set. The mode doesn't enforce the boundary for you: your prompt does, and your review confirms it. Always check the actual file list and diff rather than assuming the change stayed where you asked.

Choose Agent when completion requires a sequence of actions, such as inspecting files, editing code, running a command, and responding to the result. State the guardrails before it starts. Name the outcome, allowed files, prohibited actions, verification command, passing behavior, and stopping condition. Without that last boundary, a small fix can keep expanding after the original task is already lost.

Agent mode in your IDE is also a different thing from GitHub's cloud coding agent, which runs in a GitHub Actions-powered environment and opens a pull request for review. Choosing Agent locally does not hand your task to that cloud workflow.

Request a bounded, reviewable diff· github-copilot
Bad example

Fix negative quantities in the order total code and update the tests.

Good example

In src/order-total.ts, reject a negative quantity by throwing RangeError with a parameter-specific message. Preserve the exported function signature and the calculation for valid inputs. Update only test/order-total.test.ts. Show the diff for review.

Why this works: A small diff limited to the source and its test file, with a test for the new rule and the valid-input formula untouched. Reject it if it edits anything else.

Give an agent a boundary and a stop condition· github-copilot
Bad example

Fix the orderTotal validation and make sure the tests pass.

Good example

Implement the agreed orderTotal validation. You may modify only src/order-total.ts and test/order-total.test.ts. Run: npx vitest run test/order-total.test.ts. Correct only failures caused by this change, modify no configuration, and stop after the focused test passes or after reporting a blocker with command output. Summarize the changed files and result.

Why this works: A completed change plus the real command output and a changed-file list. The agent halts at the boundary you set instead of touching config or unrelated files.

Read the output yourself

"All tests pass" in an agent's summary is a claim. It isn't evidence. Read the actual command output and confirm the tests cover the behavior you asked for. A confident recap can sit on top of a diff that changed the return type or skipped the case that mattered.

Where does a suggestion come from?

The path from your keystroke to the displayed suggestion explains why "Copilot said so" isn't evidence. Use this sequence as a reasoning model:

Editor input → context selection and prompt building → proxy filtering
  → model generation → post-processing → suggestion displayed
  → human review and validation

Your input is the comment, partial function, selection, or chat request that starts things off. Precise input gives you a clearer contract to judge against. Context is the bounded package of material the request can see: the code near your cursor, a selection, an explicitly attached file, applicable instructions, prior messages. Nothing wider than that counts as context, so don't assume Copilot considered a file you never attached. The middle stages, proxy filtering, model generation, post-processing, are real architectural topics, but their exact internal rules aren't something you can observe from the editor. Record what you see and resist inventing a hidden cause for it.

Proxy filtering is one stage in this reasoning model. Content exclusion is different: it is a configured safeguard for specific files, and you'll meet it later in the module. Never disable a safeguard just to make a practice exercise produce output. When a suggestion doesn't appear, record "no suggestion." That observation alone does not show that a filter blocked it.

The last stage is yours. Model generation only establishes that a candidate appeared, not that the candidate is correct. Accepting it changes your editor, and only a real check tells you anything about behavior. The earlier lesson's habit holds at every level: an explicit contract plus executed checks is the only thing that turns a displayed candidate into code you can trust.

Context is evidence, so control it

Copilot reasons from the context it receives, so keep that evidence deliberate. Name the file when one file owns the behavior. Select the function when the question is local. Include the error text when you're diagnosing a failure. Ask it to inspect the repository only when you genuinely don't know where the relevant code lives.

This also matters when you compare two responses to learn what changed. If you change the prompt, the selection, the attached file, and the conversation history all at once, you can't attribute the difference to any single factor. Change one variable at a time. For a real comparison, keep the prompt, selection, cursor, and output rubric fixed and vary only the attached context. Don't lean on half-remembered "magic" syntax for references. If your editor shows a control for adding files or selections, use it. Otherwise, name the paths, symbols, diagnostics, and error text directly in the prompt. A durable request doesn't depend on a token spelling that changes between releases.

Whichever mode you're in, the same review loop applies: state the outcome you want, supply the relevant evidence, set the scope and constraints, inspect the response or diff or tool actions, run the narrowest useful check, then refine using a specific discrepancy. That last step is where people slip. Answering a weak result with "try again" tells Copilot nothing. It can't act on a shrug. Name what failed instead: "the patch changed the public return type," or "the test doesn't cover the upper discount boundary." A precise complaint is an instruction Copilot can execute. A vague one rolls the dice. Turn these prompts into testable specifications in Prompting for Code.

Try it yourself

Run one problem through Ask, Edit, and Agent

Feel the difference between the three modes on a single tiny function. Budget about eight minutes.

  1. 01

    Create a practice folder with src/discount.mjs holding a discountedPrice(price, quantity, discountRate) function that returns price * quantity * (1 - discountRate), plus a test file with one passing case. Run the test to confirm a green baseline.

  2. 02

    In Ask mode, request an explanation of the formula, its assumptions, and what happens for a negative quantity. Require no edits.

    Hint: A good answer will point out that the starter accepts a negative quantity.

  3. 03

    Decide the policy yourself: a negative quantity must throw RangeError. Everything else stays the same.

  4. 04

    In Edit mode, request a diff limited to the two files, adding one negative-quantity test and preserving the existing tests. Read the actual diff before accepting.

  5. 05

    In Agent mode, ask it to implement the reviewed policy and run your test command. Then read the terminal output. Don't stop at the summary.

Three green tests, a diff limited to two files, and a felt sense of why Ask, Edit, and Agent were each the right tool at their stage.

Key takeaways

  • A mode is a work contract. Ask for understanding, Edit for a bounded diff, Agent for a tool-driven task.
  • Use the least powerful mode that does the job, then escalate only when the work demands it.
  • Edit's boundary comes from your prompt. The mode doesn't enforce it. Always review the actual file list and diff.
  • A suggestion travels a lifecycle. Generation only proves a candidate appeared. It doesn't prove the candidate is correct.
  • Supply the smallest useful context and change one variable at a time when comparing responses.

Check your understanding

  1. 1. You inherited a pricing function and don't understand why it rounds twice. Which mode should you start with?

  2. 2. Which sequence is the correct teaching order for an inline suggestion's lifecycle?

  3. 3. You type in a function and no suggestion appears. What can you correctly conclude?

  4. 4. An Agent prompt gives a clear objective but no stopping condition. What's the risk?

  5. 5. You want to compare how an attached file changes Copilot's answer. What makes the comparison valid?

  6. 6. Copilot returns a diff in Edit mode. Since you asked for a "bounded" change, is the boundary guaranteed?

Frequently asked questions

Terms used in this lesson

chat mode
The level of action you request from Copilot: Ask (explain), Edit (bounded change), or Agent (multi-step task with tools).
Agent mode
A mode where Copilot can inspect files, edit code, and run commands in sequence, within the allowed files and stop conditions you define.
suggestion lifecycle
The path from editor input through context, processing, and display to your review. A reasoning model for why generation isn't proof.
context
The bounded package of code, selections, files, and history a request can see. It's not the whole repository unless you attach it.

Further reading