MSBA-370 · Lesson 11 of 12 · 18 min

Cost and latency

▶ Video coming soon A video version of this lesson is on the way.

Rosa Delgado, who looks after Tidewater's budget, came to the eleventh session with a printout of the organization's Copilot usage page and one question: "Is this going to keep growing?" Agent use had roughly doubled the team's Copilot consumption in a month. Nobody thought it was wasted, but nobody could say what a typical task cost either. This lesson explains where the cost and the waiting time of agent work come from, and how to estimate and control both.

Cost and latency are not separate GH-600 domains, but they run through the outline: choosing tools, managing context and memory, tuning agent behaviour, and preserving delivery speed while adding guardrails all depend on them.

Where cost comes from

An agent's cost has three parts. The model cost depends on the model used and on how much text goes in and comes out of each call, measured in tokens, the small pieces of text models process. The environment cost is the compute the agent runs on, which for the cloud agent is GitHub Actions infrastructure. The people cost is the time to write the task, watch or steer the session and review the result, which is often the largest part and the easiest to forget.

Copilot plans bundle model use into allowances and bill extra use against the account's AI credits, with budgets and policies that administrators set. GitHub has changed the details of Copilot billing several times, including how agent sessions are metered, so the numbers in this lesson are illustrative and the current billing documentation is the source to check. The principles do not change: more steps, more context and stronger models cost more.

Why agent sessions cost more than chat

A chat answer is one model call. An agent session is many calls, and each call sends the whole conversation so far: the instructions, the task, every tool result and every earlier response. The input therefore grows with each step. A session with twenty steps does not cost twenty times a chat answer; it can cost far more, because the later steps carry everything that came before.

A bar chart with twelve bars, one per agent step. Each bar is split into input tokens, which grow from about 6,000 at step 1 to about 28,000 at step 12, and a small, roughly constant slice of output tokens of about 500.
Illustrative token use in a twelve-step session. Input grows each step because the context accumulates.

Worked problem

Estimating one session

Malik logged a session that took twelve steps. The first call sent about 6,000 tokens of input and each later call sent about 2,000 more than the one before, with roughly 500 tokens of output each time. Roughly how many tokens did the session use?

Show solution
  1. Input per call runs 6,000, 8,000, 10,000 and so on up to 28,000 at step 12.
  2. That is an arithmetic series of 12 terms averaging (6,000 + 28,000) / 2 = 17,000, so about 204,000 input tokens.
  3. Output adds 12 times 500, or about 6,000 tokens.
  4. The session used about 210,000 tokens, roughly thirty times more than a single 7,000-token chat exchange, because of the growing context.

Reducing cost

The levers for cost are the same ones that improve accuracy, which is fortunate. Smaller tasks mean fewer steps and less accumulated context. Focused context means fewer files read and smaller tool results, which lesson 4 covered. Better setup steps stop the agent from spending its first minutes installing tools by trial and error. Good instructions stop it from rediscovering how to run the tests every time. Model choice matters: a faster, cheaper model is often good enough for narrow tasks, while a stronger model may be cheaper overall on hard tasks because it needs fewer attempts. And stopping early matters: a session that is clearly going the wrong way should be stopped, not left to finish.

Levers that reduce agent cost and usually improve results too.
LeverEffect on costEffect on quality
Smaller, well-specified tasksFewer steps and less contextUsually better
Purpose-built tools with small resultsLess context per stepBetter focus
copilot-setup-stepsNo wasted setup stepsMore reliable runs
AGENTS.md and instructionsLess rediscoveryMore consistent output
Right-sized modelCheaper calls, or fewer retriesDepends on the task
Plan approval before codingAvoids paying for wrong workCatches misunderstandings early

Budgets and policies

Administrators control spending with budgets and policies. GitHub lets enterprises and organizations set budgets for Copilot spending and choose whether usage stops or continues when a budget is reached, and lets them decide which models and features members may use. Usage reports and the Copilot usage metrics, which gained cloud agent fields in April 2026, show who is using what. Rosa set a monthly budget for Tidewater with an alert at 75 percent of it, and Priya reviewed the usage report on the first Thursday of each month.

Where latency comes from

Latency is the time from assigning a task to having a result. For the cloud agent it includes starting the environment and running setup steps, each model call, each tool run, and the waiting the agent does for tests and builds. Longer contexts make each model call slower, and stronger reasoning models think for longer. Local agents start instantly but tie up the developer's machine and attention; cloud agents take longer to start but let the developer do something else.

Latency that matters

Not all latency matters equally. A cloud agent session that takes twenty minutes while the developer works on something else costs little. The same twenty minutes spent watching agent mode in the editor costs the developer's full attention. And the longest delay in most teams is neither: it is the time an agent pull request waits for a human review. Priya's observation after a month was that the median agent session at Tidewater took about a quarter of an hour, and the median time to first review was over a day. Improving setup steps saved minutes; agreeing that someone would look at agent pull requests each morning saved a day.

Deciding whether it was worth it

Rosa's original question, whether agent use was worth its cost, needed a comparison rather than a total. The team compared agent tasks with similar tasks done by people over the same month: the time from issue to merge, the review time, the number of follow-up fixes and the Copilot usage. For test-writing and small fixes, agent tasks reached merge faster and freed several hours of developer time a week at a modest usage cost. For dependency upgrades the picture was mixed until setup steps improved. The measurement mattered more than the result: it let the team decide where to use agents with evidence instead of enthusiasm.

Context management in practice

Most of the cost of a long session is context, so managing context is the most effective way to manage cost. Several techniques help. Focused tools return only what is needed. Summaries replace long earlier steps with short notes. Fresh sessions start new work without carrying the previous task's context. Narrow tasks need less exploration. And good instructions answer questions the agent would otherwise spend steps discovering. Each of these also improves accuracy, because a model with less irrelevant text in its context is less likely to be distracted by it.

Context management techniques and their trade-offs.
TechniqueWhat it savesTrade-off
Focused tool resultsTokens per stepTool may hide detail the agent needs
Summarizing earlier stepsTokens in later stepsDetail lost from the summary
Fresh session per taskContext carried between tasksAgent relearns the repository
Instructions that answer common questionsExploration stepsInstructions must be kept current

Choosing models

Models differ in capability, speed and cost, and the choice is a trade-off. Faster, cheaper models suit narrow, well-specified tasks with good checks, such as adding a test or updating documentation. Stronger reasoning models suit tasks that need understanding of unfamiliar code or careful planning, and may cost less overall on those tasks because they need fewer attempts. Organizations can restrict which models members may use, and GitHub publishes how much each model counts against usage. Tidewater's rule was to start with the default and change only when results showed a reason.

Measuring what matters

Rosa's question needed measures the team could collect without much effort. For each agent task the team recorded the task type, the outcome, the number of review rounds and the time from assignment to merge, and once a month compared totals with the Copilot usage report. That was enough to see trends. A sharp rise in usage without a rise in merged work pointed to wasted sessions; a fall in review rounds after an instruction change showed the change had worked. Seraphine noted that Skerry used the same measures at scale, drawing on the Copilot usage metrics and audit data rather than a spreadsheet.

Latency and developer experience

Waiting changes how people work. If a cloud agent session takes half an hour, developers batch their tasks and check results later, which suits well-specified work. If agent mode in the editor pauses for a minute between steps, developers lose focus and are tempted to approve without reading. Faster models and shorter tasks help in the editor; in the cloud, latency matters less than predictability. Malik noticed that he trusted the cloud agent more once he knew roughly how long each kind of task took, because he could plan around it instead of checking repeatedly.

Cost at Skerry

Skerry's scale made cost a governance question. Seraphine's team set budgets per cost centre, used policies to limit which models were available to which teams, and reviewed the top users of agent sessions each month, not to criticize them but to learn what they were doing that others might copy or avoid. The most common finding was that a few repositories without setup steps or instructions accounted for a large share of usage, because every session there spent its first steps rediscovering the build. Adding setup steps and an AGENTS.md to those repositories reduced their usage noticeably within a month.

Cost of not using agents

Rosa's last question was the reverse of her first: what did it cost not to use agents for the tasks they did well? The team's honest answer was that the work would still get done, more slowly, by people who had other things to do. The test-writing backlog for trail-units had sat untouched for a year before agents cleared it in a month. That was the comparison that settled the budget: not whether agents were free, but whether the work they did was worth more than they cost, measured against what the same people would otherwise have done with their time.

A worked comparison of two sessions

Malik compared two sessions on similar tasks in open-trail-report. In the first, before the repository had an AGENTS.md or setup steps, the agent took twenty-three steps, about a third of them spent finding and installing the right tools and working out how to run the tests. In the second, after both were added, it took nine steps for a task of similar size. Because context grows with each step, the token use of the second session was well under a third of the first. The output was also better, needing one review round instead of three.

Two similar sessions in open-trail-report, before and after setup steps and AGENTS.md.
MeasureBefore setup and instructionsAfter
Steps in the session239
Steps spent on setup and discoveryAbout 80
Review rounds31
Relative token useHighWell under a third

The comparison became Tidewater's standard answer to anyone who asked whether writing instruction files was worth the time. It was the cheapest cost reduction available, and it improved quality as well.

Budgets as signals

Rosa's budget alert at 75 percent fired once in the first term, in the last week of a month when two people had run long research sessions on unfamiliar code. Nothing was wrong, but the alert prompted a conversation about whether research sessions should use a stronger model by default, which led to the team's model rule. A budget that never fires is probably too high to be useful; one that fires every week is too low to be trusted. The aim was an alert that fired rarely and always started a useful conversation.

Common mistakes

  • MistakeEstimating agent cost as a multiple of one chat answer.

    InsteadAccount for context growing at every step; long sessions cost disproportionately more.

  • MistakeAlways using the strongest model.

    InsteadMatch the model to the task; cheaper models suit narrow tasks.

  • MistakeCounting only model usage.

    InsteadInclude environment and especially people's review time.

  • MistakeTreating a slow session as the main delay.

    InsteadMeasure time to review; it is often the longest wait.

Summary and key terms

  • Agent cost comes from model use, the environment and people's time.
  • Each agent step resends the growing context, so long sessions cost disproportionately more than chat.
  • Smaller tasks, focused tools, setup steps, instructions, right-sized models and plan approval reduce cost and usually improve quality.
  • Budgets, policies, usage reports and metrics let administrators control and monitor spending.
  • Latency includes environment start, model calls and tool runs, but the longest wait is often human review.
Token
A small piece of text that models process; model use is measured in tokens.
AI credits
The unit GitHub uses to bill Copilot usage beyond plan allowances.
Budget
A spending limit with alerts or a stop when reached.
Latency
The time from assigning a task to having a usable result.
Time to first review
How long an agent pull request waits before a person reviews it.

Practice problems

Work each problem on paper first, then reveal the answer to check.

  1. Why does an agent session cost more than the sum of its outputs suggests?

    Show answer

    Each call resends the accumulated context as input.

  2. Name three levers that reduce both cost and errors.

    Show answer

    Smaller tasks, focused tools and good instructions, among others.

  3. What was the longest delay in Tidewater's agent tasks?

    Show answer

    The wait for a first human review.

Lesson quiz · 5 questions

Score 60% or more to complete this lesson.

Take the quiz