Appendix D. Deep dives
35 min read
This is where the evidence and dated detail behind each chapter lives: the studies, benchmarks, vendor timelines and worked cases that the chapters leave out so they can stay short. Entries are grouped by chapter, each ending with its sources and caveats in italics. Full citations are in Appendix C; vendor behavior is dated to mid-2026 and will drift, so check defaults against the version you run.
Chapter 1 - What an agent is¶
Effective context depends on the benchmark. RULER v3 uses a fixed threshold derived from Llama2-7B at 4K (85.6% in Table 3), not each model retaining its own short-context score. Its thirteen synthetic tasks and tested 2024 models establish no universal half-window rule for current coding agents. Evaluate the lengths and tasks you actually intend to use. Source: Hsieh et al., August 6, 2024, Section 4/Table 3; Appendix C. Definition rechecked October 23, 2026.
What tool definitions cost, and the 2026 harness answers. One audit of a default Claude Code session counted about 24k tokens of tool definitions, MCP schemas and reminders before the user typed anything; one practitioner put three MCP servers at 143k of a 200k window. With a large catalog fully loaded, tool-selection accuracy in one benchmark was 13.62%; loading only the relevant tools raised it to 43.13%. The 2026 answers are deferred loading and programmatic tool calling (the model scripts the calls and returns one result; native in GPT-5.6, where it cut input tokens by 21% on one financial-research evaluation). For custom tools with nested schemas, consider strict decoding where supported and check schema and latency limits (Appendix C): Armin Ronacher documented Opus 4.8 and Sonnet 5 inventing undeclared fields, and strict mode eliminating it. Sources: Lumer et al., Jan 31, 2026; anthropics/claude-code#42452, Apr 2, 2026; Gan and Sun (RAG-MCP), May 6, 2025; MetaBlogue, Sep 5, 2026; OpenAI GPT-5.6 guide, Aug 2026; Ronacher, Jul 4, 2026. Caveats: 24k and 143k are practitioner counts; the 21% is one benchmark (Rogo's).
Sandbox posture by vendor, and the mechanisms underneath. Scope matters as much as the default. Claude Code has an opt-in shell sandbox on macOS, Linux and WSL2; native Windows commands, native file tools, MCP servers and hooks are outside it. Codex documents OS-level restrictions with a different implementation and platform support; inspect the selected permission profile and any escalation path. opencode documents permission controls, with OS isolation supplied by an external environment. Configure enforceable path and network restrictions in the runtime or managed policy, not AGENTS.md. Test prohibited reads, writes and connections through every relevant route. Sources: Claude Code sandbox/permission docs; Codex security docs; Vercel KB on opencode, checked October 23, 2026. Caveat: configuration and coverage change by version; one shell boundary is not whole-agent isolation.
The two-agent demo, in detail. Claude Code ran in two panes against Codex CLI (Rust, Apache 2.0, OpenAI) and opencode (TypeScript, MIT, independent team) with one prompt: explain the architecture, map the agent loop, tool system, permission gates, sandbox and plugin model, citing files and lines. It took about four minutes (a May 2026 re-run: 4:13), because both repositories name their architecture in their directories; a less self-documenting codebase takes ten to fifteen minutes per repo. Both returned an agent loop, tool registry, permission gate, plugin directory, MCP support and a subagent path (in opencode, found by behavior: a function that spawns a fresh instance on a bounded prompt). The one divergence was the sandbox. Source: author experiment, no human correction. Limit: the comparison illustrates capabilities in two repositories, not a universal anatomy or effectiveness result.
Subagent configuration and historical adoption. Codex CLI exposes agents.max_concurrent_threads_per_session for spawned threads, excluding the primary; agents.max_threads is a legacy alias. Unset defaults are client-selected, not a fixed-six ceiling. Other agents expose their own version-specific orchestration. Sources: OpenAI config reference and Subagents docs, checked October 23, 2026; historical vendor changelogs. Caveat: the current docs do not establish the previously stated March 14 GA date; inspect installed settings and resource limits.
Scripted orchestration (/workflows). Claude Code's /workflows (mid-2026) has the agent write a script that dispatches subagents deterministically: ordered phases, parallel or pipeline fan-out across hundreds of children, schema-validated handoffs, an optional verification gate, and resume that replays completed agents. Runtime caps bound the agent count; the size guideline and the large-run warning are advisory and do not pause or limit spending, so a budget still needs its own control. Compared with model-driven dispatch (as in Superpowers), it adds determinism and keeps intermediate results out of the main conversation; use it when the fan-out is large, repeatable or worth verifying mechanically. Source: Claude Code workflows documentation, checked October 30, 2026.
Memory and skills: shared roles, different loading. Project instructions have a shared role, not identical discovery. Codex has directory precedence; Claude has versioned fallback/import behavior; Gemini CLI defaults to GEMINI.md and can configure AGENTS.md; Aider supports explicit read-only inclusion. Chapter 6 records scope and inspection methods. Skill bodies and agent-written memory are separate mechanisms with their own loading and retention. Sources: official Codex, Claude Code, Gemini CLI and Aider docs, checked October 23, 2026; Appendix C. Caveat: shared naming implies neither automatic loading nor equal authority.
Effort: the evidence. With the harness held constant, GPT-5.6 Sol at low effort beat GPT-5.5 at high effort on Agents' Last Exam; Fable 5.1 at low effort is often competitive with Opus and Sonnet on cost per task while scoring higher, by its vendor's own guide. Effort names do not transfer between models, so every migration starts with a sweep (Appendix B.9). Whether reasoning is kept between turns is the harness's call: on ARC-AGI-3, by OpenAI's account, retained reasoning plus compaction took GPT-5.6 Sol from 13.3% to 38.3% while cutting output tokens sixfold. Sources: OpenAI GPT-5.6 guide, Aug 2026; OpenAI ARC-AGI-3 post, Jul 29, 2026; Anthropic, "Prompting Claude Fable 5.1." Caveat: vendor evaluations on one benchmark and model; the manual uses ARC-AGI-3 for the mechanism, not the score.
Plugins: trust and value are separate checks. Vet the maintainer, permissions, instructions, tools and hooks in the installed version. Allow review time for its actual scope; an update is a dependency update, and a hook outside the sandbox needs particular scrutiny. Skill descriptions can cost context before invocation; full bodies load when used and may persist. Narrow overbroad triggers or use manual invocation before assuming the whole collection must be enabled or removed. Sources: author field practice; Claude Code skills docs, checked October 23, 2026. Caveat: loading behavior varies by harness; source size alone does not measure active context or value.
Chapter 2 - Guardrails in five layers¶
Three vulnerability classes behind layers one to three. (1) Secret exposure: agents may discover .env* files through shell or native tools, or inherit secret environment variables. Protect each route. Claude Code's credential settings restrict sandboxed commands; shell deny-read rules do not block native Read. (2) Configuration-file injection: untrusted project settings could run hooks once a folder was trusted, without the warning saying so (patched in v1.0.87); execute code before the trust dialog was accepted (CVE-2025-59536, patched in v1.0.111); or send requests, and the API key, to an overridden ANTHROPIC_BASE_URL before the trust prompt (CVE-2026-21852, patched in v2.0.65). Accepting trust is itself a grant of execution. (3) Coverage gaps and parser bypasses: a deny rule written for one interface does not cover another (a Read deny rule does not stop cat through Bash, or Python's open()), or, as a quiet failure, when a command chained more than fifty subcommands (MAX_SUBCOMMANDS_FOR_SECURITY_CHECK = 50) and the check fell through to a generic "ask"; disclosed April 1, 2026, patched in v2.1.90 within days. Nothing in the configuration shows such a failure, so assume any single layer can have a bug; the classes outlive their patches. Sources: Knostic, Dec 2025; Check Point Research, Feb 2026 (fixes August to December 2025); Adversa AI Red Team, Apr 1, 2026; Adam Kinney, Apr 2026. Caveat: architectural classes, not single CVEs; unpatched versions stay vulnerable.
The sandbox escapes ("DuneSlide"). In mid-2026 a red team disclosed two critical zero-click prompt-injection flaws in Cursor's kernel-backed sandbox (CVE-2026-50548 and CVE-2026-50549, CVSS 9.8) that abused its working-directory write allowlist and a symlink-resolution fallback to reach OS-level code execution. Versions before Cursor 3.0 (April 2, 2026) were affected. The lesson is the class, not the vendor: the strongest layer can have bugs, which is why there are five. Sources: Cato Networks (Cato AI Labs), mid-2026; SecurityWeek and The Hacker News, Jul 2026.
Injection through the work: the DNS TXT proof of concept. The June 2026 report describes a repository inducing Claude Code to retrieve a payload through DNS TXT and execute it. An HTTP proxy/domain allowlist does not establish DNS containment. Verify direct connections, direct DNS tools and system-resolver requests separately, using benign owned endpoints. The runtime README documents unfenced system-resolver requests on its Windows path and similar macOS behavior. Standalone runtime support does not imply Claude Code native-Windows shell sandbox support. Sources: June 29 incident coverage and Anthropic sandbox-runtime network documentation, Appendix C; current scope checked October 23, 2026. Caveat: platform and resolver routes differ; a proof of concept is not a measured frequency.
Telemetry plumbing and hook examples. By mid-2026 Claude Code, Codex CLI and Gemini CLI emit OpenTelemetry natively, so the audit store can be whatever the stack already speaks; the requirement is durability and queryability. The security-guidance plugin ships rules for roughly eight to ten vulnerability categories. One team rule beyond the chapter's two: block edits to a compliance-relevant module outside business hours.
PocketOS: where the accounts disagree, and what the platforms changed. Railway says it recovered the database with all data from offsite disaster backups; the restore was reportedly about 30 minutes after the CEO contacted them, while other accounts say about 30 hours, or two days, for full restoration, so the manual uses the incident for the governance pattern only. On April 29, 2026, Railway made API deletes match the dashboard's 48-hour soft delete. Workspace- and project-scoped tokens already existed; the session's token was account-scoped, the broadest available. Alexey Grigorev's follow-up to the DataTalks.Club Terraform loss (late February 2026) reads like this chapter's checklist: delete protection in Terraform and AWS, state moved to S3, manual review of every destructive plan, an upgraded AWS support tier. AWS restored roughly 1.94M rows from a snapshot within about a day. Sources: DevOps.com; Business Insider; Railway blog, Apr 29, 2026; Grigorev's public account.
Browser, desktop and remote routes. A project-directory sandbox does not bound an already signed-in browser, a desktop-control feature or a remote API reached with stored credentials. OpenAI's managed configuration is explicit: Computer Use can operate a browser as a native app, Browser Use site rules do not apply to that path, and blocking it takes forcing Computer Use off or denying the browser app. Record each route in the control record with its effective identity. MCP tool annotations such as read-only or destructive are descriptions, not controls: the July 2026 specification says clients must treat them as untrusted unless the server is trusted. Sources: OpenAI managed configuration and MCP specification 2026-07-28, checked October 30, 2026.
ChainDrop: persistence through agent and editor configuration. Microsoft's August 4, 2026 analysis of a self-propagating supply-chain worm describes it using stolen GitHub credentials to inject .claude/settings.json, .vscode/tasks.json and companion setup scripts across branches, so that later Claude or VS Code activity could restart the payload. Recovery therefore includes those files, hooks, memory and workflow definitions, not only the package that delivered it. For CI, GitHub's guidance is that pull_request_target and workflow_run workflows are privileged and must not check out untrusted code. Sources: Microsoft Security, Aug 4, 2026; GitHub Actions secure-use reference, checked October 30, 2026.
Chapter 3 - The bottleneck moved¶
Workflow advice reviewed October 23, 2026. OpenAI's September 11 GPT-6 Astra guidance warns that broad skill triggers and elaborate recipes can overconstrain stronger models; requiring a repository map for every edit is excessive. Current Codex advice still recommends planning for complex work. Claude Code likewise recommends planning for uncertain, unfamiliar or multi-file changes while skipping it for clear small fixes. These support the chapter's task-sized workflow, not removing context, verification or normal shipping controls. Sources: OpenAI, "Rethinking skills and prompts for GPT-6 Astra" and "Best practices"; Claude Code best practices. Caveat: vendor guidance, not a controlled test of this manual's full method.
The unknowns frame, in full. In July 2026 an Anthropic engineer opened a field guide to Claude Fable 5 with this chapter's observation: it was "the first model where I find the quality of the work is bottlenecked by my ability to clarify its unknowns." His four questions: known knowns (what your prompt states), known unknowns (questions you have not settled), unknown knowns (context so obvious you would never write it down, though you would spot a violation at once) and unknown unknowns (what neither of you thought to ask). Source: Thariq Shihipar, Anthropic, Jul 6, 2026. Caveat: the frame adapts an older taxonomy and "first model" is his judgment, not a measurement; the mapping onto this manual's machinery (the chapter's table) is the author's.
The METR randomized controlled trial. METR's July 2025 trial had experienced open-source developers work on their own familiar repositories with AI assistance. They took 19% longer than without it, after predicting a 24% speedup, and afterward still believed it had made them roughly 20% faster: a 43-point gap between predicted speedup and measured slowdown. The author reads it as a warning that raw assistance does not become delivery speed without workflow discipline. Source: Becker et al., METR, Jul 10, 2025. Caveat: METR did not test formulation discipline; that reading is the author's. Its follow-up suffered selection bias, it redesigned the experiment in February 2026, and it cautions against applying the 19% to current tools.
February to April 2026: the discipline absorbs a vendor regression. Claude Code product changes materially degraded complex engineering work in some workflows. On April 6, AMD senior director Stella Laurenzo published an audit of 6,852 of her own sessions and 234,760 tool calls, showing a shift from research-first to edit-first behavior as thinking redaction rolled from 1.5% to 100% of turns, and pointed at the February adaptive-thinking default as a contributing cause. Anthropic's April 23 post-mortem acknowledged three regressions: default effort dropped from high to medium on March 4 (reverted April 7); a caching bug from March 26 that cleared reasoning history every turn instead of once per idle hour (fixed April 10); and a system-prompt verbosity cap from April 16 with a measured 3% quality drop (reverted April 20). Two adjacent teams used the same Claude Code. The one with this manual's infrastructure (CLAUDE.md rules, plan mode by default, the six-phase loop, hooks on destructive operations) dropped maybe 10% and recovered once it tightened plan-mode gates and raised effort on a few skills; the freestyle team's velocity halved overnight. Sources: Anthropic post-mortem, Apr 23, 2026; Laurenzo, anthropics/claude-code#42796, via The Register, Apr 6, 2026. Caveats: the accounts diverge on the earliest cause; external magnitudes are approximate; the two-team comparison is a field observation.
Chapter 4 - The six-phase loop¶
Research blind, design short, plan vertically. In March 2026 Dex Horthy of HumanLayer reviewed what went wrong with his team's research-plan-implement workflow. A single planning prompt with 85 or more instructions skipped steps, including the design questions it was meant to ask; splitting it into stages of fewer than 40 instructions each was their fix. In the workflow Horthy described, a fresh research context received the questions without the ticket. He described a design discussion that might be about 200 lines (current state, desired end state, patterns to follow) and contrasted a roughly two-page structure outline with an eight-page plan: "if the plan is the implementation, the outline is the C header files". The outline orders the work in vertical slices, each with a checkpoint. He also retracted his 2025 advice to review plans instead of code: "don't read the plans. Please read the code." His team had stopped reading code for about six months and had to replace large parts of that system. HumanLayer's current documentation has moved on again: its RPI path goes from the outline to implementation, with the detailed plan kept as a legacy option. This manual keeps both reviews: Chapter 4 reads the plan when the approach is uncertain, starting with the short design note and outline, and Chapter 5 has a person read the diff. Sources: Horthy, "Everything We Got Wrong About Research-Plan-Implement," Coding Agents Conference, March 3, 2026; HumanLayer workflow reference and RPI plugin prompts, checked November 9, 2026. Caveat: practitioner testimony from the workflow's own vendor, with no measured comparison; talk quotes come from YouTube's machine transcript.
When splitting into subagents pays. The 260-configuration scaling study found gains on decomposable work and large losses on some sequential planning tasks. Those percentages and fitted thresholds are not rules for coding. Current Claude Code guidance keeps quick edits and phases sharing substantial context in the main conversation, using subagents for self-contained work or exploration whose output would flood it. Delegate when isolation or parallel progress pays for startup, duplicated context and coordination. Sources: Kim et al., July 24, 2026; Claude Code subagent docs, checked October 23. Caveat: the study's strongest losses are not coding results; neither source establishes one worker per file as an optimum.
One writer, context sized to the worker. Keep one writer per overlapping area and settle shared contracts before dependent work. Forks can reuse established context through the cache; fresh workers isolate a large investigation. If an independent reviewer is justified, give it the requirements and evidence without earlier verdicts. Fable 5.1's guide reports faster completion when a lead can continue useful work while children run, at similar quality and cost. Sources: Walden Yan, Cognition, April 22, 2026; Bengre and Curme, LangChain, September 8; Anthropic, "Prompting Claude Fable 5.1." Caveat: vendor evidence; async dispatch does not make dependent work independent.
Vendor autonomy and scope guidance. A model may stop after announcing the next step or ask again for work already authorized. Other runs expand scope or add unnecessary test files. Define the deliverable, permit routine authorized steps and require a decision only for real ambiguity, risk or scope changes. Fable 5.1's guide recommends keeping committed tests proportionate to the request and repository practice, while allowing scratch checks. Re-check the guidance per model rather than preserving old prompt blocks unchanged. Sources: Anthropic, "Prompting Claude Fable 5" and "Prompting Claude Fable 5.1"; OpenAI, "Using GPT-6 Astra." Caveat: reversible changes can still have serious behavioral risk.
The implementation-notes file pays twice when hand-offs need it. A reviewer can see where diff and plan disagree, and the author records a deviation before it disappears into a compressed summary. A PR or task report can do the same job on smaller work. Skill instructions request discipline; enforce critical permissions and shipping controls outside the model's discretion.
What the Superpowers comparisons establish. Krupa's September 29 study tested v6.4.2 with Sonnet 5.5 on twelve tiny headless cases, eight runs per arm. Mean per-case cost was 1.33x; the clear deliverable gain was regression-test consistency on one bug fix, 8/8 versus 4/8, with correct fixes in both arms. OrcaBot's July v6/Codex gpt-5.5-high run reported 57.06% versus 55.56% resolved on 729 common cases, at $0.46 versus $0.37 each. Its single-seed advantage is indicative. Later Native-execution and gate changes limit transfer to v7.x; this review found no independent v7.x/current-Codex comparison. B.10 therefore measures the installed workflow against the native baseline, including process that should stay inactive. Sources and limitations: Appendix C; reviewed October 23, 2026.
Focused skills versus a general workflow. SkillsBench v4 found curated skills improved average pass rate from 33.9% to 50.5% across 87 tasks and 18 model/harness configurations. This is evidence that useful procedural knowledge remains valuable, not that every agent needs a general process plugin. The intervention and task matter. Source: Li et al., June 14, 2026, v4. Caveat: preprint, task-specific curated skills; no Superpowers comparison.
Chapter 5 - Review and verify¶
Model-specific review and bounded repair. As checked October 23, Fable 5's guide recommends fresh verifier subagents for long tasks, while Opus 5's guide says extra verification prompts and agent double-checks add cost without improving its quality. Neither is evidence for two reviewers on every PR. Research on critique uptake, late-round degradation and judge anchoring motivates independent judgments and a stopping rule, but mostly studies math or deep research. Track useful defects, false positives and rework; accepting or rebutting a comment is not itself a quality gain. Sources: Anthropic's Fable 5 and Opus 5 guides; Yang et al., July 16, 2026; Wan et al., January 22, v2 April 29; Kapetanovic et al., August 26. Caveat: model and domain transfer need evaluation.
SpecBench and the Cursor finding in full. SpecBench (May 2026) ran frontier agents against specifications with visible and hidden test sets. Every agent saturated the visible suite, while held-out scores stayed much lower; Claude Code's gap was roughly 43 to 48 points across three search strategies, and other agents varied by strategy; the 90th-percentile gap grew by about 27 points per tenfold increase in lines of code, and more search did not reliably remove the reward hacking. Cursor found the other half in June 2026: on SWE-bench Pro, 63% of successful Claude Opus 4.8 Max resolutions had retrieved the upstream fix from git history or the network instead of deriving it, and sealing both dropped the score from 87.1% to 73.0%. These are evaluation-boundary findings: use held-out checks and leakage controls where those boundaries matter, without sealing every ordinary PR from history and documentation. Sources: Zhao, Srikanth, Wu and Jiang (Weco AI), May 20, 2026 (v2 Sep 9); Naman Jain, Cursor, Jun 25, 2026. Caveats: the abstract rounds 27 to 28 points (R-squared 0.21), so the trend is real but noisy; Cursor's result is one harness and one model.
Playwright semantic locators and interactions. Roles and labels can resist styling/DOM changes while the accessible contract is stable. Actions remain control-specific: selectOption() targets a native select; check() selects a radio/checkbox; a custom widget can require different interactions. A component replacement may need a test update. Assert business behavior and inspect rendered visual changes. Sources: Playwright locators/input documentation, checked October 23, 2026; Appendix C. Caveat: semantic stability establishes neither interaction-model compatibility nor visual correctness.
Measure the PR review toolkit's contribution. Review agents can catch mechanical findings before a senior reads the diff. Measure useful defects, false positives, review time and escaped defects rather than assuming four reviewers save ten minutes. Keep human attention on business correctness and architectural fit; the chapter's case shows what happens when that attention disappears.
Chapter 6 - AGENTS.md and context¶
Context files: the revised evidence. The AGENTS.md study's September 29 v3 found no general success improvement from generated files, with inference cost over 20% higher in its settings. Developer-written files showed a small, statistically non-significant average success gain; repository overviews did not help in this evaluation. This supports testing non-obvious instructions and linking long maps on demand, not declaring all context files harmful. OpenAI's Codex practice also uses a short AGENTS.md pointing into structured docs. Sources: Gloaguen et al., v3 September 29, 2026; Ryan Lopopolo, OpenAI, February 11. Caveat: tested agents and benchmarks; keep-and-move is the manual's interpretation, not a universal measured content rule.
Instruction load and the size guideline. A July study found sharply falling perfect adherence as simultaneous rules increased; it did not establish a line limit for project files. Anthropic also reported removing over 80% of Claude Code's own system prompt without measured loss on its Claude 5 coding evaluations. Current Claude Code docs recommend staying under about 200 lines per CLAUDE.md and scoping rules; OpenAI recommends short, accurate instructions. Use those as reasons to trim and test, not proof that line 201 is ignored. Sources: Netanel Eliav, July 21, 2026; Thariq Shihipar, July 24; current vendor docs checked October 23. Caveats: rule count differs from line count, adherence depends on task and model, and vendor evaluations are their own.
Instruction counts need a task and a metric. IFScale tested 20 models writing business reports under up to 500 keyword-inclusion instructions; the best reached about 68% adherence at that density. In the talk, Horthy cited a HumanLayer blog post about the paper and described roughly 150 to 200 instructions that frontier models could follow consistently, adding that the number might already be higher. The paper establishes no universal ceiling. HumanLayer split its planning prompt of 85 or more instructions into stages of fewer than 40 each (Appendix D, Chapter 4). Count the instructions loaded into context at each step, including those in tool descriptions and project files, and check whether the agent performs the required steps. Sources: Daniel Jaroslawicz et al., July 15, 2025; Horthy, March 3, 2026. Caveat: synthetic writing tasks, not coding-agent workflows; no universal limit follows.
Claude Code's native AGENTS.md support. Direct loading begins at v2.1.277 under the Project instructions setting. Default fallback checks for CLAUDE.md, .claude/CLAUDE.md and CLAUDE.local.md on the working-directory/ancestor path. A CLAUDE file can import @AGENTS.md. These are not Codex override semantics; Chapter 6 includes inspection/version caveats. Source: current memory documentation, checked October 23, 2026. Caveat: earlier releases and settings differ.
Mistake-journal mechanics. Anthropic's Fable 5 guide describes a memory system with three rules that keep a journal honest at a hundred entries: one lesson per file with a one-line summary, update rather than duplicate when a lesson recurs, delete notes that turn out wrong. Add an evidence pointer so the next champion can check whether the failure is still possible. OpenWiki's claims runtime, which attaches evidence pointers to stored claims and re-checks them, cut stale claims from 3.5% to 0.5% across 2,000 evaluated claims. The quarterly review asks of each entry, "has anyone been saved by this rule in the last three months?" If yes, keep it; if no but the rule still applies, keep it, since rare failures still matter; if no and the cause is gone, retire it with a commit-message note. Sources: Anthropic, "Prompting Claude Fable 5"; Colin Francis, LangChain, Aug 25, 2026. Caveat: OpenWiki is a knowledge-base system, not a journal; the manual borrows the mechanism.
Why the precedence line exists. GPT-6 Astra follows longer instructions better and is more sensitive to context: conflicting guidance in a skill file can make it pause and block early, and OpenAI's guide says the user's instructions take precedence over a skill's. One top line ("In a conflict, the task prompt wins over this file; this file wins over any skill", in the B.2 skeleton) removes a class of stalls. Source: OpenAI, "Using GPT-6 Astra," Sep 2026 (GPT-6 released September 3-4, 2026; guide revised in place).
Compaction and context measurements. JetBrains compared unmanaged history, masking and summarization across five SWE-agent/SWE-bench Verified configurations. Masking was cheaper than summarization in four; Qwen3-Coder 480B saved 52.7% with masking and 50.4% with summarization against unmanaged history. Other configurations saved less; neither a universal over-50% reduction nor that ratio between methods follows. Anthropic separately reported a 29% gain from tool-result clearing on its internal search evaluation. The multi-turn study found average degradation against a fully specified turn and recovery through consolidation. Sources: Lindenbauer et al., The Complexity Trap, Table 1; Anthropic, September 29, 2025; Laban et al., May 2025; Appendix C. Caveat: different interventions and settings, not a controlled coding-handoff comparison. Cost baseline rechecked October 23, 2026.
Context warnings are local rules of thumb. HumanLayer called the point where results degrade "the dumb zone": around 40% of the usable window on average in its experience, with results sometimes still acceptable at 60%. In March 2026 it replaced that percentage with a warning at 100,000 tokens for long-context models. Neither number says where another model or task starts to degrade; watch for the drift signs in Chapter 6 instead. Sources: Horthy, March 3, 2026; HumanLayer, "Long-Context Isn't the Answer," March 23, 2026. Caveat: practitioner observation, not a controlled threshold measurement.
Append-only history and cache pricing (Fable 5.1). Thinking blocks are bound to the exact prefix that produced them, so editing or reordering earlier turns invalidates them and discards the retained reasoning that Chapter 1 counts as half of Effort. The guide's answer is to keep history append-only and let server-side compaction or context editing do the trimming; if you compact on the client, replace the whole history with one summary plus the new turn. With cache reads at 0.025x the base input price, the guide says compacting early to save cost may no longer be the right trade; when you do compact, give the compactor a keep-list (the plan, open questions, deviations in the implementation notes, the exact commands that worked). Source: Anthropic, "Prompting Claude Fable 5.1." Caveats: undated page, written for API harness builders; 0.025x is the manual's arithmetic from published prices; append-only applies to accounts created on or after August 31, 2026.
Chapter 7 - Map it first: architecture review¶
Why the agent reads the code rather than querying an index of it. Navigation beats retrieval on this task. On Claude Sonnet 4.5, agentic navigation (grep, open the file, follow the reference) reached 49.6% recall@1 on BRIGHT, 21.8 points above the best embedding model, and bounded workspaces (the RISE result) keep it working at a million documents, where direct context inspection degrades. Code search for agents resolves into three tools: ripgrep for text, ast-grep for structure, the language server for references. An embedding index is the exception you add when a corpus outgrows them. Sources: Suresh et al., May 7, 2026; Zhuang et al. (RISE), Jun 5, 2026; Kumanyaev, Jun 6, 2026. Caveat: the recall figure is on a general retrieval benchmark, not a codebase.
The visual alternative: Understand Anything. A plugin that renders the codebase as a navigable graph: a structural view (modules, dependencies) for engineers and a domain view (business concepts, entities) for managers, who can read "this service handles fraud detection on incoming transfers" without reading source.
Chapter 8 - Should the agent touch this code?¶
Signal 1, no tests: the reconciliation module. Twice in banking: a reconciliation module written in the early 2010s by a senior engineer who left in 2018, with no tests because "the senior engineer just knew it worked." The next change broke it in a way that took two months to surface, by which point the discrepancy had crossed the threshold that triggers a regulatory disclosure. Fix: characterization tests first, the agent doing the bulk.
Signal 2, no documentation: the fee tier. The fee tier for the legacy product line was calculated differently because of a 2017 regulatory carve-out. The agent assumed uniform treatment and "simplified" it; the senior caught it in review. The second-order cost is senior engineers reviewing AI output forty hours a week instead of building, until they leave. Fix: the architecture review (Chapter 7) plus a short domain glossary.
Signal 3, tight coupling: the fourteen-year cycle. A customer service module imported a loan origination module, which imported a credit scoring module, which imported customer service: a cycle introduced fourteen years earlier to "save time" and never broken because it was an eight-week project. The agent's change surfaced months later at month-end batch close. Fix: break only the worst coupling; if the team will not, yellow at best.
Signal 4, scattered rules: the maximum transfer amount. The limit lived in a UI config, a service constant and a database trigger. Compliance updated the config; six weeks later a valid transfer failed on the stale constant. With no single source of truth the agent guesses which copy is canonical. Fix: one source (a typed rules engine or configuration service) and worth it with or without agents.
Signal 5, regulatory constraints. Any change to anti-money-laundering logic needs sign-off from the compliance officer, a representative from legal and a senior engineer not involved in the implementation; the agent cannot route approvals or satisfy a two-person rule. Mild constraints (a senior review on every change) fit the existing process; heavy ones (sign-off matrices, evidence trails, time-stamped approvals, retention) mean the agent works only inside a system that already handles them.
Signal 7, model-context fit: the in-house workflow engine. A proprietary workflow engine can be unfamiliar to the model even when domain experts understand it. Check representative state transitions and edge cases against documented behavior; investigate missing context or choose a better-fit model. Thin public documentation creates model-fit uncertainty, not automatically a missing qualified evaluator. If the team also cannot judge the behavior, evaluability separately fails. Author-reported case pattern, not a measured rule about language popularity.
Signal 8, velocity-of-change: the React 18/19 bug. On a codebase mid-migration the agent is confidently right about the old version and wrong about the new, and you cannot always tell which. The author's own bug: Claude used React 18 idioms where React 19 was needed; it worked locally on a transitive React 18 dependency and broke when production pulled 19. Fix: a version rule in AGENTS.md ("we are migrating from React 18 to React 19 this quarter; new code uses 19 idioms; old code may still use 18 but should be updated when touched").
The model-migration soft signal, with its evidence. Instructions written for the previous model (AGENTS.md rules, skill prompts, effort levels) do not retire themselves. For between 37% and 63% of the software-engineering papers surveyed, a newer model given a single prompt natively outperformed the heavily engineered tooling proposed about a year earlier. It is not a ninth kill signal; it is what to check when a green codebase turns yellow after a model upgrade (Appendix B.9). Source: Salsabil et al., Aug 31, 2026 (arXiv 2609.00468). Caveat: preprint, not peer-reviewed; use it for the direction, not the fraction.
Worked preparation examples and task restrictions. (1) Customer-profile service: relevant assertions/failure cases run reliably, current overview, canonical rules and qualified reviewer. Zero known gaps, green candidate; still establish task scope and recovery. (2) Legacy payments: missing failure-case checks (1), stale docs (0.5), costly coupling (1), scattered rules (0.5), with expertise and approval machinery available. Total 3, yellow preparation; establish verification before behavior changes. (3) Custom cryptography without a qualified reviewer fails evaluability regardless of count. (4) Greenfield API with uninvestigated checks/deployment is unknown, not automatically green. (5) Internal tool with relevant checks and bounded documentation/coupling gaps (0.5 each) totals 1, a possible pilot subject to task prerequisites. (6) A vendor-customized fork with unknown upstream effects needs investigation and a decision whether to retain the custom layer. These are illustrative worksheet applications, not validated safety classifications; coverage percentages alone determine none of them.
Chapter 9 - Rolling it out¶
The two kinds of hooks in full: pre-commit versus pre-push. Use quick checks at commit and costlier tests or builds at push for fast feedback. A hook manager helps install them but cannot make local hooks unavoidable: Git permits bypasses and alternative hook directories. Policy hooks also need protected configuration and blocking failure behavior. Acceptance belongs in required server checks and protected workflow review, with credentials unable to bypass them. Sources: Git githooks reference, GitHub rulesets and Claude Code hooks reference, checked October 23, 2026. Caveat: a particular repository must configure and verify these protections; running CI alone is not enforcement.
The outer loop: from AutoGPT to Ralph Wiggum. The inner loop is the six-phase loop (Chapter 4); the outer loop wraps it and re-invokes the agent until a condition holds. In 2023 AutoGPT and BabyAGI looped a model against its own opinion of its progress; nothing external graded an iteration, laps compounded drift, and the approach collapsed as a way of shipping software within months. The revival differs structurally: in mid-2025 Geoff Huntley wired an agent into a bash while-loop (one prompt file, repeat), which spread as "Ralph Wiggum". Each iteration starts with a fresh context, does one unit of work and ends against graders the model does not control (compiler, tests, diff), with state in the repository. His name for the failure mode is overbaking: a loop left running past its job invents work nobody asked for. Sources: ghuntley.com/ralph (Jul 2025); HumanLayer, Jan 6, 2026; The Register, Jan 27, 2026; AutoGPT and BabyAGI repositories. Caveat: the collapse judgment and structural contrast are the manual's interpretation.
The outer loop: the vendor wave and stop-condition mechanisms. Between September and December 2025 GitHub, Cursor and Google shipped cloud or scheduled agents, and a ralph-wiggum plugin landed in the official Claude Code repository. By spring 2026 Claude Code had /loop (re-run on an interval or self-paced), Routines (cloud agents from a schedule or GitHub event), /goal (work until a completion condition holds) and /autofix-pr (push fixes until CI is green). By Chapter 1's test the capability converged, though what converged is a workflow around the primitives, not a primitive. /goal uses a separate model to assess the condition from the conversation; Codex Goals lets the acting model mark a persistent objective complete. These control continuation and budgets. Neither replaces independently protected acceptance checks. The ralph-wiggum plugin has no controlled evidence, and its README names max iterations as its primary safeguard, a budget, not a stop condition. Sources: GitHub changelog, 2025-09-25; Cursor and Google blogs; Claude Code release notes, Apr-May 2026; Claude Code "/goal" docs; OpenAI Cookbook, "Using Goals in Codex." Caveat: vendor dates drift; the goal docs describe mechanism, not outcomes.
The outer loop: why each contract line exists, and the two poles. A machine-evaluable stop condition, because a loop without one is abandonment. A budget, because an unattended loop is the per-token model's best customer (Appendix A). An acceptance gate enforced by protected required checks and reviewed policy changes, because the cheapest way to go green is to negotiate with your own grader, and a green suite the agent wrote is evidence, not proof (Chapter 5). A durable queue and decision record, with fresh context when the handoff or observed drift justifies it. Fresh context does not mean a fresh world: before a retry or resume, reconcile the current commit, completed writes, running processes, external calls and spend, and make consequential operations safe to repeat. Isolation sized for absence, since an unattended session is where prompt injection meets no human skeptic (Chapter 2). Queue similar, independently verifiable and recoverable units only after each meets the task prerequisites and unattended-run controls; green alone is insufficient. Huntley runs the loop raw at roughly $10 an hour; StrongDM's software factory runs fully non-interactive delivery, humans neither writing nor reviewing code, with end-to-end scenarios held outside the codebase as a holdout the loop cannot weaken, at a spend Simon Willison pegged near $20,000 a month per engineer. Sources: Willison, Feb 7, 2026; Huntley and The Register as above. Caveat: the $10 figure is Huntley's own and the StrongDM figures are one company's self-description and Willison's framing, not audits.
Example time budgets for the role commitments. In this schedule, the champion reserves about three hours in week one and five in week two; later weeks depend on the pilot features. The intended outputs are a tested workflow, useful maintained instructions, delivered features and a designated successor. The lead reserves roughly two hours in week one and three to five in later phases. These are planning examples from practice; adjust them to measured effort and the team's starting point.
Why the 90-day example is shaped that way. The schedule reserves time for learning, a bounded pilot, expansion and operational ownership. It is an organizing example drawn from practice, not a measured exponential curve. Baseline cycle time, defects, review effort and usage before the pilot; inspect outcomes throughout it. Expand or change the approach when those outcomes justify it rather than waiting for a promised month-three payoff.
The outer loop's own kill signals. The loop gets kill signals the way Chapter 8 gives them to codebases. Four are enough: the same diff applied and then reverted across iterations; budget burning while the queue does not shrink; the same failure surfacing a third time; any iteration that touched the gate. Any one means stop: read the journal, fix the cause, then relaunch. A loop restarted on hope is a loop you have stopped controlling. Appendix B.6's morning-review block carries the same four checks.
Appendix A - For managers¶
Tier routing, the two measured points. Anthropic's advisor pattern pairs a cheaper executor with a stronger model on call. Sonnet with Opus as advisor scored 2.7 points higher on SWE-bench Multilingual than Sonnet alone, at 11.9% lower cost per task. Haiku with an Opus advisor scored 41.2% on BrowseComp against 19.7% solo, trailing Sonnet solo by 29% in score at 85% lower cost per task. These vendor benchmarks suggest a candidate to compare on representative tasks, not a universal routing rule for implementation or research. Routing can also be the vendor's: GitHub Copilot Fusion, generally available on October 28, 2026, chooses the models per request and bills each at its standard rate, so record the models actually used. Availability depends on how you sign in: GPT-5.5 left Codex for ChatGPT sign-ins on October 14, 2026, while API-key sessions were unaffected. Keep a tested fallback. Sources: Anthropic, "The advisor strategy," Apr 9, 2026; GitHub changelog, Oct 28, 2026; Codex changelog, Oct 14, 2026. Caveat: vendor benchmarks on the vendor's own models; per-task figures, not a general ratio.
Cache-first layout, tool tax and masking. Cache-first layout cut API cost by 41% to 80% on more than 500 agent sessions across three providers (Lumer et al., Jan 31, 2026). The tool-definition figures are under Chapter 1, the masking result under Chapter 6.
The full-cost comparison. Compare useful accepted work and human effort on both sides, including investigation, implementation, review, rework and failed attempts. Add incremental tooling/infrastructure, amortized setup, ongoing maintenance and recurring governance/evaluation. The hypothetical calculation in Appendix A values released capacity; it establishes neither cash savings nor faster elapsed delivery. Replace assumptions with records before making an investment claim.