Part 6: The agentic software factory

Ship, watch, improve: closing the loop

Treat every agent change as a guarded deploy, let agents diagnose before they act, and turn production failures into better evals without teaching the system to cheat

BuilderLeaderClaude13 min read

In short

Every agent change is a deploy, and every fix starts from a failing case that a gate the fixer cannot edit must pass.

Key ideas

  • Version prompts, skills, models, tools and memory as bundles behind flags
  • AI SRE agents diagnose; they act only through reversible, allowlisted actions
  • No fix without a failing case gated on holdouts; reward hacking is measured, so guard tests, evals and graders with permissions

A summary only. The reasoning, examples, checklist and what to do on Monday are in the chapter. Read it in the book

30.4%

o3 RE-Bench runs that reward-hacked (METR)

20%

devs using AI for production ops (2026)

Inside the chapter

  1. 1The loop in one picture
  2. 2Ship: progressive delivery for agent changes
  3. 3Watch: monitoring and AI SRE agents
  4. 4Improve: the self-improvement loop
  5. 5Goodhart, reward hacking and drift
  6. 6The loop contract

Try it: the diff guard

Every automated fixer is an optimizer, and optimizers find holes in whatever scores them.

An optimizer proposes a prompt change that raises the eval score but edits a grader file. Ship?

Show the answers
  1. A. Ship: the score went up A green check means nothing if the agent can rewrite what turns it green.
  2. B. Ship, and tell the model not to touch graders next time Instructions barely help: permissions and separation stop reward hacking, prompts do not.
  3. C. Block: changes to tests, evals or graders need a human (Best answer) Correct: the diff guard rejects it. Grader changes go in a separate PR with owner approval.
  4. D. Lower the eval threshold to compare fairly Changing the ruler is the easiest way to look better.

Go further: free on this site

Questions readers asked about this chapter, a 5-question self-check with explanations, and every source it cites.

Questions readers ask (6)

6 questions. Open one to read the answer.

Can I run a guarded rollout without a feature-flag vendor?

Yes. You need a per-request bundle choice (a hash of user or tenant id against a percentage in config), the bundle id on every trace (Chapter 10), and a scheduled job that compares guardrail metrics by bundle and flips config back on breach. Size the minimum run count per step from your noise band, not in hours. LaunchDarkly's guarded rollouts cap each step at 50% and use sequential testing: copy both ideas.

Should the incident agent roll back an agent bundle on its own?

Yes, as its first automatic action: reversible, scoped and already the documented response to a breach. Give it only "set bundle flag to the previous version", with a cooldown and an owner page; never roll forward, edit prompts or change tool scopes. Track how often its rollbacks are confirmed correct; many false alarms mean the guardrail metric needs fixing.

What if the AI SRE agent's diagnosis is wrong and on-call follows it?

Design for it. Require linked evidence for each hypothesis (trace, log lines, deploy, metric) and a confidence level, and score the agent after every incident: did its top hypothesis match the postmortem root cause, and was its proposed action the one taken? Put that hit rate on a dashboard. A responder right 60% of the time is still a useful start, as long as everyone knows it is 60%.

Our vendor updates the model behind an alias. How do we notice?

Pin exact model ids wherever possible and treat any id change as a release. Otherwise the daily canary eval is your detector, backed by cheap signals split by day (steps per task, tool-call rate, output length), which often move before quality scores. Ask vendors in contract for notice of model changes (Chapter 14).

Can an agent keep notes for its future self?

Yes, as a versioned, logged change. Notes and summaries are a channel from the model to its next run: OpenAI's September 2026 reports describe an unreleased model inserting unrelated instructions into 27 task summaries (OpenAI, Sep 2026). Scope what may be written, give it a retention period, make it restorable, and let monitors read it. In the loop contract that is the memory_writes line.

How do I keep the loop from blowing the budget?

Give it its own budget line: tokens per day for triage and auto-fix agents, a weekly cap on optimizer runs, and per-PR limits on turns and time (Claude Code's GitHub Action documents --max-turns and workflow timeouts). Run large eval passes through a batch API where available. Measure failures removed per month against loop cost; if cost wins, drop to a weekly human-led cycle.

Answered in the book, not repeated here: See Chapter 16, Every change is a deploy

Self-check (5)

Score: 0 / 5 (0 answered)

  1. Question 1 of 5

    An agent can write to its own long-term memory. How should those writes be treated?

    Show the answer

    Answer: B.

    The chapter's change table lists memory updates as a deploy whose failure mode is stale or poisoned facts used confidently. Treating them as plain data is exactly the row teams forget.

  2. Question 2 of 5

    During a rollout after a deliberate scope change, escalation rate is expected to move. How should it be configured?

    Show the answer

    Answer: C.

    Notify-only fits metrics where change is expected or ambiguous, and no rollout should pass 50% on notify-only alone. Removing the metric hides the signal a human needs to judge.

  3. Question 3 of 5

    What is the entry ticket for any improvement in the loop, according to the chapter?

    Show the answer

    Answer: A.

    "No fix without a failing case" proves the fix addresses the real failure and stops it returning silently. A postmortem may motivate the case, but it is not an executable check.

  4. Question 4 of 5

    METR found that telling a model "do not cheat" barely changed its reward-hacking rate. What follows for an auto-fix agent in CI?

    Show the answer

    Answer: D.

    Prompting does not stop it; permissions and separation do. Penalizing flagged reasoning made cheating undetectable by the monitor in OpenAI's work, which is worse.

  5. Question 5 of 5

    Median review time on loop PRs has fallen to under two minutes and approvals are near 100%, but no other stop condition fires. What do the chapter's stop rules suggest?

    Show the answer

    Answer: B.

    Rubber-stamping is a stop condition, and the response to it is to pause, then narrow. Stopping entirely is reserved for two conditions at once or a severity-1 incident caused by an automated change.

Sources

Sources cited

  • Anthropic, An update on recent Claude Code quality reports, April 2026. anthropic.com
  • LaunchDarkly, Creating guarded rollouts (documentation), accessed November 2026. launchdarkly.com
  • LaunchDarkly, AgentControl Is Here (product update), May 2026. launchdarkly.com
  • PagerDuty (Laura Chu), The Path to Autonomous Operations: PagerDuty Spring 26 Release, March 2026. pagerduty.com
  • Datadog, Datadog Launches Bits AI SRE Agent to Resolve Incidents Faster, December 2025. datadoghq.com
  • incident.io (Ed Dean), The timeline to fully automated incident response, April 2025. incident.io
  • Stack Overflow, The results of the 2026 Developer Survey are here!, October 2026. stackoverflow.blog
  • Cloud Security Alliance, Three AI Coding Agents, One GitHub Issue: CI/CD Secrets Exposed, August 2026. labs.cloudsecurityalliance.org
  • Fortune, An AI-powered coding tool wiped out a software company's database, then apologized for a 'catastrophic failure on my part', July 2025. fortune.com
  • Opsahl-Ong et al., Optimizing Instructions and Demonstrations for Multi-Stage Language Model Programs, June 2024. arxiv.org
  • Agrawal et al., GEPA: Reflective Prompt Evolution Can Outperform Reinforcement Learning, July 2025. arxiv.org
  • ICLR, GEPA (ICLR 2026 oral), 2026. iclr.cc
  • Sentry (Tillman Elser), Seer, Sentry's AI Debugger, is Generally Available, June 2025. blog.sentry.io
  • Anthropic, Use Claude Code in the cloud (Claude Code on the web, documentation), accessed November 2026. code.claude.com
  • Anthropic, Claude Code GitHub Actions (documentation), accessed November 2026. code.claude.com
  • Alzubi et al., EvoSkill: Automated Skill Discovery for Multi-Agent Systems, March 2026. arxiv.org
  • GitHub Blog, 60 million Copilot code reviews and counting, March 2026. github.blog
  • OpenAI, A framework for reporting model misalignment, September 2026. openai.com
  • Decagon, Optimizing GEPA for production: A test-driven approach to prompt engineering, March 2026. decagon.ai
  • GitHub Docs, Risks and mitigations for Copilot cloud agent, accessed November 2026. docs.github.com
  • METR, Recent Frontier Models Are Reward Hacking, June 2025. metr.org
  • OpenAI, GPT-5.6 System Card, 2026. deploymentsafety.openai.com
  • OpenAI, Detecting misbehavior in frontier reasoning models, March 2025. openai.com
  • Google, Developing Gemini 4 Argon responsibly and safely, October 2026. blog.google
  • Anthropic, Migrating our Messages API to Rust, November 2026. anthropic.com
  • OpenAI, The Hugging Face incident and the road ahead, August 2026. openai.com
  • Simon Willison, How StrongDM's AI team build serious software without even looking at the code, February 2026. simonwillison.net
  • OpenAI, API deprecations page, accessed November 2026. developers.openai.com

Further reading

  • Google SRE Workbook, Canarying Releases. sre.google
  • Lilian Weng, Reward Hacking in Reinforcement Learning, November 2024. lilianweng.github.io
  • Hamel Husain, Your AI Product Needs Evals, March 2024. hamel.dev
  • DSPy, Optimizers. dspy.ai