MSBA-370 · Lesson 12 of 12 · 19 min

Case study: an agent that fixes failing tests

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

The last session was a case study, chosen because it used almost everything the course had covered. On a Monday morning a Dependabot pull request in the trail-units repository, bumping the Rollup bundler by a major version, had failed its checks. Three tests failed and the build step reported a configuration error. Nobody on the team had time that week to read the bundler's migration guide. Dmitri, who owned the action, decided to give the problem to the cloud agent and to treat the whole episode as a worked example for the course. This lesson follows it from the failing check to the merged fix, and then asks what an evaluation of the agent's work would look like.

The starting point

The trail-units action had everything lessons 6 to 9 recommended. Its repository had a copilot-setup-steps workflow that installed Node 24 and ran npm ci, an AGENTS.md file that said how to build and test and what done meant, a path-specific instruction file for tests, and the test-writer custom agent. The cloud agent was enabled for the repository, the firewall used the recommended allow list, and the Copilot environment held no secrets at all, because the action needed none to build or test. Branch rules required one review and the CI check on the default branch.

The controls in place before the case study.
ControlState in trail-units
copilot-setup-stepsInstalls Node 24 and runs npm ci
AGENTS.mdBuild, test, done criteria and forbidden actions
Path-specific instructionsTest conventions for test/**/*.test.js
FirewallOn, recommended allow list
Copilot environmentEmpty; no secrets needed
Branch rulesOne review and the CI check required on main

Writing the task

Dmitri wrote the task as an issue, using the checklist from lesson 10, and asked for a plan before any code. He linked the failing Dependabot pull request, pasted the three failing test names and the build error, and set out what done meant. He deliberately said what the agent must not do: change the tests to make them pass. The rule was already in the path-specific instructions, but a task-level reminder cost nothing.

The issue Dmitri assigned to Copilot.
Title: Fix build and tests after the Rollup major version bump

The Dependabot pull request that upgrades Rollup to the new major version fails CI.
Failing tests: converts miles to km, converts feet to inches, rejects negative input.
Build error: rollup.config.js uses an option the new version removed.

Please propose a plan first.

Done means:
- npm test passes and npm run build succeeds on the new Rollup version
- dist/index.js is rebuilt and committed
- No test is changed to make it pass; if a test seems wrong, explain why
- No new runtime dependencies

Out of scope: other dependency upgrades, refactoring.

The plan

The agent's plan arrived a few minutes later. It proposed reading the bundler's release notes for the removed option, updating rollup.config.js to the replacement, running the build, then investigating the test failures, which it suspected were caused by the build change because the tests imported the bundled output in one place. It also proposed upgrading two plugins to versions compatible with the new bundler. Dmitri checked that both plugins were build-time development dependencies, not runtime ones, and approved the plan with one change: run the tests before and after each step and report the results in the pull request.

A timeline of the case study. Monday 9:10, Dependabot pull request fails. 9:40, Dmitri assigns the issue and asks for a plan. 9:50, plan proposed. 10:05, plan approved with one change. 10:30, agent pushes the configuration fix; build passes, one test still fails. 10:45, agent finds a test importing the old output path and asks a question instead of editing the test. 11:20, Dmitri changes the test import himself; the agent reruns the tests and rebuilds, and all tests pass. Tuesday 9:15, Lena reviews and approves; Dmitri allows workflows; merged.
From failing check to merge, with the two points where a person decided.

The session

The session log showed the agent working through the plan. It read the release notes through the browser tool, which the firewall allowed because the documentation site was on the recommended list, changed one configuration option, upgraded the two plugins and rebuilt. The build passed and two of the three failing tests now passed too. The third, rejects negative input, still failed.

At this point the agent did what the instructions asked rather than what was easiest. The test imported a helper from a path that the new bundler configuration no longer produced, and the quickest fix was to change the test's import. Instead it stopped and wrote in the pull request: "The remaining failure is caused by test/validate.test.js importing from dist/lib/validate.js, which the new configuration no longer emits. I can either change the test to import from src/validate.js, or change the build to emit the old path. The instructions say not to change tests to make them pass, so I have not changed it. Which do you prefer?"

Dmitri's answer was a third option. The test should never have imported from dist at all; the source module was the right import. That was a test change, but a correct one, made by a person who understood why. He made the one-line change himself, pushed it to the agent's branch, and mentioned Copilot asking it to rerun the tests and rebuild. All tests passed.

Worked problem

Reading the diff against the plan

Lena reviewed the pull request on Tuesday. The diff changed rollup.config.js, package.json, package-lock.json, dist/index.js and test/validate.test.js. Which changes should she check most carefully, and why?

Show solution
  1. package.json: confirm the only changes are the bundler and the two approved plugins, all development dependencies, matching the plan.
  2. rollup.config.js: confirm the replaced option matches the release notes the agent cited in the session log.
  3. test/validate.test.js: confirm the change is Dmitri's, made by a person, and only changes the import path, not any assertion.
  4. dist/index.js: confirm it was rebuilt by the build step rather than edited, which the required check that rebuilds and compares dist already verifies.

The review

The review followed lesson 8's gates. Lena, not Dmitri, approved, because Dmitri had requested the work and had also committed to the branch. Before approving she read the session log and compared the diff with the plan. Dmitri then allowed the workflows to run on the pull request, the CI check passed on Node 24, and Lena merged it on Tuesday morning. Dependabot closed its own pull request automatically because the upgrade was now on the default branch.

Evaluating the agent's work

Priya asked the group to evaluate the episode the way the GH-600 evaluation domain describes: define what success means, find where errors happened, and decide what to tune. Success had a concrete meaning here: the issue's done criteria. All four were met. The time from assignment to merge was about a day, of which the agent's work was under two hours and most of the rest was waiting for review, as lesson 11 predicted.

Tidewater's evaluation of the case study.
QuestionFindingAction
Did the result meet the done criteria?Yes, all fourNone
Did the agent stay in scope?Yes; plugin upgrades were in the approved planNone
Where did it need a person?The test importing from distAdd a rule: tests import from src, never dist
Did any control fire?No firewall warnings; no secrets neededNone
What slowed it down?Overnight wait for reviewAssign a reviewer when the task is created
Could the problem recur?Yes, at the next major bumpAdd a test that fails if any test imports from dist

The most useful finding was the one where the agent stopped. A less careful configuration, without the rule against changing tests, would probably have produced a green pull request with a test quietly pointed at a different file, and the team would not have learned that its tests depended on build output. The instruction turned a hidden problem into a visible question. Dmitri added the new rule to the test instructions and asked the test-writer agent to add a check that failed if any test imported from dist, which it did in a separate pull request the same afternoon.

What generalizes

The case study is small, but its shape is the one the GH-600 outline describes throughout. Clear tasks with done criteria and scope. A plan approved before code. Controls that limit what the agent can reach. Instructions that make it ask rather than guess at the points that matter. A person who reviews against the plan and the log. And an evaluation that feeds back into instructions, setup and tests. MSBA-371 takes the evaluation, multi-agent coordination and guardrail domains further; this course has given the architecture and tools they build on.

Alternatives Dmitri considered

Before assigning the task Dmitri considered three other options. He could pin the bundler at the old major version and ignore the upgrade, which would defer the problem until a security fix forced it. He could fix it himself, which would take an afternoon he did not have. Or he could ask agent mode in his editor to help while he watched, which would still take most of an afternoon of his attention. The cloud agent was the right choice because the task was well specified, the tests were good, the change was reversible and the cost of waiting a few hours was small.

What the session log showed

Lena's review started with the session log. It showed the agent reading the bundler's release notes, opening rollup.config.js, changing one option, upgrading the two plugins, running npm ci, the build and the tests, and reading the failing test's file. It did not show the agent opening unrelated files or trying the same failing command repeatedly. The log also showed that the agent had run the tests before its first change, as the approved plan asked, so the pull request summary could report which failures existed before and after each step. That record let Lena review in fifteen minutes rather than an hour.

What could have gone wrong

Priya asked the group to imagine the case study going badly, because the controls are easiest to understand by seeing what they would have caught. If the agent had changed the test to make it pass, the path-specific instruction might not have stopped it, but review against the plan would have caught an unplanned test change. If the agent had added a runtime dependency, the AGENTS.md rule and dependency review would have flagged it. If the bundler's release notes had contained instructions aimed at agents, the firewall would have stopped data leaving, and the token could not have reached other repositories. If Dmitri had approved his own pull request, the approval rule would have refused it.

Controls mapped to failures that did not happen.
Possible failureControl that would catch it
Test changed to passInstruction against it; review against the plan
Unneeded runtime dependency addedAGENTS.md rule; dependency review
dist edited by handRequired check that rebuilds and compares dist
Data sent to an unknown siteAgent firewall
Self-approvalRule that the requester cannot approve

Repeating the pattern

After the case study the team wrote a short playbook for broken dependency upgrades, which were the most common reason for failing Dependabot pull requests across its repositories. The playbook was the issue template Dmitri had written, with blanks for the package, the failing checks and the error, and a standard done list. Over the following weeks Malik used it for a failing upgrade in open-trail-report and Lena for one in TrailCheck. Both were merged after one review round. A template turned one good task into a repeatable one, which is how a team's agent practice grows.

Looking ahead to MSBA-371

The case study used one agent on one task with one person deciding at each key point. MSBA-371 asks what changes when there are several agents, longer tasks and more autonomy: how agents keep state across sessions, how to evaluate their output systematically, how work passes between agents and people, and how guardrails and audit trails scale. The habits from this course carry forward: clear tasks, narrow tools, contained environments, instructions backed by controls, and review against a plan.

The case study as exam practice

Malik wrote up the case study as a set of practice questions for GH-600, one for each domain it touched: which architecture choice fitted the task, which tools the agent needed, how the plan controlled execution, how the result was evaluated, which human handoffs occurred, and which guardrails applied. Writing questions about a real episode, he said, was better revision than any list of facts, because it forced him to connect each control to a reason.

Common mistakes

  • MistakeLetting the agent change tests to make a build pass.

    InsteadForbid it in instructions and the task, and have a person decide test changes.

  • MistakeApproving an agent pull request you also committed to.

    InsteadHave a different person approve.

  • MistakeReviewing only the final diff.

    InsteadCompare the diff with the approved plan and read the session log.

  • MistakeTreating a merged fix as the end.

    InsteadEvaluate the session and turn findings into instructions, setup or tests.

Summary and key terms

  • Good preparation, including setup steps, AGENTS.md, path-specific instructions and an empty Copilot environment, made the task straightforward.
  • A written task with done criteria and a plan-first request kept the agent in scope.
  • An instruction against changing tests made the agent ask a question that exposed a real problem.
  • Review compared the diff with the plan and the session log, and a different person approved.
  • Evaluation against the done criteria produced new instructions and a new check.
Done criteria
The conditions written into a task that define a successful result.
Plan-first task
A task in which the agent proposes a plan and waits for approval before writing code.
Agent evaluation
Reviewing an agent's result against success criteria to find errors and decide what to tune.
Scope
The set of changes a task is allowed to make.
Build output
Files produced by a build step, such as dist/index.js, which should not be edited by hand.

Practice problems

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

  1. Why did the agent stop instead of fixing the last failing test?

    Show answer

    Its instructions forbade changing tests to make them pass.

  2. Why did Lena, not Dmitri, approve the pull request?

    Show answer

    Dmitri requested the work and committed to the branch, so a different person had to approve.

  3. Name one change the evaluation produced.

    Show answer

    A rule that tests import from src, or a check that fails if a test imports from dist.

Lesson quiz · 5 questions

Score 60% or more to complete this lesson.

Take the quiz