📁 Sangam Dhakal - Portfolio v2.0 - Netscape Navigator 4.0
_
□
×

📚 Interview question

How do AI coding assistants such as GitHub Copilot actually work? Explain the LLM underneath, what context it sees, the difference between inline completion, chat and agent mode, and what these tools are good and bad at for a .NET developer.

How AI coding assistants work: next-token prediction by an LLM, the context window and what the IDE sends, completion vs chat vs agent mode vs cloud coding agent, and their strengths and limits.

Junior Theory Beginner ai ai-assisted-development developer-productivity github-copilot llm

🎯 Key points

  • The LLM itself only predicts the next token; compiling and testing happen only when the tool runs them (agent mode)
  • The IDE builds the prompt: open file, cursor position, neighbouring tabs, instructions files, retrieved repo snippets
  • Clear names, small files and consistent conventions in the repo measurably improve suggestions
  • Inline completion = low-latency model, fill-in-the-middle; chat = conversational, explains and edits
  • Agent mode iterates: plans, edits several files, runs dotnet build / dotnet test, reads errors, retries
  • Training data has a cut-off: older .NET patterns dominate unless the target version is stated
  • Output is plausible, not verified: hallucinated APIs and packages, subtle logic bugs, self-confirming tests
  • The developer stays accountable; prompts follow the data policy (no secrets, redacted data)

⏱ 30-second answer

An AI coding assistant is a large language model that predicts the next token given a context window the IDE assembles for it: the current file around the cursor, other open tabs, repository instructions such as .github/copilot-instructions.md or AGENTS.md, and snippets retrieved from the codebase. It has no compiler inside it, so it produces plausible code, not checked code.

  • Inline completion: fast fill-in-the-middle suggestions as you type.
  • Chat: ask, explain, generate or edit with a conversation.
  • Agent mode / coding agent: plans, edits many files, runs dotnet build and dotnet test, reads the errors and iterates, or works from an issue and opens a PR.

It is excellent at boilerplate, tests and explaining code, and weak at novel design and anything newer than its training data. The trade-off: speed of first draft against the cost of verifying it.

🗣 Full answer (senior)

How I would answer this in an interview

"Underneath, a coding assistant is a large language model doing next-token prediction. It never sees my whole solution: the IDE builds a prompt from the code around my cursor, my open tabs, any repository instruction files like copilot-instructions.md or AGENTS.md, and snippets it retrieves from the repo, then the model continues that text. There is no compiler or runtime in that loop, so what comes back is statistically likely code, which is usually right for common patterns and confidently wrong for unusual ones.

In .NET the modes matter. Inline completion is a small, low-latency model filling in the middle of a line or method, great for a mapping method or a guard clause. Chat is for 'explain this LINQ query' or 'write xUnit tests for this handler'. Agent mode goes further: it edits several files, runs dotnet build and dotnet test, reads the compiler errors and tries again, and GitHub's cloud coding agent can take an issue and open a pull request on its own branch. The more autonomy, the more context it can gather, but the bigger the diff I have to review.

The mistake I see is treating a green build as proof. The model will invent an overload that doesn't exist, use an API from .NET 6 instead of .NET 10, or write a test that asserts what the code does rather than what it should do. So I use it as a fast first draft and keep my own judgement for the design, the edge cases and the review. It changes how fast I type, not who is accountable for the code."


The modes compared

Mode What it does Context it uses Best for Watch out for
Inline completion Suggests the next lines as you type Cursor surroundings, open tabs Boilerplate, mappings, guard clauses Accepting without reading
Next edit suggestions Predicts the next edit after a change Recent edits in the file Repetitive refactors Edits in places you didn't look at
Chat (ask / edit) Conversation; explains or edits selected code Selection, referenced files, instructions Explaining, generating tests, small edits Answers that sound sure but are outdated
Agent mode (IDE) Plans, edits many files, runs build and tests, iterates Workspace search, terminal output, tools (MCP) Multi-file changes with a clear goal Large diffs, loops, touching unrelated files
Cloud coding agent Works on an issue in its own environment, opens a PR Repo, issue, instructions, CI Well-scoped backlog items Needs the same review as any PR

What they are good and bad at

Good at Bad at
Boilerplate: DTOs, mappings, DI registration Novel architecture and trade-offs specific to your system
Unit test scaffolding and edge-case brainstorming Knowing APIs released after its training cut-off
Explaining unfamiliar code and regex Whole-system reasoning across many services
Translating between languages (VB.NET to C#) Concurrency, security and performance subtleties
Writing first-draft docs and commit messages Saying "I don't know" instead of guessing

Production example

On [a team of 8 building an ASP.NET Core API], agent mode drafted a new CRUD slice with validator, handler and tests in about [15 minutes] instead of [half a day]. Review found [2] problems the build didn't: an async void event handler and a test that only asserted the mock was called. The time saved was real, but only because review stayed mandatory.

🔍 What the interviewer is checking

Checks that the candidate understands assistants as context-bound text predictors, knows the modes, and keeps accountability for correctness.

Green flags

  • Explains next-token prediction and the context window in plain terms
  • Distinguishes completion, chat, agent mode and a cloud coding agent
  • Names concrete failure modes: hallucinated APIs, outdated patterns, self-confirming tests
  • Mentions instructions files and giving the model context
  • Still compiles, tests and reviews everything

Red flags

  • "It understands the code" or "it checks that it compiles"
  • No idea what is sent to the model or where it goes
  • Measures value by lines accepted
  • Would merge agent output on a green build alone

📚 Learn in depth

1. Next-token prediction

An LLM is a transformer trained to predict the next token (a piece of a word, roughly 3–4 characters of English or code) given the previous tokens. Generation is a loop: predict a probability distribution, sample a token, append it, repeat. Settings such as temperature control how adventurous the sampling is. Nothing in the loop checks that services.AddDbContextPool<T>() has the overload the model just wrote.

prompt tokens ──► transformer ──► probabilities for next token ──► sample ──► append ──┐
      ▲                                                                                │
      └────────────────────────────────────────────────────────────────────────────────┘

2. The context window is everything

The model only knows what is in its training data plus what is in the prompt. The IDE extension decides what goes in:

[system / instructions]  copilot-instructions.md, AGENTS.md, org rules
[retrieved snippets]     similar code found by search or embeddings in the repo
[open tabs]              files you have open, ranked by relevance
[prefix] <cursor> [suffix]   fill-in-the-middle for completions

This is why opening the interface file you are implementing improves suggestions, and why a repo instructions file that says "we use FluentValidation and TimeProvider, never DateTime.Now" changes the output.

3. Completion vs chat vs agent

  • Completion favours latency (tens to a few hundred milliseconds), so it uses smaller, faster models and short context.
  • Chat uses larger models and longer prompts; it can take selected code, files and terminal output.
  • Agent mode wraps the model in a loop with tools: read file, search workspace, edit file, run terminal command, call an MCP server. The model decides which tool to call, the IDE executes it, and the result goes back into context. That loop is what lets it fix its own compiler errors.
  • Cloud coding agents run the same loop in a sandboxed environment (for GitHub, an Actions runner), push to a branch and open a pull request.
goal ──► model plans ──► tool call (edit / build / test) ──► result back into context ──► model decides next step
                              ▲                                                              │
                              └──────────────────────────── until done or limit ──────────────┘

4. Why it hallucinates

The model is optimised to produce likely text, not true text. Common .NET hallucinations: methods that exist on a similar type, NuGet packages with plausible names, configuration keys from an older version, and Startup.cs patterns in a .NET 10 minimal-hosting app. Training data has a cut-off, and the most common code on the internet is not always the most current or secure.

5. Costs and limits

Every request costs tokens. Large contexts are slower and more expensive, and quality can drop when relevant information is buried in a long prompt. Organisations also manage data handling: business plans can exclude files from context, disable suggestions matching public code, and keep prompts out of model training.

Try it yourself

  1. Open an empty file and ask for an EF Core query; then open the DbContext and entity files and ask again. Compare.
  2. Add a .github/copilot-instructions.md with three house rules and check whether chat follows them.
  3. Ask chat for a method on a .NET 10 API you know well and verify every member it uses in the docs.
  4. Give agent mode a failing test and watch the build/test loop it runs; count the iterations.
  5. Ask for unit tests for a method with an off-by-one bug and see whether the tests catch it or enshrine it.

💻 Code

A repository instructions file is the cheapest way to improve what the assistant sees; the test below is the kind of check you write before trusting generated code.

<!-- .github/copilot-instructions.md -->
# House rules for this repo
- .NET 10, C# 14, nullable enabled, file-scoped namespaces.
- Use TimeProvider, never DateTime.Now or DateTime.UtcNow.
- Validation with FluentValidation; handlers with MediatR.
- Every async method takes a CancellationToken and passes it on.
- Tests use xUnit and FluentAssertions; assert behaviour, not mock calls.
namespace Billing.Tests;

// Generated code under test: a discount calculator the assistant wrote.
public sealed class DiscountCalculator(TimeProvider clock)
{
    public decimal Apply(decimal amount, DateOnly promoEnds)
    {
        ArgumentOutOfRangeException.ThrowIfNegative(amount);
        var today = DateOnly.FromDateTime(clock.GetUtcNow().UtcDateTime);
        // Inclusive end date: the edge case assistants most often get wrong.
        return today <= promoEnds ? Math.Round(amount * 0.9m, 2) : amount;
    }
}

public sealed class DiscountCalculatorTests
{
    // Written by a human from the requirement, not from the generated code.
    [Theory]
    [InlineData("2026-11-30", 90.00)]  // last day of the promotion still discounts
    [InlineData("2026-12-01", 100.00)] // day after does not
    public void Apply_respects_inclusive_end_date(string today, double expected)
    {
        var clock = new FakeTimeProvider(DateTimeOffset.Parse($"{today}T10:00:00Z"));
        var sut = new DiscountCalculator(clock);

        sut.Apply(100m, new DateOnly(2026, 11, 30)).Should().Be((decimal)expected);
    }
}

⚠ Common mistakes

  • Mistake: Believing the model checks its own code. Why it is wrong: the LLM only predicts text; completion and chat never compile anything, and agent mode only runs the build and tests you have. Instead: compile, test and read every suggestion.
  • Mistake: Accepting multi-line completions without reading them. Why it is wrong: a plausible block can hide a wrong condition or a swallowed exception. Instead: accept word by word or line by line when the logic matters.
  • Mistake: Assuming it knows the latest .NET APIs. Why it is wrong: training data has a cut-off and older patterns (Startup.cs, Newtonsoft.Json) dominate. Instead: state the target version in instructions and verify APIs in the .NET 10 docs.
  • Mistake: Giving it no context and blaming the output. Why it is wrong: it only sees what the IDE sends. Instead: open related files, reference them in chat and keep an instructions file.
  • Mistake: Letting agent mode run unattended on a vague goal. Why it is wrong: it produces large diffs that touch unrelated files. Instead: give a narrow goal, a definition of done and review the diff before keeping it.
  • Mistake: Pasting secrets, connection strings, customer data or production logs into chat. Why it is wrong: the prompt is sent to a hosted model and may be retained or logged; for personal information that can be a disclosure under the Privacy Act 1988. Instead: follow the organisation's AI data policy: use an approved business or enterprise plan, configure content exclusions for sensitive paths, redact or synthesise data before pasting, and keep secrets in Key Vault or user-secrets so they are never in files the assistant reads.
  • Mistake: Asking it to write the tests for code it also wrote, and calling that verification. Why it is wrong: the tests encode the same misunderstanding. Instead: derive tests from the requirement, especially the edge cases.

🏛 Senior insight: trade-offs

The useful mental model is "a very fast junior who has read the whole internet but not our codebase and has never run anything". That person is great at drafts and terrible at judgement. What changes the quality most is not the model choice but the context: instruction files, small well-named files, clear interfaces, and good tests the agent can run. A codebase that is easy for a new developer is easy for an assistant.

Option When it fits Cost When not to
Inline completion Routine code in a familiar area Low; needs attention per line Security-sensitive or concurrency code
Chat Explaining, tests, focused edits Medium; prompt writing Decisions that need system knowledge it lacks
Agent mode Multi-file change with clear done criteria and tests High review cost per change Vague goals, no tests, unfamiliar code you can't review
Cloud coding agent Small, well-specified backlog items Reviewer time, CI minutes Cross-cutting design, anything urgent in production

Measure it like any tool: cycle time, review rework and escaped defects before and after, not lines generated or suggestions accepted.

🔗 Follow-ups the interviewer may ask

  1. When: Candidate mentions giving the model more context Why: Checks whether they can actually steer the tool rather than just accept its output
    How to answer

    A good code prompt reads like a good ticket for a capable contractor who has never seen the repo:

    • Goal: what should be true when done.
    • Context: the files, interfaces and target framework ("ASP.NET Core 10, EF Core 10, our Result<T> type in Shared/Result.cs").
    • Constraints: libraries to use, patterns to follow, what must not change.
    • Example: an existing class in house style.

    Then ask for edge cases and tests first, review them, and only then ask for the implementation. When it's wrong, paste the actual compiler error or failing test instead of "try again". Rules you repeat go in an instructions file. The trade-off: a longer prompt costs a minute, a vague one costs a review cycle.

  2. When: Candidate mentions hallucinated APIs or packages Why: Checks awareness of supply-chain and data risks specific to AI tools
    How to answer

    AI-generated code carries the usual risks plus some new ones:

    • Insecure patterns: models reproduce what's common, such as string-built SQL, a certificate callback that returns true, MD5, or a missing [Authorize].
    • Hallucinated packages: the model names a NuGet or npm package that doesn't exist, and attackers register those names (slopsquatting).
    • Licence exposure from suggestions matching public code, and data leakage when secrets or personal information go into prompts.
    • Poisoned context: instruction files or docs that steer agent mode into unsafe edits or commands.

    Control it with the gates you already need (SAST, secret scanning, dependency review, human approval) plus package source mapping, lock files and allow-lists, content exclusions and a data policy. The trade-off: a little friction on new dependencies in exchange for closing the cheapest attack path.

↩ Usually asked after

More in AI-Assisted Development

Last updated 23 Nov 2026.

🌐 Sangam's Webring

⏪ Previous 🏠 Main Next ⏩
💬 Chat with me