MSBA-371 · Lesson 11 of 12 · 19 min
Operating agents in production
▶ Video coming soon A video version of this lesson is on the way.
By November the Copilot cloud agent was part of ordinary work at Tidewater. Lena assigned it import fixes, Dmitri used it for dependency updates across the actions, and Malik had it writing tests for the trail-report validator. Then, on a Monday, three agent sessions in a row ended without a pull request worth reviewing: one stalled with no commits for an hour, one finished with a plan half ticked and a note that the tests could not run, and one produced a change that ignored the repository's test conventions entirely. Nothing had changed in Tidewater's configuration. Something had changed somewhere.
Running agents every day is an operations job, like running a build system or a website. The GH-600 domain on multi-agent coordination includes three objectives that belong here: observability, detecting and responding to failures, and managing the lifecycle of agents without disruption. This lesson treats them as one practice: knowing how your agents are doing, noticing when they are doing badly, and changing them safely.
What to watch
Observability for agents uses the signals from the evaluation lessons, collected continuously instead of on a test set. They fall into four groups.
| Group | Examples | Where the data comes from |
|---|---|---|
| Throughput and outcome | Sessions started, pull requests opened, merged, closed unmerged, reverted within 14 days | Pull requests, commits, labels on agent pull requests |
| Quality and safety | Failed required checks, new code scanning alerts, push protection blocks, firewall warnings, test files modified | Checks, code scanning, secret scanning, session logs |
| Process | Sessions without commits, sessions needing steering, files outside plan, escalations | Session logs, pull request timelines |
| Cost and time | Premium requests or credits used, Actions minutes, session duration, time from assignment to merge, reviewer time | Billing and usage reports, Actions usage, pull request timestamps |
GitHub provides some of this directly: Copilot usage metrics for organizations and enterprises, billing and usage reports for premium requests and Actions minutes, and the agent sessions view and audit log events described in the previous lessons. The rest comes from querying pull requests and checks. Tidewater, being small, used a scheduled workflow that ran a weekly query through the GitHub API and posted a table to a discussion. Skerry fed the same kinds of data into its existing dashboards.
Rates, not anecdotes
Operators should watch rates rather than counts or stories. Three failed sessions on a Monday is alarming if the agent normally fails one session a week, and normal if the team assigned forty tasks that day. A rate, such as the share of sessions that end without a reviewable pull request, or reverts per hundred merged agent changes, can be compared week to week and with the test-set results from the evaluation lessons.
Baselines help. In October Tidewater's agent sessions ended without a reviewable pull request about one time in eight, and about one merged agent change in thirty was reverted within fourteen days. Those numbers became the yardstick for what a bad week looked like.
Failed, partial and stalled
The outline asks candidates to identify failed, partial or stalled executions. The three need different detection.
A failed session ends with an error: setup steps failed, the environment could not start, the agent hit a hard limit, or the agent reported that it could not complete the task. Failures are visible because something says so, in the session log, the pull request or a notification. The response starts with the error: an environment failure is usually fixed in the setup steps, not by retrying.
A partial session ends normally but does not finish the task: some plan steps ticked, others not, perhaps with an escalation. Partial results are visible only if someone compares the plan with the work, which is another reason agents should keep a plan checklist. The response is a decision: continue with a new session from the plan, take over by hand, or close the work.
A stalled session neither finishes nor fails: no commits, no plan updates and no log progress for a long time. Stalls are the hardest to see because nothing announces them. Detection needs a rule, such as "no commit or log entry for sixty minutes", and someone or something that checks it. The response is to look at the log, then either steer, cancel and retry, or cancel and escalate.
Degraded behaviour
Tidewater's bad Monday was not a single failure but a change in behaviour: the agent was doing worse across many sessions. The outline calls this degraded behaviour. Its causes are often outside the team's repository: a change in the default model, a change in the agent product, an outage or slowdown in a dependency, an update to a shared custom agent or MCP server, or a change in the runner image the environment starts from.
Detecting degradation needs the rates and baselines above. Responding to it follows a familiar sequence.
Worked problem
Tidewater's bad Monday
Three of Monday's sessions failed in different ways. Lena led the response.
Show solution
- Check scope: Lena queried the week's sessions. Six of eleven had problems, against a baseline of about one in eight. That was degradation, not bad luck.
- Look for a common change: nothing had changed in Tidewater's repositories. Dmitri checked the GitHub changelog and status page; there was no incident, but the session logs showed that the model the cloud agent used by default had changed the previous week.
- Contain: Lena paused assigning new tasks to the agent for the validator repository, where the failures were worst, and moved two urgent tasks to people.
- Test: she ran the 25-task smoke subset of her test set with the new default model and with the previous model pinned. The new default passed 14 of 25; the pinned model passed 20 of 25, close to its earlier results.
- Recover: the team chose the previous model explicitly when assigning tasks in that repository, resumed assignments and opened an issue to tune instructions for the new model before switching.
- Record: a short note in the discussion and a decision record explained the pin and set a date to review it.
The example is invented for Tidewater, but the pattern is real for every team: agent behaviour depends on parts the team does not control, and those parts change. Teams that pin what matters, watch rates and keep a test set can see and reverse a change in hours. Teams without them find out from frustrated reviewers weeks later.
Recovery patterns
The outline lists recovery patterns including rollback and human-in-the-loop intervention. In practice a team needs a short menu.
| Pattern | When to use it | How on GitHub |
|---|---|---|
| Retry | A transient failure such as a network error, with no damage done | Start a new session from the same issue or plan |
| Resume | A partial session with a sound plan and good commits | New session that reads the plan and continues from the first unfinished step |
| Take over | The agent is stuck on a hard part, or the task needs judgement | A person checks out the agent's branch and continues |
| Roll back | A merged agent change caused a problem | Revert the pull request; redeploy the previous version through the normal path |
| Roll back configuration | A change to instructions, agents, MCP servers or model caused degradation | Revert the configuration pull request or pin the previous model |
| Pause | Cause unknown and impact growing | Stop new assignments to the affected repositories or agents |
| Escalate | Security concern, data affected or customer impact | Follow the incident process; involve security and owners |
Configuration rollback deserves emphasis. Because instructions, custom agents and much of the agent configuration live in the repository, a bad change can be reverted like code. Settings that live outside the repository, such as model choice, MCP server configuration or firewall rules, should be documented with their previous values so they too can be restored.
Runbooks
A runbook tells whoever is on duty what to do when a known problem occurs. For agents it need not be long. Tidewater's fitted on one page: where to look for sessions and their logs; the baseline rates; what counts as a stall; the menu of recovery patterns; who can pause assignments and pin a model; and who to call for a security concern. Skerry's was longer, with a page per agent, because Skerry ran a dozen custom agents across hundreds of repositories, and it was linked from every custom agent file.
Lifecycle without disruption
The previous lesson covered the lifecycle from the audit point of view. From the operations point of view the question is how to change agents without disrupting the work that depends on them.
Adding an agent starts with a pilot: a few repositories, a few willing teams, a test set, and the same monitoring as everything else. Updating an agent, such as revising its instructions or adding a tool, goes through a pull request, runs the regression suite, and rolls out gradually where possible, for example by changing a shared custom agent in one organization before others. Replacing an agent or model runs old and new side by side on the test set first, then switches in one place so the switch can be reversed in one place. Retiring an agent announces the date, redirects its work, disables it and keeps its records.
Seraphine described how Skerry rolled out a new version of its shared security review agent. The new version lived on a branch of the shared configuration repository, and three pilot repositories pointed at it for two weeks while the platform team compared its review comments with the old version's on the same pull requests. Only after the comparison did the change merge for everyone, with a changelog entry and a one-line rollback instruction.
Capacity: the human side of operations
Agents can produce work faster than people can review it. A team that assigns more tasks than its reviewers can handle builds a queue of agent pull requests that go stale, conflict with each other and eventually get approved in a hurry, which is exactly the thin review that let the date bug through. MSBA-370 made the same point when choosing tasks. In operation, reviewer capacity is a resource to watch: the number of open agent pull requests, their age, and reviewer time per pull request.
Rosa, who had asked the question that started the guardrails lesson, tightened the review-capacity rule from the first course for TrailCheck: no more open agent pull requests in a repository than its maintainers can review in two working days, rather than in a week. When the queue is full, new tasks wait.
Service levels for agent work
Once agents are part of daily work, people start depending on them, and dependence brings expectations. A team that relies on overnight agent runs for dependency updates notices when they stop. Skerry's platform team wrote informal service levels for its shared agents: how soon a broken shared configuration would be rolled back, how quickly an escalation from an agent would be looked at during working hours, and how much notice teams would get before a shared agent changed or was retired. They were not contracts, but they told teams what to expect and told the platform team what to monitor.
Tidewater, being small, needed only one rule, written by Priya into the runbook: if agent results look wrong for more than a day, pause new assignments in that repository and say so in the team's discussion. Work does not stop; it goes back to people while the cause is found. That rule, and the willingness to use it, is what makes it safe to depend on agents at all.
Reviewing the operation
Operations improve through regular review. Once a month Tidewater looked at the rates, read a sample of failed and stalled sessions, checked the queue of open agent pull requests against Rosa's capacity rule, reviewed the repository facts list and instruction files, and decided on at most two changes. The meeting took half an hour and fed directly into the test set and the tuning work from earlier in the course.
Common mistakes
MistakeJudging agents by anecdotes from a bad day.
InsteadWatch rates against baselines and compare with test-set results.
MistakeRetrying a session that failed in setup.
InsteadFix the environment or setup steps first; retry only transient failures.
MistakeHaving no rule for stalled sessions.
InsteadDefine a stall, such as no progress for a set time, and check for it.
MistakeLeaving model and MCP settings undocumented.
InsteadRecord their values so configuration can be rolled back.
MistakeAssigning more agent work than reviewers can handle.
InsteadLimit open agent pull requests to review capacity.
Summary and key terms
- Observe agents with throughput, quality and safety, process, and cost and time signals.
- Watch rates against baselines, not counts or anecdotes.
- Failed sessions announce themselves; partial sessions need plan comparison; stalled sessions need a time rule.
- Degraded behaviour often comes from changes outside the repository, such as a model change.
- Recovery patterns include retry, resume, take over, roll back code or configuration, pause and escalate.
- Runbooks, pilots, gradual rollouts and side-by-side comparisons keep lifecycle changes safe.
- Reviewer capacity is an operational limit on agent work.
- Observability
- The ability to see how agents are performing from the signals they and their environment produce.
- Baseline
- Normal values of a signal, used to judge whether a change is significant.
- Stalled session
- A session that neither finishes nor fails and shows no progress.
- Degraded behaviour
- A drop in agent performance across many sessions.
- Configuration rollback
- Restoring previous agent instructions, files, model or settings.
- Runbook
- Written steps for handling known operational problems.
- Reviewer capacity
- How much agent work people can review well in a given time.
Practice problems
Work each problem on paper first, then reveal the answer to check.
How did Lena distinguish degradation from bad luck?
Show answer
She compared the week's failure rate with the baseline: six of eleven against about one in eight.
Which recovery pattern fits a partial session with a sound plan and good commits?
Show answer
Resume: a new session that reads the plan and continues from the first unfinished step.
What was Rosa's capacity rule?
Show answer
No more open agent pull requests in a repository than its maintainers can review in two working days.
Lesson quiz · 5 questions
Score 60% or more to complete this lesson.
Create a free account to save your progress, take quizzes and earn a certificate.