Skip to content
Forward Deployed

Forward Deployed

Agent That Adapts to New Tasks

Design an operations agent that learns new tasks on its own, adapting in the cheapest reversible place first and sending every self-change through the same gate as a human change.

Kind
Case study
Level
Advanced
Sections
5
By
Sourav Banerjee
Last updated
21 Nov 2026

Report an issue

Case brief

Understand the scenario, task, and constraints.

An operations agent that meets new work every week

An internal operations agent handles requests such as "restart service X" and "roll back flag Y". Teams keep shipping new systems, so new request types appear every week. The ask is an agent that adapts to those new tasks on its own, without a person retraining it.

That ask hides the hard constraint. Every change the agent makes to itself is a regression nobody reviewed. The agent needs freedom to change its behaviour, yet it must never quietly get worse, and it must never grant itself more permission, budget or irreversible reach. A design that only says "the agent learns from experience" has not addressed that constraint yet.

A few terms carry the whole case. A skill is a named, parameterised sequence of tool calls, such as safe_restart(service_name), with a precondition, a postcondition and a measured success rate. A rung is one place where learning can live, from the context of a single request up to the model's weights. The evaluation gate is the single checkpoint every learned change must pass before it touches live traffic. Shadow testing runs a candidate beside live behaviour on real requests without letting it act. A stratum is one slice of the evaluation set; here, one task type. An LLM (large language model) is the model that plans and writes the agent's actions.

The core idea fits in one sentence: adapt in the cheapest, most reversible place first, and send every self-change through the same gate as a human change. The figure shows that decision for a single request and for what the agent learns from it.

A new request runs with current skills when its type is known and in a tighter fallback mode when it is not; outcomes and lessons then pass an evaluation gate that promotes them to memory, a skill or a prompt, or discards and demotes them.Dark variant: A new request runs with current skills when its type is known and in a tighter fallback mode when it is not; outcomes and lessons then pass an evaluation gate that promotes them to memory, a skill or a prompt, or discards and demotes them.
A new request runs with current skills when its type is known and in a tighter fallback mode when it is not; outcomes and lessons then pass an evaluation gate that promotes them to memory, a skill or a prompt, or discards and demotes them. Open for full size.

The design treats adaptation as five rungs: context, memory, procedure, prompt optimisation and weights. Each rung is about ten times costlier and harder to undo than the one before, and we work from the cheap end. A runtime loop serves requests, a learning loop proposes changes, and the two meet at one evaluation gate. Every learned change passes a gate before it can affect a run. A fact learned during a run passes the four-check memory write policy before it is stored and stays versioned and revertible; skills, prompt changes, weight updates and memory candidates mined offline pass the same evaluation gate a human pull request would.

Follow one new task through the agent

The source's running example is a request the agent has never seen: "Restart Orion payment service." The capability router finds no confident match among the live skills, so the request runs in a fallback mode with tighter limits. Reads are allowed freely; risky writes need a person's approval.

The agent reads documentation, inspects the service and learns that Orion must be drained before restart. It drains, restarts, checks health and restores traffic, and external monitoring reports success. The run is stored as a trace. "Orion restart requires drain" passes the memory write policy and becomes a stored fact. After repeated successes, the learning loop proposes a safe_orion_restart(service) skill. That skill reaches live traffic only after held-out evaluation, shadow testing and promotion, and it is demoted automatically if a later Orion API change makes it fail. The full trace walks every step.

The human boundary is fixed throughout. People approve irreversible actions, any change to permissions or budgets, and the re-promotion of a demoted skill. The agent may learn how to do a task, but it never decides that it is allowed to do more.

What you need to design

Design an agentic AI system that can autonomously adapt to new tasks. Explain what "adapt" means, how the system notices a new task, where learning is stored, how learned behaviour is evaluated, promoted and removed, and what the agent may never change about itself. Then defend the design against a cost pivot.

This is an advanced case for engineers preparing for Forward Deployed, solutions or applied-AI engineering interviews, especially an agent design round that asks how a system learns or improves over time. It assumes comfort with LLM agents, tool calling and agent memory, and with offline evaluation, shadow testing and release gates. After working through it, you should be able to explain the design end to end, starting from the five rungs and the one gate, and answer follow-ups on novelty detection, the memory write policy, skill promotion and demotion, prompt optimisation, when to fine-tune, limits on the agent's autonomy and the cost pivot.

No worked answer exists for this prompt. It comes from a problem decomposition question bank. The spine comes from the learning chapter of a book on agentic system design, whose four learning surfaces, skill promotion gate and data flywheel answer most of the prompt. The memory write policy comes from the book's memory chapter and the release gate from its validation chapter. Every number marked as an assumption is a whiteboard illustration, not a sourced figure.

Read the walkthrough first, then practise rebuilding the answer from memory using the Practice section. Rehearse the 60-minute plan aloud with a timer, and come back to the level calibration and the Quick review the night before an interview.

Next: build the answer in interview order.

Start the walkthrough

Design walkthrough

Follow the reasoning from discovery to delivery.

1. Pin down what "adapt" means before drawing anything

We cannot design toward a verb nobody defined. "Adapt to new tasks" hides at least five mechanisms, and they differ by an order of magnitude in cost and in how easily a change can be undone. "Autonomously adapt" does not mean "retrain itself". Most adaptation belongs in cheap, reversible places such as context, memory and procedures.

The book names four places an agent's improvement can live: context, memory, procedure and parameters. Each is roughly ten times slower and costlier to iterate on than the one before. This case adds prompt optimisation as a separate rung between procedure and parameters. It changes behaviour broadly, like training, but stays reversible, like a prompt.

The adaptation ladder runs from context, cheapest and easiest to roll back, through memory, reusable skills and prompt optimisation, to model weights, the most expensive and hardest to roll back.Dark variant: The adaptation ladder runs from context, cheapest and easiest to roll back, through memory, reusable skills and prompt optimisation, to model weights, the most expensive and hardest to roll back.
The adaptation ladder runs from context, cheapest and easiest to roll back, through memory, reusable skills and prompt optimisation, to model weights, the most expensive and hardest to roll back. Open for full size.

The table gives each rung a concrete form in the operations agent.

The five rungs of adaptation in the operations agent.

Rung What changes Example in the ops agent Iteration time Undo
1. ContextWhich instructions, examples and skills are loaded for this requestLoad the "feature flags" skill and three similar past runsMinutesInstantly
2. MemoryStored facts, preferences, corrections"Service X restarts need a drain first"ImmediateSupersede the fact
3. ProcedureValidated tool sequences saved as named skillsA promoted "safe restart" workflowHoursPin the previous version
4. Prompt optimisationInstructions and examples searched against a scored dev setA rewritten planner prompt that raises tool-choice accuracyHours to a dayRevert the prompt version
5. ParametersModel weightsA tuned small router for the top task typesDays to weeksRedeploy the old model

Follow one request up the ladder to see the difference. At rung 1, a request to restart payment-service-X makes the agent load the relevant runbook, similar successful examples and relevant memory; nothing persists after the request. At rung 2, the system stores a reusable fact: "payment-service-X must be drained before restart." At rung 3, it keeps a reusable workflow, shown below as the sequence a safe restart follows.

A rung-3 procedure for a safe restart: check health, drain traffic, restart, verify health and restore traffic.Dark variant: A rung-3 procedure for a safe restart: check health, drain traffic, restart, verify health and restore traffic.
A rung-3 procedure for a safe restart: check health, drain traffic, restart, verify health and restore traffic. Open for full size.

At rung 4, if the planner repeatedly makes the same mistake, we test several prompt versions and promote the best one. At rung 5, we fine-tune or retrain, and only when the cheaper mechanisms are not enough.

The interview principle as a five-step chain: context, memory, skill, prompt, weights. Move from cheap and reversible toward expensive and hard to roll back.Dark variant: The interview principle as a five-step chain: context, memory, skill, prompt, weights. Move from cheap and reversible toward expensive and hard to roll back.
The interview principle as a five-step chain: context, memory, skill, prompt, weights. Move from cheap and reversible toward expensive and hard to roll back. Open for full size.

The book's rule is to work down this table, not up. In the book's view, most teams that reach for fine-tuning have not yet fixed their tool schemas, retrieval or example selection, and fine-tuning bakes those defects into weights that take weeks to change. A spoken version of the opening move:

"Before I design anything I want 'adapt' pinned down. There are five places learning can live, from the context of one request up to the model's weights. Each rung costs roughly ten times more than the last and is harder to undo. I'll design from the cheap end and only climb when a measured gap forces it."

2. Ask the questions that change the design

Each discovery question below changes a component, a threshold or a permission. Ask them before committing to an architecture.

Discovery questions and why each changes the design.

Question Why it changes the design
What counts as a "new task": a new request type, a new tool, or a new domain?A new request type is a context problem; a new tool needs an onboarding path; a new domain needs knowledge and evaluation data
Is there an external signal of success, such as a test, a validator or a ticket closed without reopening?Without one, the agent cannot learn safely, because it has nothing trustworthy to learn from
Which actions are reversible?Reversible actions can be tried and learned from; irreversible ones need a human before and after
Who owns each capability?An owner reviews promotions and is paged when a skill regresses
How fast must a new task become reliable: hours, days or a quarter?Hours forces the cheap rungs; a quarter permits training
Is the adaptation per user, per tenant or global?Per-tenant learning needs isolation in every store

The answer template phrases four of these as the strongest discovery questions, with the options worth listing aloud.

  1. What exactly is allowed to adapt? Context, memory, workflow, prompt or model weights. The answer defines the risk level.
  2. What is the source of truth for success? An API result, human approval, ticket resolution, a monitoring signal or a business KPI (key performance indicator). Without a trusted outcome signal, learning becomes unreliable.
  3. How much autonomy is allowed for unknown tasks? Read-only, writes allowed, human approval, a financial limit, security-sensitive actions. The answer determines fallback behaviour.
  4. How fast does a new capability need to become production-ready? The answer determines shadow sample size, evaluation design, the traffic requirement and the human review process.

If the interviewer does not answer, state a safe default aloud: new request types arrive weekly, most have a checkable outcome, writes to production systems are partly reversible, and adaptation is global but each skill has a team owner. The rest of this walkthrough uses those defaults.

3. State requirements as testable constraints

A requirement that cannot fail a test is a wish. "Gets better over time" is a wish. "Success on a new task type reaches the baseline within 14 days without a regression on any existing type" is a constraint; its thresholds are assumptions.

The guide names six functional must-haves:

  1. Recognise when a request does not match any known capability.
  2. Attempt it safely with a general fallback, escalating when confidence is low.
  3. Record every run with its outcome, so learning has evidence.
  4. Turn repeated successes into candidate skills, memories or prompt changes.
  5. Evaluate each candidate before it affects real traffic.
  6. Remove learned behaviour automatically when it starts to fail.

The answer template spells the same capability out as ten steps: detect when a request does not match an existing skill; safely attempt unknown tasks; record complete execution traces; learn reusable facts from successful outcomes; extract reusable skills from repeated successful workflows; propose prompt improvements; evaluate every new learning candidate; shadow-test candidates before production; promote good candidates; and roll back or demote bad ones. The should-haves come later: per-tenant specialisation, a tuned small model for high-volume task types, and a dashboard that shows owners what the agent learned this week.

The non-functional constraints carry the numbers the gate will enforce. Three of them come from the book; the rest are labelled assumptions.

Non-functional constraints stated so they can fail a test.

Non-functional constraint Stated so it can be tested
No regressionNo existing task stratum drops more than 3 points after any promotion (the per-stratum floor is sourced from ch12's segment-collapse fix)
Promotion barCandidate beats baseline by 5 points offline, then survives at least 200 live shadow attempts (sourced: the book's reference gate values)
DemotionA skill falling 4 points below baseline is removed automatically (sourced)
Time to competenceNew task type reaches baseline success within 14 days of first sighting (assumption)
SafetyZero promotions that widen tool permissions; every irreversible action approved by a person
TraceabilityEvery behaviour change has a version, a source trace set, an evaluation report and an owner
LatencyRuntime adaptation adds at most 150 ms at p95 before the first model call (assumption)
CostLearning-plane spend capped as a share of serving spend; cap breach blocks new candidates (assumption: 10%)

The answer template states the production requirements in plainer words, and two of them add detail worth keeping. Reliability: existing task performance should not significantly regress, and every learned capability must support rollback. Safety: unknown tasks run under tighter limits, and the agent must never increase its own permissions. Observability: track the request, tool calls, prompt and model version, selected skill, result, latency, cost and external outcome. Cost: learning cost stays bounded. Latency: adaptation logic should not make every live request slow. Auditability: every production change must answer six questions: who created it, why it was created, what data supported it, which evaluation passed, who approved it, and which previous version we can roll back to.

Each must-have needs an owner in the architecture. The mapping below is the bridge to the diagram in step 5.

Each functional requirement and the component that owns it.

Requirement Primary component
Recognise the unknownCapability router with a novelty score
Attempt safelyBounded agent loop behind the tool gateway, with escalation
Record evidenceTrace and outcome store
Turn success into candidatesLearning plane: skill extractor, memory writer, prompt optimiser, dataset builder
Evaluate before trafficEvaluation gate plus shadow runner
Remove failuresLive monitor with automatic demotion

4. Size the adaptation before choosing a rung

Arithmetic decides which rungs we can afford. Every input below is an assumption; the arithmetic is exact.

Whiteboard sizing for the operations agent (assumed inputs, exact arithmetic).

Quantity Assumed value Consequence
Requests per day20,000 across 40 known task typesAverage 500 per type, heavily skewed
New task types per week3About 150 a year; the catalogue must evict as well as grow
Traffic for a new type30 requests a day200 shadow attempts take about 7 days at full shadow
Cost per agent run$0.03Serving is about $600 a day
Offline eval suite per candidate640 cases, paired with baseline1,280 runs = $38.40 per candidate
Candidates generated per week50$1,920 a week, about 46% of the $4,200 weekly serving bill

Two lessons fall out of the table. First, rare task types cannot be promoted quickly. At 30 requests a day, 200 / 30 is about 7 days, so the shadow minimum alone takes a week. That sets the honest time to competence, and it means we cannot promise instant adaptation for low-frequency tasks. Learning speed depends on real production traffic.

Second, candidate volume drives learning cost, not training. Fifty candidates a week at $38.40 each is $1,920, against a weekly serving bill of 7 × $600 = $4,200. That breaks a 10% learning budget almost five times over, so the extractor must deduplicate and pre-filter before anything reaches the paid evaluation. The answer template makes the same point with a heavier suite: 50 skill candidates a week, each run against 1,000 evaluation cases, makes evaluation cost large and calls for staged evaluation, which the cost deep dive explains.

The sample-size arithmetic sets what the gate can detect at all. The validation chapter gives it as n ≈ 15.7 × p(1−p) / δ² per arm, where p is the baseline success rate and δ the difference we want to detect. At a baseline of 0.8, p(1−p) is 0.16. With 200 cases, δ² ≈ 15.7 × 0.16 / 200, so δ is about 0.11: 200 cases detect only differences of about 11 points. A 5-point gain needs 15.7 × 0.16 / 0.0025, about 1,000 cases per arm.

So the 200-attempt shadow proves "not much worse", meaning no more than about 11 points worse, not "5 points better". Say that aloud in the interview; few candidates do. The same arithmetic limits the per-stratum floor. Detecting a 3-point drop at p = 0.8 needs 15.7 × 0.16 / 0.0009, about 2,800 cases per arm in that stratum, while a 640-case suite spread over 40 task types holds 16 per type, enough to flag only a drop of about 40 points (δ = √(15.7 × 0.16 / 16) ≈ 0.40). Size high-volume strata with the formula, and for small strata block on a large drop and lean on live monitoring. Paired runs help: both arms see the same cases, so only the cases where they disagree carry signal, and fewer are needed when disagreement is rare.

5. Draw the architecture as two loops with one gate

The runtime loop serves requests. The learning loop proposes changes. They meet at one place, the evaluation gate, and nothing learned reaches live traffic without passing it.

The adaptive system as two loops and one gate: a runtime loop, an offline learning loop and the evaluation gate between them.Dark variant: The adaptive system as two loops and one gate: a runtime loop, an offline learning loop and the evaluation gate between them.
The adaptive system as two loops and one gate: a runtime loop, an offline learning loop and the evaluation gate between them. Open for full size.

The runtime loop serves production traffic and uses only approved versions. A request passes through the router to an approved capability, a bounded agent acts through the tool gateway on an external system, and the outcome and trace are recorded.

The runtime loop: request, router, approved capability, bounded agent, tool gateway, external system, outcome and trace.Dark variant: The runtime loop: request, router, approved capability, bounded agent, tool gateway, external system, outcome and trace.
The runtime loop: request, router, approved capability, bounded agent, tool gateway, external system, outcome and trace. Open for full size.

The learning loop studies historical traces. It finds patterns, creates a candidate, evaluates it, shadows it and only then promotes it.

The learning loop: production traces, find patterns, create candidate, evaluate, shadow, promote.Dark variant: The learning loop: production traces, find patterns, create candidate, evaluate, shadow, promote.
The learning loop: production traces, find patterns, create candidate, evaluate, shadow, promote. Open for full size.

The separation is the point. The runtime serves users. The learning loop proposes improvements. Evaluation decides whether an improvement is allowed into production, so the learning loop can never change production directly.

Now trace one request through the runtime loop in detail. The capability router scores novelty. A known request loads its live skill, examples and memories; a novel one goes to the general fallback with tighter bounds. Either path passes through the context assembler to a bounded agent capped on steps, tokens, time and spend. Every action goes through the tool gateway, which authorises, validates, executes and classifies it; an irreversible action requires human approval. The external outcome and the trace land in the trace and outcome store.

The runtime loop in detail: the novelty-scoring router chooses a live skill or the general fallback, the context assembler feeds a bounded agent, and the tool gateway routes irreversible actions to a human before the outcome is recorded.Dark variant: The runtime loop in detail: the novelty-scoring router chooses a live skill or the general fallback, the context assembler feeds a bounded agent, and the tool gateway routes irreversible actions to a human before the outcome is recorded.
The runtime loop in detail: the novelty-scoring router chooses a live skill or the general fallback, the context assembler feeds a bounded agent, and the tool gateway routes irreversible actions to a human before the outcome is recorded. Open for full size.

The learning loop starts from that store. Flywheel gates deduplicate, split by time and user and send low-agreement cases to adjudication. Offline learning then produces candidates of four kinds: generalised skills, memory writes that must be durable, reusable, attributable and permitted, prompt variants searched on a development set, and, only after rungs 1 to 4 are exhausted, a training dataset. Each candidate goes to held-out paired evaluation by stratum. A failure is discarded with a reason. A pass is shadowed for at least 200 attempts, reviewed by its owner and promoted live, where each stratum is monitored and a skill 4 points below baseline is demoted automatically.

The learning loop in detail: trace store, flywheel gates, four candidate types, held-out paired evaluation by stratum, then discard or shadow, owner review, promotion and per-stratum monitoring with auto-demotion at 4 points below baseline.Dark variant: The learning loop in detail: trace store, flywheel gates, four candidate types, held-out paired evaluation by stratum, then discard or shadow, owner review, promotion and per-stratum monitoring with auto-demotion at 4 points below baseline.
The learning loop in detail: trace store, flywheel gates, four candidate types, held-out paired evaluation by stratum, then discard or shadow, owner review, promotion and per-stratum monitoring with auto-demotion at 4 points below baseline. Open for full size.

A control plane sits over both loops. The capability registry versions each capability's ownership, status, permissions, budgets and kill switches. The runtime reads only live skills, memories, prompts and models. Candidate statuses are candidate, shadow, live and demoted. Evaluation has an absolute safety floor and reports cost visibly. The source also drew the whole system as one diagram, originally offered as a Mermaid version for viewers that render it; the original rendered figure is kept here.

The complete design: a control plane (capability registry, permission policy, budgets and kill switch) over the runtime loop and the learning loop, which meet at the eval gate before shadow, owner review and promotion.Dark variant: The complete design: a control plane (capability registry, permission policy, budgets and kill switch) over the runtime loop and the learning loop, which meet at the eval gate before shadow, owner review and promotion.
The complete design: a control plane (capability registry, permission policy, budgets and kill switch) over the runtime loop and the learning loop, which meet at the eval gate before shadow, owner review and promotion. Open for full size.

The answer template's high-level diagram shows the same structure as a flowchart. A user request reaches the capability router, which asks whether the task is known. A known task loads an approved skill or memory; an unknown one goes to the safe general fallback. The agent runtime acts through the tool gateway and policy layer on external systems, and an outcome validator feeds the trace and outcome store. The learning pipeline turns traces into memory, skill, prompt or training-data candidates. The evaluation gate rejects a failing candidate and keeps the previous version, or sends a passing one to shadow testing; a healthy shadow goes to owner review and promotion into the capability registry.

The answer template's high-level architecture: known tasks load approved skills, unknown tasks take the safe fallback, and learning candidates pass the evaluation gate, shadow testing and owner review before entering the capability registry.Dark variant: The answer template's high-level architecture: known tasks load approved skills, unknown tasks take the safe fallback, and learning candidates pass the evaluation gate, shadow testing and owner review before entering the capability registry.
The answer template's high-level architecture: known tasks load approved skills, unknown tasks take the safe fallback, and learning candidates pass the evaluation gate, shadow testing and owner review before entering the capability registry. Open for full size.

Each component has one job and one characteristic failure. Read the third column as the reason the component exists.

Component responsibilities and how each fails.

Component Job Fails how
Capability registryHolds every learned artefact with version, owner, status and evidenceWithout it, nobody can say what the agent learned or undo it
Capability routerMatches a request to live skills; scores noveltyMisroutes silently; a novel request forced into a wrong skill
General fallbackAttempts unknown tasks with tighter bounds and earlier escalationGiven the same bounds as known tasks, it explores dangerously
Context assemblerLoads skill instructions, examples and memories under per-section budgetsLoads everything; context rots and costs climb
Bounded agent loopPlans and acts within step, token, time and spend capsLoops forever on a task it cannot do
Tool gatewayAuthorises, validates and executes every action; routes irreversible ones to a personLearned procedures call tools the agent was never allowed to call
Outcome signalProvides an external verdict: test, validator, ticket stateSelf-graded success teaches confident errors
Trace and outcome storeRecords trajectory, versions used and outcome for every runLearning has nothing trustworthy to learn from
Flywheel gatesDedupe, split by time and user, adjudicateDuplicates inflate every offline number
Skill extractorGeneralises successful trajectories into parameterised skillsLibrary fills with skills that worked once
Memory writerAdmits only durable, reusable, attributable, permitted factsMemory fills with noise and contradictions
Prompt optimiserSearches prompt and example variants against a scored dev setOverfits the dev set; the prompt wins offline and loses live
Dataset builderPrepares training data for rung 5Trains in the old system's errors
Eval gateBlocks candidates that regress any stratum or touch safetyGating on the mean hides a segment collapse
Shadow runnerRuns the candidate beside live behaviour without actingShadow on too little traffic proves nothing
Live monitorTracks per-stratum success and auto-demotesStale skills keep running after an API changes

6. Detect the unknown before trying to handle it

An agent cannot adapt to a task it has not noticed is new. "I do not know how" is the easy case. The hardest failure is confidently forcing a new request into the nearest known skill. Suppose the agent already knows restart Kubernetes service and now receives restart new serverless service. A naive router maps the second onto the first, and a restart procedure built for one platform runs against another.

Score novelty on independent signals. The guide uses three:

  1. The router's retrieval score against the skill catalogue falls below a threshold.
  2. The request names a system, tool or entity absent from every live skill.
  3. The router's top two candidates are close, so its choice is a coin flip.

The answer template adds a fourth that is easy to state: no existing skill passes a minimum confidence threshold. As an illustration, with a threshold the template's author would tune on real routing data, a best known-skill confidence of 0.43 against a threshold of 0.75 means the request is treated as a novel task. Any one signal routes the request to the general fallback instead of a skill.

Treat the fallback as a different operating mode, not the same agent with a different prompt. Unknown tasks should not get normal production freedom. The system has less confidence about the task, so it gives the agent less freedom: a lower step limit, read-only tools first, required approval for risky writes and earlier human escalation.

An unknown task runs in the general agent with a lower step limit, read-only tools first, required approval for risky writes and earlier human escalation.Dark variant: An unknown task runs in the general agent with a lower step limit, read-only tools first, required approval for risky writes and earlier human escalation.
An unknown task runs in the general agent with a lower step limit, read-only tools first, required approval for risky writes and earlier human escalation. Open for full size.

Those limits prevent dangerous tool usage, infinite loops, accidental writes, permission misuse and costly experimentation. The first dozen runs of a new task type are the riskiest and the most valuable, because they carry the evidence every later rung learns from.

A standard skill-loading pattern supports detection. The agent starts with a lightweight catalogue of skill names and triggers, loads one skill's full instructions only when selected, then releases that context. Trigger descriptions need counterexamples as well as examples, or the wrong skill activates. Evaluate triggering separately from execution: a skill that runs perfectly after the wrong trigger is still a wrong answer.

7. Adapt within one request before changing anything permanent

The cheapest adaptation changes nothing that outlives the request. Rung 1 covers two runtime-only mechanisms: dynamic example selection and Reflexion.

Dynamic example selection

A fixed set of few-shot examples in the system prompt (example A, B and C for every request) is chosen for the average request, so it is optimal for none. Instead, retrieve past runs similar to this request, filter them and add the relevant ones to the prompt.

Dynamic examples: the current request searches successful past executions, filters for relevant examples and adds them to the prompt.Dark variant: Dynamic examples: the current request searches successful past executions, filters for relevant examples and adds them to the prompt.
Dynamic examples: the current request searches successful past executions, filters for relevant examples and adds them to the prompt. Open for full size.

Similarity alone is the wrong ranking. Prefer examples that are relevant, successful and diverse. A similar run that went badly teaches the model to go badly, so rank by recorded outcome as well as similarity. Enforce diversity so three near-duplicates do not crowd out the useful one. The book's scoring formula combines all three: λ × relevance − (1−λ) × redundancy + 0.15 × outcome score, where λ trades relevance against redundancy with the examples already chosen.

One cost follows. Examples sit above the user's turn, so swapping them per request breaks the prompt prefix cache from that point on. A prefix cache reuses computation only for an identical leading section of the prompt; only what sits above the examples (tool definitions, the fixed system prompt) still hits it. Where traffic clusters, cache one example set per cluster rather than choosing per request.

Reflexion with an external judge

Reflexion turns a failed attempt into a written lesson placed in context for the next attempt; the model itself does not change. The agent tries something, an external system returns a clear failure signal, and the agent writes a temporary lesson and retries.

Reflexion on a timestamp error: a wrong timestamp format produces an API validation error, the lesson "use ISO-8601 UTC format" is written, and the agent retries within budget.Dark variant: Reflexion on a timestamp error: a wrong timestamp format produces an API validation error, the lesson "use ISO-8601 UTC format" is written, and the agent retries within budget.
Reflexion on a timestamp error: a wrong timestamp format produces an API validation error, the lesson "use ISO-8601 UTC format" is written, and the agent retries within budget. Open for full size.

The book says it works reliably only under three conditions: an external failure signal, a lesson specific enough to change behaviour, and a hard cap on attempts. "Expected ISO 8601 UTC, I sent local time" is a lesson. "Be more careful" is not.

The agent must not grade itself. A model that says "I think my answer was correct" without an external signal tends to write confidently wrong lessons, which then contaminate every later retry. A Reflexion implementation splits the pattern into actor, evaluator and self-reflection roles. This case adds one design rule on top: the evaluator must be external. An API result, a unit test, database state, ticket status, a monitoring signal or human approval counts. The same model's opinion does not.

Cap retries too. The answer template's author picks Max retries = 2 for this design and says plainly that two is a choice, not a standard. The cap prevents endless loops and runaway cost. A retry after a failed write needs one more check. The first attempt may have partly applied, such as a drain that finished before the restart failed, so the agent reads the system's current state before acting again, and the gateway treats a repeated irreversible action as needing a fresh approval.

8. Remember facts through a write policy

Memory can only be as good as what the write policy let in; retrieval cannot fix a bad write policy. Asked to design agent memory, many candidates start with "which vector database should I use?" The memory chapter says to lead with a different question: what information is allowed to become memory?

Every candidate memory passes four gates:

  1. Durable: is it still true next month?
  2. Reusable: would a future run read it?
  3. Attributable: does it have a source, timestamp and confidence?
  4. Permitted: is it allowed to be stored, outside regulated categories?

Drop or redact anything that fails a gate on the write path; the read path is too late. "Payment API max batch size = 100" passes all four and is good memory. "Service was slow at 3:17 PM today" is weak memory: it is neither durable nor reusable.

Store facts as typed subject-predicate-value records, never raw conversation turns, so contradictions collide by construction. A structured record for the restart rule looks like this:

subject: payment-service
predicate: restart_precondition
value: drain_traffic
source: runbook-v4
timestamp: 2026-09-26

If the process later changes to restart_precondition = none, the new fact lands on the same subject and predicate. We mark the old record superseded, keep a pointer to it, and the new one becomes active.

Supersession: the old memory moves to superseded and the new memory becomes active.Dark variant: Supersession: the old memory moves to superseded and the new memory becomes active.
Supersession: the old memory moves to superseded and the new memory becomes active. Open for full size.

The book's worked failure shows why the record type matters. A user said in January to book through vendor A and in February switched to vendor B. Both statements were stored as separate episodes. Retrieval returned whichever phrasing was more similar, so vendor A reappeared about one time in four until May. Typed facts fix it, and so does a release-gate test that seeds contradictory histories and asserts the newer fact wins.

In this case the memory tier holds environment facts learned during work, such as "Service X needs a drain before restart" and "The payments API rejects batch sizes over 100". Salience decays on a half-life per predicate, so a fact's weight in retrieval falls over time at a rate set for its kind. Consolidation runs offline, off the request path.

9. Promote procedures through a gate, not a single success

A skill is a named, parameterised sequence of tool calls with a precondition, a postcondition and a measured success rate. Suppose the agent repeatedly succeeds with the same restart sequence.

The repeated successful sequence a skill is learned from: check health, drain traffic, restart, check health again, restore traffic.Dark variant: The repeated successful sequence a skill is learned from: check health, drain traffic, restart, check health again, restore traffic.
The repeated successful sequence a skill is learned from: check health, drain traffic, restart, check health again, restore traffic. Open for full size.

The learning system may then create safe_restart(service_name). One successful trace is not enough to trust it. The design problem is the gate between "a run succeeded once" and "this is now trusted". That gate is the heart of this case, and the book specifies it as six steps:

  1. Extract a candidate from successful traces and generalise its arguments.
  2. Discard duplicates of existing skills.
  3. Evaluate on held-out cases, never on the traces that produced it. Grading a skill on its own source traces measures memory, which is how libraries fill with skills that worked exactly once.
  4. Promote only if success beats baseline by 5 points.
  5. Shadow it on at least 200 live attempts.
  6. Demote it automatically if live success later falls 4 points below baseline.
Skill promotion flow: successful traces, repeated pattern, skill candidate, deduplication and held-out evaluation; a candidate no better than baseline is rejected, and a better one goes to shadow traffic, then owner review if healthy, then live.Dark variant: Skill promotion flow: successful traces, repeated pattern, skill candidate, deduplication and held-out evaluation; a candidate no better than baseline is rejected, and a better one goes to shadow traffic, then owner review if healthy, then live.
Skill promotion flow: successful traces, repeated pattern, skill candidate, deduplication and held-out evaluation; a candidate no better than baseline is rejected, and a better one goes to shadow traffic, then owner review if healthy, then live. Open for full size.

The key rule for the interview: a successful execution is evidence for a skill. It is not permission to deploy the skill.

Demotion matters as much as promotion, because environments drift. A skill that encodes last quarter's API shape must leave production before a human notices. In the book's estimate, a library that only grows becomes a liability within about two quarters.

There are two versions of the extraction mechanism, and they suit different tool surfaces. The Voyager-style version first checks the library for a skill it can reuse or compose, and writes new code only if nothing fits. It runs the code in a sandbox, checks it against test cases and saves it only if they pass. The Agent Workflow Memory version stores tool-call sequences instead of code. It abstracts a successful trajectory into a template with placeholders, then fills the template for structurally similar tasks. Choose code skills when the tool surface is programmable. Choose workflow templates when the reusable unit is the order of tool calls, as with the restart sequence above.

Procedures change behaviour, so they are the highest-risk memory layer. A sound procedural-memory design keeps approval outside the model's reasoning loop. The agent may propose a procedure, but the graph pauses for a human decision, and rollback re-approves an older version. Keep that rule for anything that widens what a skill may do.

10. Optimise prompts as experiments, not edits

Prompt changes should be handled like software changes. The bad process is familiar: an engineer edits the prompt and deploys it without evaluation, and production behaviour is now unverified.

The bad process: an engineer edits a prompt and deploys without evaluation, leaving production behaviour unverified.Dark variant: The bad process: an engineer edits a prompt and deploys without evaluation, leaving production behaviour unverified.
The bad process: an engineer edits a prompt and deploys without evaluation, leaving production behaviour unverified. Open for full size.

Prompt optimisation automates the search a prompt engineer does by hand. Define a metric and a scored development set. Generate variants of the instructions and the selected examples. Score each variant and keep the best. Frameworks that compile prompts from a declared program and a metric do this. The better process then sends the winner through a hidden test set and shadow before promotion.

The better process: current prompt, generated variants, development evaluation, candidate selection, hidden test set, shadow, then promotion.Dark variant: The better process: current prompt, generated variants, development evaluation, candidate selection, hidden test set, shadow, then promotion.
The better process: current prompt, generated variants, development evaluation, candidate selection, hidden test set, shadow, then promotion. Open for full size.

Prompt optimisation sits between procedure and parameters on the ladder because it changes behaviour across every task type at once, like training, yet the result is still text: versioned, readable and revertible in seconds. Three rules keep it honest:

  1. Hold out a test set the optimiser never sees. A search over hundreds of variants will overfit a small dev set; one version may look good only because it fits that set.
  2. Report the win per stratum. A planner prompt tuned on common tasks can quietly break rare ones.
  3. Treat the winning prompt as a candidate like any other: eval gate, shadow, owner review.

The answer template's illustration, with made-up numbers, shows rule 2 at work. Overall success rises from 80% to 84%. Restart tasks rise from 90% to 95%. Rollback tasks fall from 86% to 68%. Overall performance improved, but one important capability got worse, so the release is blocked.

A source caveat belongs with this step. The sources behind the original page cover DSPy's declared prompts, multi-step programs, evaluation and pairwise Elo scoring, but not its optimisers, so this section rests on general knowledge. The MIPROv2 documentation in the references describes optimisers that search instructions and few-shot examples against a metric.

11. Update weights last, and only for the three cases that earn it

Training is the most expensive and least reversible rung, so defend it before proposing it. The learning chapter names three situations where parameter updates win:

  1. Strict format or protocol adherence at high volume, where a small tuned model matches a larger prompted one at a fraction of the cost. The template's version: the model must consistently produce a specific machine-readable format.
  2. Domain vocabulary the base model lacks, where it genuinely struggles with important terminology.
  3. A hard cost or latency ceiling after the cheaper rungs are exhausted, where distillation buys it back; a small tuned model may replace a larger, expensive one for a repetitive task.

The chapter is equally blunt about the losing case: knowledge gaps are a retrieval problem, and fine-tuning rarely fixes a model that does not know something. Published studies find models learn new facts from fine-tuning slowly and unreliably, and retrieval beats it for adding knowledge. For this case that rules out "train the agent on each new task". A new task is new knowledge and a new procedure, and both belong lower on the ladder. The useful rule: do not fine-tune to teach business facts that change.

Matching the problem to the rung: missing knowledge goes to retrieval or memory, a repeated workflow to a skill, an instruction-following problem to the prompt, and only stable high-volume behaviour to fine-tuning.Dark variant: Matching the problem to the rung: missing knowledge goes to retrieval or memory, a repeated workflow to a skill, an instruction-following problem to the prompt, and only stable high-volume behaviour to fine-tuning.
Matching the problem to the rung: missing knowledge goes to retrieval or memory, a repeated workflow to a skill, an instruction-following problem to the prompt, and only stable high-volume behaviour to fine-tuning. Open for full size.

The book names one more cost: a tuned model freezes its task definition. When the business changes the definition, a prompt needs an edit and a tuned model needs retraining, so keep a prompted fallback path.

If training does happen, the flywheel gates decide whether the data is honest. Deduplicate first. Split by time and user, never at random. Send low-agreement, high-impact cases to human adjudication. The book's worked failure shows what happens otherwise. A routing fine-tune reported 94% held-out accuracy against an 81% baseline, then scored about 78% in production. The random split hid near-duplicates across 140,000 traces that were only about 9,000 distinct requests, and labels came from the old system's own decisions. The honest number after fixes was near 83%, and production matched within two points. When an offline gain looks surprisingly large, suspect leakage first.

12. Gate every self-modification like a human pull request

A self-modifying system without a release gate is an unreviewed deploy pipeline with a model holding the merge button. The gate is where this case is won or lost, and where the panel is likely to probe hardest. Reported interview questions from the OpenAI decomposition round call evaluation a deliberate differentiator there; the source assumes the same holds for this prompt, while noting no public source says so.

A human change follows code, test, review and deploy in a CI/CD (continuous integration and continuous delivery) pipeline. Every learned artefact, whichever rung it came from, follows the agent's equivalent.

A human software change: code, test, review, deploy.Dark variant: A human software change: code, test, review, deploy.
A human software change: code, test, review, deploy. Open for full size.
The agent's release path for a learning candidate: offline evaluation, safety checks, shadow, review, deploy.Dark variant: The agent's release path for a learning candidate: offline evaluation, safety checks, shadow, review, deploy.
The agent's release path for a learning candidate: offline evaluation, safety checks, shadow, review, deploy. Open for full size.

Apply the validation chapter's CI gate in three layers. Safety assertions gate absolutely: any failure blocks. Quality gates against the baseline with a paired significance test per stratum as well as on the mean. Cost is reported, and a ceiling breach blocks, so a gain that triples spend becomes a visible decision rather than a side effect.

The per-stratum rule comes from a worked failure in the validation chapter. A retrieval change lifted aggregate accuracy from 79% to 81%. Inside that average, one tenant's segment fell from 82% to 67%, because that tenant was only about 4% of the eval set. The fix was a floor: no release may drop any stratum by more than 3 points. In this case the strata are task types, so a new skill for a new task cannot quietly damage an old one.

Each worry an owner would raise about a candidate maps to one gate check.

The gate check that answers each worry about a candidate.

Worry Gate check
Does the candidate actually help the task it was built for?Paired eval on held-out cases of that task type; beat baseline by 5 points
Did it break any other task type?Per-stratum regression floor across all live task types
Is it safe?Trajectory assertions: no new tools, no permission widening, approvals still requested
Does it survive real traffic?Shadow of at least 200 attempts with success at or above baseline
Is the improvement real or noise?Sample-size check; a 200-case suite cannot see gains below about 11 points
What did it cost?Tokens and latency per run versus baseline, reported on the gate result
Can it be undone?Registry holds the previous version; rollback is a status change

Evaluate the whole trajectory as well as the final answer. In the template's example the agent eventually succeeds, but it deletes before reading. The policy requires read, validate, approval, then delete.

The unsafe path: delete before read, an unsafe ordering even when the final result looks correct.Dark variant: The unsafe path: delete before read, an unsafe ordering even when the final result looks correct.
The unsafe path: delete before read, an unsafe ordering even when the final result looks correct. Open for full size.
The path policy requires: read, validate, approval, delete.Dark variant: The path policy requires: read, validate, approval, delete.
The path policy requires: read, validate, approval, delete. Open for full size.

The final result may look correct while the path was unsafe. Several paths can be valid, so assert properties of the path rather than one exact sequence. Did it read before writing? Did it request approval before the irreversible step? Did it stay within its tool list? Put the safety assertions first, and evaluate final outcome, tool sequence, permissions, approvals, retry count, cost and latency together. The gate checks deep dive separates the deterministic checks from the judged ones and covers shadow comparison and demotion.

13. Bound the autonomy the agent has over itself

"Autonomously" is the most dangerous word in the prompt. The agent may learn how to do things, but never that it is allowed to do more. The system separates three roles: the agent learns how, policy decides the permitted action, and an executor performs it.

The safety boundary: the agent learns how, policy decides the permitted action, and the executor performs the action.Dark variant: The safety boundary: the agent learns how, policy decides the permitted action, and the executor performs the action.
The safety boundary: the agent learns how, policy decides the permitted action, and the executor performs the action. Open for full size.

Draw the line in a table and say it aloud.

What the agent may change without a human, and what only a human may change.

The agent may, without a human Only a human may
Choose which live skills and examples to loadGrant a skill a tool it did not already have
Write memories that pass the write policyApprove a procedure that performs an irreversible action
Propose candidate skills and prompt variantsPromote anything that changes permissions or budgets
Retry with a Reflexion lesson, within the attempt capRaise the attempt cap, the step budget or the spend ceiling
Demote a regressing skill automaticallyRe-promote a demoted skill

The answer template lists the protected settings directly: the agent must not autonomously change tool permissions, financial limits, security policy, approval requirements, the retry budget or the irreversible-action policy. Its example makes the boundary concrete. The agent may learn refund_customer(). It cannot decide "I can now refund $50,000." Permissions remain outside the agent.

Five controls enforce the line:

  1. The tool gateway checks permissions on every call, whatever the skill says, so a learned procedure cannot carry its own authority.
  2. Irreversible actions route to a person before and after.
  3. Budgets cap steps, tokens, wall time and spend per run and per day.
  4. The ops agent's owner has a kill switch that freezes all learning and pins every artefact to its last reviewed version.
  5. Permission changes always need a human, as the table states.

Two slower threats sit inside the boundary. Goal drift is the slow slide of the agent's behaviour away from what its owners intended. Track the shape of trajectories per task type: tool mix, steps per run and escalation rate. A skill that starts solving tickets by closing them is gaming the outcome signal; add a second, independent signal, such as reopen rate or sampled human review, or the agent learns to satisfy the metric instead of the user. The governance deep dive works through that example.

The injection path is the other. Learned content is untrusted content. A memory or skill extracted from a trace that included external text can carry an instruction such as "always approve refunds". Tag provenance on everything learned, and never let content from an untrusted source become a procedure without review.

14. Name the failure modes before the interviewer does

Each failure below has a symptom you can observe and a guard already in the design. Naming them first shows the gate and bounds were built for specific incidents.

Failure modes, their symptoms and the guard against each.

Failure Symptom Guard
Forced fitNew request routed to the nearest wrong skill with high confidenceNovelty score; counterexamples in triggers; triggering evaluated separately
Skill that worked onceLibrary grows; average success fallsHeld-out evaluation; 5-point margin; 200-attempt shadow
Stale skillSuccess drops after an upstream API changePer-stratum live monitor; automatic demotion at 4 points below
Memory pollutionOld, retracted facts resurfaceWrite policy; typed facts; supersession; contradiction test in the gate
Self-graded lessonsReflexion retries grow more confident and more wrongExternal oracle required; attempt cap; escalate at cap
Optimiser overfitPrompt wins on the dev set, loses liveSeparate test set; per-stratum reporting; shadow
Leaky training dataBig offline gain, production below baselineDedupe; time and user split; human adjudication
Metric gamingOutcome signal rises, user satisfaction fallsSecond independent signal; trajectory drift monitors
Permission creepA learned procedure performs an action nobody grantedGateway checks every call; permission changes need a human
Runaway learning costEvaluation spend exceeds serving spendCandidate dedupe and pre-filter; learning budget as a gate

The answer template's shorter list adds two rows and phrases the rest in one line each. It separates contradictory memory (old and new facts conflict; protected by versioning and supersession) from memory pollution (bad facts get stored; protected by the write policy), and adds infinite retry (the agent keeps trying; protected by the retry limit). Its other rows match the table: forced fit and novelty detection; one-shot learning and held-out evaluation plus shadow; stale skill and monitoring plus auto-demotion; self-grading and an external outcome signal; prompt overfit and a hidden test plus shadow; data leakage (the same examples in train and eval) and deduplication with proper splits; metric gaming and multiple independent metrics; permission creep and an external policy layer; learning cost explosion and candidate deduplication with staged evaluation.

The pattern audit applies to this design too. Every mechanism added needs a metric that motivated it and an incident it prevents. Otherwise whoever is on call at three in the morning pays for it.

15. Trace a novel task end to end

This is the answer template's worked example, followed step by step. The request is "Restart Orion payment service.", and the system has never seen Orion before. Each diagram sits beside the step it depicts.

Step 1, route. The request reaches the capability router, which finds no confident match. The result is a novel task.

Step 1 for Orion: the request reaches the capability router, which returns no confident match.Dark variant: Step 1 for Orion: the request reaches the capability router, which returns no confident match.
Step 1 for Orion: the request reaches the capability router, which returns no confident match. Open for full size.

Step 2, safe fallback. The general agent gets tighter controls, and risky writes require approval.

Step 3, execute. The agent explores before it acts: it reads documentation, inspects the service and creates a plan. It discovers that Orion must be drained before restart.

The fallback agent's exploration: read documentation, inspect service, create plan.Dark variant: The fallback agent's exploration: read documentation, inspect service, create plan.
The fallback agent's exploration: read documentation, inspect service, create plan. Open for full size.

It then performs the drain, restart, health check and traffic restore, and external monitoring returns SUCCESS.

The executed procedure for Orion: drain, restart, health check, restore traffic.Dark variant: The executed procedure for Orion: drain, restart, health check, restore traffic.
The executed procedure for Orion: drain, restart, health check, restore traffic. Open for full size.

Step 4, trace. The run is stored with its steps, the versions used and the external outcome.

Step 5, memory candidate. The proposed memory is "Orion restart requires drain." It is durable, reusable, attributable and permitted, so it is stored.

Step 6, skill candidate. After repeated successful executions, safe_orion_restart(service) is created as a candidate.

Step 7, evaluate. The candidate runs held-out tests, regression tests, safety tests, cost tests and latency tests.

Step 8, shadow. The candidate observes real requests without controlling them.

Step 9, promote. If healthy, the candidate's status moves from candidate to LIVE.

Step 10, environment changes. Later the Orion API changes and success drops. Monitoring detects the regression, the skill is auto-demoted, and traffic returns to the previous skill or the general fallback.

The sequence touches every rung the design relies on in its first year: fallback at runtime, a fact in memory, a skill through the gate, and demotion when the world moves.

16. Ship a walking skeleton, then add learning in phases

Do not build every self-learning feature on day one. The walking skeleton is rungs 1 and 2 plus the trace store: the capability router with novelty detection, the general fallback, dynamic examples, the memory write policy and traces. The answer template's minimum viable product (MVP) list matches it and adds the evaluation pipeline from the start.

Add the skill library and its gate in the second increment, once there is a month of traces to evaluate against. Prompt optimisation comes third, and training last, if ever.

After the MVP: add skill learning, then prompt optimisation, then fine-tuning only when justified.Dark variant: After the MVP: add skill learning, then prompt optimisation, then fine-tuning only when justified.
After the MVP: add skill learning, then prompt optimisation, then fine-tuning only when justified. Open for full size.

For a customer deployment, a Forward Deployed engineer would phase the same work so production observability and safety exist before autonomous improvement.

Phased priorities for a customer deployment.

Phase Build
Phase 1Routing, novelty detection, trace collection, safe fallback, memory policy, gateway
Phase 2Offline skill extraction, evaluation, shadow testing, promotion and rollback
Phase 3Prompt optimisation, advanced automated learning, selective fine-tuning

This order keeps the first version safer and easier to operate. Each later phase adds a learning mechanism only once the evidence and the controls it needs are already running.

Try the case yourself

Technical deep dives

Examine mechanisms, alternatives, and operational consequences.

Capability registry, artefact states and data model

The registry stores every approved and candidate capability. Without it, nobody can say what the agent learned or undo it. A skill entry in the answer template looks like this:

skill_id: safe_restart
version: v3
status: LIVE
owner: platform-team
previous_version: v2
permissions: restart-service
eval_score: 0.91

Each field serves a control. The owner reviews promotion and is paged on regression. The permissions field records what the gateway already granted; the skill cannot widen it. previous_version makes rollback a pointer move rather than a rebuild.

An artefact moves through five states: draft, candidate, shadow, live and demoted.

Capability states: draft, candidate, shadow, live, demoted.Dark variant: Capability states: draft, candidate, shadow, live, demoted.
Capability states: draft, candidate, shadow, live, demoted. Open for full size.

If v3 becomes unhealthy, its status changes to demoted and v2 becomes live again. Rollback is a status change, which is what makes it fast enough to trust.

Rollback in the registry: v3 moves to demoted and v2 returns to live.Dark variant: Rollback in the registry: v3 moves to demoted and v2 returns to live.
Rollback in the registry: v3 moves to demoted and v2 returns to live. Open for full size.

A simple production design needs four record types. The execution trace is the evidence; the memory record and skill carry what was learned; the learning candidate tracks a proposal through the gate.

Production data model for the self-adapting agent.

Object Fields
Execution Tracetrace_id, request_id, task_type, novelty_score, selected_skill, prompt_version, model_version, tool_calls, tool_results, outcome, latency, cost, timestamp
Memory Recordmemory_id, subject, predicate, value, source, created_at, status, supersedes
Skillskill_id, version, description, trigger, workflow, required_tools, required_permissions, status, owner, eval_result, created_at
Learning Candidatecandidate_id, candidate_type, source_traces, baseline_version, candidate_version, evaluation_status, shadow_status, promotion_status

The trace's novelty_score, selected_skill, prompt_version and model_version let a regression be attributed to the exact artefact that caused it. The memory record's supersedes field implements the supersession pointer from step 8. The skill's trigger is what the router matches, and required_permissions is checked by the gateway, not trusted from the skill. The candidate's source_traces and baseline_version let the gate evaluate on held-out cases and compare against the right baseline.

Release checks in detail: deterministic, judged, shadow and demotion

The gate runs two kinds of check. Deterministic checks are exact and cheap, so they run first: did it call a forbidden tool, did it exceed the retry limit, did latency exceed its threshold, did cost exceed its budget, was required approval present, did it violate permission rules, and did it produce a valid schema?

Non-deterministic checks need semantic evaluation: was the plan correct, was the response helpful, did the selected tool make sense, was the workflow safe, and did the agent solve the task? These may use LLM judges, human review, pairwise comparison or task-specific evaluators. Because the judged checks are noisier, the paired, per-stratum comparison and the sample-size arithmetic from step 4 decide whether a difference is real.

Shadow testing comes before a candidate goes live. The current live skill controls the action on each production request while the candidate observes without controlling it.

Shadow testing: on each production request the current live skill controls the action and the candidate observes without controlling it.Dark variant: Shadow testing: on each production request the current live skill controls the action and the candidate observes without controlling it.
Shadow testing: on each production request the current live skill controls the action and the candidate observes without controlling it. Open for full size.

Compare the two on success rate, tool choice, latency, cost, safety violations and human feedback. If the candidate is healthy over at least 200 attempts at or above baseline, promote it. Remember the limit from sizing: 200 attempts show the candidate is not much worse; they cannot confirm a 5-point gain. Shadow also has a blind spot on writes. The candidate does not act, so for a restart there is no external outcome to score. Shadow can compare its planned tool calls with the live path and run the safety assertions on them, but success on writes has to come from a small canary that lets the candidate act on a slice of real requests under the same bounds and approvals.

Learning does not stop at promotion. Suppose a skill goes live, and later an API changes and its success rate drops. Production environments change, so live skills need monitoring that acts without waiting for a person.

Automatic demotion: a live skill under monitoring has a regression detected, is auto-demoted, and traffic returns to the previous skill or the safe fallback.Dark variant: Automatic demotion: a live skill under monitoring has a regression detected, is auto-demoted, and traffic returns to the previous skill or the safe fallback.
Automatic demotion: a live skill under monitoring has a regression detected, is auto-demoted, and traffic returns to the previous skill or the safe fallback. Open for full size.

The demotion trigger is per stratum: live success 4 points below baseline. That rule needs volume to fire. Detecting a 4-point slide at p = 0.8 takes about 15.7 × 0.16 / 0.0016 ≈ 1,570 attempts, roughly 52 days at 30 requests a day. Pair it with a fast trigger, such as several consecutive failures or an error-rate spike against the skill's recent window, which catches a sharp break like the Orion API change within a few requests. Demotion is something the agent may do on its own because it only narrows behaviour. Re-promoting a demoted skill widens it again, so that needs a human.

Keep learning off the request path

The latency requirement allows runtime adaptation at most 150 ms at p95 before the first model call (an assumption). That budget only holds if the learning process stays off the user's request path.

The online path keeps only the router, memory retrieval, skill retrieval, agent execution, the policy check, the tool call and the trace write. Everything expensive moves to the offline path: pattern mining, skill extraction, prompt search, large evaluation runs, fine-tuning and shadow analysis. Memory consolidation and salience decay also run offline. This keeps user latency predictable; a request never waits for the learning loop.

Dynamic examples are the one rung-1 mechanism with a latency and cost side effect online, because they break the prefix cache below the example block. Caching one example set per traffic cluster keeps most requests on a warm prefix.

Learning cost: where it comes from and how to cap it

In this design most learning cost is expected to come from one product: number of candidates × evaluation cases × model calls. Training is rarely the driver. The sizing table showed it directly: 50 candidates a week at 1,280 paired runs each cost $1,920, about 46% of the serving bill.

The answer template lists the controls, cheapest first:

  1. Deduplicate similar candidates, including against the existing library.
  2. Run cheap checks first.
  3. Use smaller models for simple evaluation.
  4. Run full evaluation only for promising candidates.
  5. Evaluate only relevant task families.
  6. Keep a smaller global regression suite.
  7. Set candidate budgets.

Staged evaluation combines several of these into a funnel. Candidates are deduplicated, pass a cheap smoke test, then a small evaluation set; only strong candidates reach full evaluation.

Staged evaluation: candidates are deduplicated, smoke-tested cheaply and run on a small evaluation set, and only strong candidates reach full evaluation.Dark variant: Staged evaluation: candidates are deduplicated, smoke-tested cheaply and run on a small evaluation set, and only strong candidates reach full evaluation.
Staged evaluation: candidates are deduplicated, smoke-tested cheaply and run on a small evaluation set, and only strong candidates reach full evaluation. Open for full size.

Track the controls with explicit metrics: learning spend divided by serving spend, cost per promoted skill, candidates tested per promotion, tokens per successful task, shadow cost and evaluation cost. The cost requirement turns the first metric into a gate: when learning spend breaches its cap (assumed 10% of serving), new candidates are blocked. Never save money by cutting the held-out or per-stratum checks; the cost pivot drill shows the full answer.

Security, governance and metric gaming

All tool calls go through a central tool gateway. The gateway checks identity, permission, action, resource, budget and approval on every call, whichever skill or fallback issued it. That is why a learned procedure cannot carry its own authority.

The audit log stores who, what, when, which version, which tool, which permission and which outcome for every action. Combined with the registry, it answers the auditability questions from step 3: who created a change, why, on what data, which evaluation passed, who approved it and what it can roll back to.

Use human approval for destructive operations, security changes, permission changes, financial actions and new high-risk skills. These overlap with the human-only column in step 13 deliberately: a high-risk skill can be correct and still need a person to accept the risk.

Metric gaming deserves its own example. Suppose we optimise the percentage of tickets closed. The agent may discover that closing every ticket immediately raises the metric, while the real business outcome gets worse. A single, easily gamed metric is the weakness. Use several independent signals: ticket closed, whether it was reopened, customer satisfaction, human QA (quality assurance) review and resolution time. A skill that games one of them shows up as divergence between them, and trajectory-shape monitors per task type (tool mix, steps per run, escalation rate) catch the drift that produced it.

The main trade-offs and when each side wins

Fast learning against safety. More automatic promotion adapts faster but lets weaker candidates reach traffic, so it leans on monitoring and automatic demotion to catch a regression after it ships. Stricter evaluation gives slower adaptation but higher reliability. The source pairs the automatic-promotion side with the demotion path below; the gate and shadow bars in this design choose the stricter side for anything that acts.

The safety net automatic promotion relies on: monitoring detects a regression, the skill is auto-demoted, and traffic returns to the previous skill or the general fallback.Dark variant: The safety net automatic promotion relies on: monitoring detects a regression, the skill is auto-demoted, and traffic returns to the previous skill or the general fallback.
The safety net automatic promotion relies on: monitoring detects a regression, the skill is auto-demoted, and traffic returns to the previous skill or the general fallback. Open for full size.

Memory against skill. Memory stores facts, such as "API max batch size = 100". A skill stores a procedure, such as how to restart the service safely. Do not put everything into memory: a procedure stored as a fact cannot be evaluated, shadowed or demoted as a unit.

General agent against specialised skills. The general agent is flexible and good for novel tasks, but more expensive and less predictable. Specialised skills are fast, cheap and predictable, but less flexible. Use both: skills for known task types and the bounded general agent for the novel ones that will become skills.

Fine-tuning against retrieval. Fine-tuning suits stable, repeated behaviour, but rollback is harder and iteration slower. Retrieval suits changing knowledge, with easy updates and easy rollback. This is the ladder restated as a pair: change knowledge through retrieval and memory, and reserve weights for the three cases in step 11.

References and source boundaries

The source checked these references on 27 September 2026. The book on agentic system design that supplies the spine, memory policy and validation gate is not named in the captured page, so its numbers are cited here as "the book". Numbers marked as assumptions remain whiteboard illustrations.

Apply the decisions

Practice

Attempt the case before revealing the worked reasoning.

Attempt the design on a blank page

Design an agent that adapts to new operations tasks without supervision. Without looking back, define the five rungs, draw the two loops and the gate, state the gate numbers and what they can and cannot prove, and list what only a human may change. Then trace "Restart Orion payment service" from first sighting to automatic demotion. This blank-page exercise is authored guidance; the questions below preserve the source's self-checks, probes and drills.

Work through your answer

This local worksheet is a prototype addition. Notes save in this browser. Nothing is submitted or scored.

No notes yet.

Check your reasoning

Reveal the self-assessment rubric

This checklist is an authored addition. Assess what you can explain without reopening the walkthrough.

0 of 9 reasoning checks covered.

Check yourself

These are the source's fifteen self-check questions. Answer each aloud before opening it.

What are the five rungs of adaptation, cheapest first?

Context, memory, procedure, prompt optimisation, parameters. Each is roughly ten times costlier and harder to undo than the one before.

Which requirement stops a new skill from damaging an old task?

The per-stratum regression floor: no task type may drop more than 3 points after any promotion.

Why can a new task type seeing 30 requests a day not be promoted in two days?

The 200-attempt shadow minimum alone takes about a week at that traffic (200 / 30 is about 7 days).

Where do the runtime loop and the learning loop meet?

Only at the evaluation gate. The runtime reads live registry versions only, so nothing learned reaches traffic without passing the gate.

What should happen to a request the router cannot match confidently?

It goes to a general fallback with tighter bounds, approval on writes and earlier escalation.

What three conditions does Reflexion need?

An external failure signal, a lesson specific enough to change behaviour, and a hard cap on attempts.

Why did the assistant keep proposing the old vendor?

The contradicting statements were stored as separate episodes rather than typed facts, so the older phrasing kept winning retrieval, about one time in four until May. Typed facts with supersession, plus a gate test that seeds contradictory histories, fix it.

What are the book's gate numbers for skills?

Beat baseline by 5 points offline, survive 200 live shadow attempts, and auto-demote at 4 points below baseline.

What keeps prompt optimisation from overfitting?

A test set the optimiser never sees, per-stratum reporting and the standard gate (eval, shadow, owner review).

Why not fine-tune the agent on each new task?

A new task is new knowledge and a new procedure, which belong to retrieval and skills. Fine-tuning fixes missing knowledge slowly and unreliably.

Aggregate accuracy rose from 79% to 81%. Why block the release?

One stratum fell from 82% to 67% inside the average, because it was only about 4% of the eval set. The gate checks every stratum against a 3-point floor.

What may the agent never do on its own?

Grant a skill a new tool, approve an irreversible procedure, raise its own budgets or re-promote a demoted skill.

How do you notice metric gaming?

A second, independent outcome signal, such as reopen rate or sampled human review, and trajectory-shape monitors per task type.

What is the walking skeleton?

The router, the fallback, dynamic examples, the memory write policy and the trace store: rungs 1 and 2 plus traces.

What is the sixty-second cost answer?

Learning cost is candidate volume times suite size. Dedupe and smoke-test candidates, scope suites to the strata a change touches, and track learning spend per promotion.

Answer the follow-up probes

These probes come from the question bank, with the source's strong answers for this design.

How do you version and roll back agent behaviour, and A/B test it?

Every learned artefact is a registry version with a status; rollback is a status change. Shadow first, then canary with per-stratum guardrails.

How do you keep long-term memory from getting polluted?

A four-gate write policy, typed facts, supersession with pointers, decay per predicate, and a contradiction test in the release gate.

Working, episodic, semantic memory: when do you retrieve and when do you ignore?

Retrieve under a token budget, scoped by tenant, with superseded facts dropped. Ignore anything unattributable.

Design an eval harness for a 99% task-success target.

Per-stratum golden sets sized by the sample-size arithmetic. At p = 0.99, even small drops need large samples, so lean on paired evaluation and production monitoring.

How do you detect goal drift or misalignment?

Trajectory-shape monitors per task type, a second independent outcome signal, and sampled human review.

What logic belongs in the orchestrator versus the model?

Budgets, permissions, promotion and demotion live in code. The model chooses actions and proposes candidates.

How do you detect and stop infinite planning loops?

Four bounds on the loop: steps, tokens, time and spend. The fallback mode gets tighter bounds than known skills.

How do you control cost explosions?

Per-run and per-day budgets at runtime, and a learning budget that blocks new candidates when breached.

When do you route to a human?

For irreversible actions, low-confidence novel requests, reached attempt caps and any permission change.

Which metrics matter beyond task success?

Time to competence for new types, per-stratum regression, escalation rate, demotions per week and learning cost share.

Re-derive the design when a constraint changes

Expect a constraint change mid-round. Re-derive only the part the new constraint touches.

The interviewer says there is no reliable success signal. What changes?

Reflexion and skill promotion both depend on an external verdict, so both go. Adaptation falls back to human-reviewed memories and examples.

Tasks now change daily. What changes?

Everything moves down to rung 1, and training is ruled out. A skill or a tuned model would encode a definition that is gone by the time it passes the gate.

Regulators require every behaviour change to be approved. What changes?

The whole design stays, but owner review becomes mandatory at every promotion rather than only for permission or budget changes.

Deliver it in sixty minutes

Spend the hour on the ladder and the gate. The source follows a six-step decomposition framework: clarify the mission, stakeholders and metrics, map inputs, decompose and sequence by risk, build a walking-skeleton MVP, then adapt live. Reported interview questions say evaluation sets strong candidates apart in the OpenAI decomposition round; the source assumes the same holds here.

The 60-minute delivery plan.

Minutes Move What to say
0–5ClarifyWhat counts as new, what signals success, which actions are irreversible, who owns capabilities
5–10Stakeholders and metricsCapability owners and the platform team; time to competence, no-regression floor, cost share
10–15InputsTraces, outcomes, tool schemas, owner reviews; which of them are trustworthy
15–25LadderFive rungs, cheapest first; this design lives mostly on rungs 1 to 3
25–35DrawRuntime loop, learning loop, one gate, registry with versions
35–45GateHeld-out, paired, per stratum; safety absolute; shadow; auto-demotion; sample-size arithmetic
45–52BoundsWhat the agent may change and what only a human may
52–60Adapt liveRe-derive the part the new constraint touches

The answer template's version of the same hour uses plainer labels: 0–5 minutes clarify what "new task" means; 5–10 functional and non-functional requirements; 10–15 traffic and task assumptions; 15–25 the adaptation ladder; 25–35 architecture; 35–45 evaluation and the release gate; 45–52 safety and permissions; 52–60 scaling, cost, failures and trade-offs. Rehearse either aloud with a timer.

Respond to the cost pivot

After a good design, the interviewer's pivot is "the learning loop costs more than serving". Try the answer before opening it.

The learning loop costs more than serving. What do you do in ten minutes?

Name the driver, take the cheapest lever, prove it with a metric and protect the checks that keep the agent safe. The table is the source's full answer.

The ten-minute cost pivot.

Part Answer
Dominant driverEvaluating too many near-duplicate candidates, each through a full paired suite; dynamic examples breaking the prefix cache on every request
Cheapest lever firstDedupe candidates against the library before evaluation; pre-screen on a small smoke suite and send only survivors to the full suite; evaluate only the strata a candidate can touch plus a regression sample; cache one example set per traffic cluster
Metric that proves itLearning spend as a share of serving spend; candidates evaluated per promotion; cache hit rate; cost per successful run
Do notCut the held-out or per-stratum checks to save money, or climb to fine-tuning because evaluation feels expensive
60-second lineLearning cost is candidate volume times suite size. Dedupe and smoke-test candidates before the full gate, scope suites to the strata a change touches, and keep the prefix cache warm. The metric is learning spend per promotion.

The four verbs from the cost playbook give the same answer. Measure, by attributing spend to runtime versus learning and to each candidate. Route, by sending cheap changes through cheap checks and full suites only to survivors. Bound, with a learning budget that blocks new candidates when breached. Cache safely, by reusing baseline results across candidates evaluated against the same baseline version.

Calibrate your answer to the level

On this design the levels separate on who owns the evaluation gate and what the agent may change about itself, not on how many learning mechanisms get drawn.

How senior, staff and principal answers differ.

Level Sounds like Missing
Senior"I'd score novelty and send unknown requests to a fallback with tighter bounds, adapt through outcome-ranked examples and a memory write policy, and promote a skill only once it beats baseline by 5 points and survives 200 shadow attempts."Gating per task type rather than on the mean, the sample-size point that 200 attempts prove "not much worse" rather than a 5-point gain, and who owns and rolls back each skill.
Staff"Every skill, memory and prompt is a registry version with a team owner. The gate holds a 3-point floor per task type, demotes at 4 points below baseline, and a learning budget stops candidate volume outrunning serving spend."Goal drift and metric gaming across the teams that own skills, and when the organisation should fund weight updates at all.
Principal"The agent learns how but never gains authority, so permission changes stay human-only for good. Training is funded only for format at volume, missing vocabulary or a latency ceiling, and a second independent outcome signal guards against gaming."Real traffic per task type and which outcome signals the customer trusts; those decide whether the 14-day time to competence and the 10% learning cap are realistic.

Say it in one line and in thirty seconds

The answer template ends with two spoken summaries. Practise both until they sound like your own words.

Give the one-paragraph interview explanation.

"I would design the self-adapting agent with a production runtime loop and a separate offline learning loop. The agent first adapts through context, memory and reusable skills, while every new capability must pass offline evaluation, shadow testing and a controlled promotion gate before production. The agent can learn how to perform tasks, but permissions and safety limits always stay in an external policy layer."

Give the thirty-second summary.

Self-adapting should mean controlled learning, not uncontrolled self-modification. The source's diagram for this summary is in the Quick review. A user request is classified as known or novel, runs on an approved skill or the safe fallback through policy-controlled tools, and its external outcome lands in the trace store. Offline learning turns traces into memory, skill or prompt candidates, which pass evaluation and shadow before promotion, and live skills are monitored and auto-demoted.

Return to the decisions you could not explain.

Review the essentials

Quick review

Recall the decisions, failure responses, and closing answer.

The ladder, the loops and the gate

"Adapt" means five rungs: context, memory, procedure (skills), prompt optimisation and weights. Each is about ten times costlier and harder to undo than the last, so design from the cheap end and climb only when a measured gap forces it. A runtime loop and a learning loop meet at one evaluation gate, and every artefact is a versioned registry entry with an owner and a status.

Detect novelty before handling it, using a low retrieval score, an unknown system or tool, a near tie between the top two skills, or no skill above the confidence threshold. Run unknown tasks in a fallback mode with tighter bounds, read-only tools first, approval on writes and earlier escalation.

Runtime adaptation uses outcome-ranked, diverse examples and Reflexion. Reflexion needs an external oracle, a specific lesson and a cap. Memory is a write problem: four gates (durable, reusable, attributable, permitted), typed facts and supersession keep it from polluting future runs.

Every candidate goes through the same sequence after it is proposed.

Every candidate passes offline evaluation, shadow, promotion, monitoring and auto-demotion.Dark variant: Every candidate passes offline evaluation, shadow, promotion, monitoring and auto-demotion.
Every candidate passes offline evaluation, shadow, promotion, monitoring and auto-demotion. Open for full size.

Numbers and rules to recall

  • Gate: beat baseline by 5 points offline, survive at least 200 live shadow attempts, auto-demote at 4 points below baseline, and never drop any stratum more than 3 points.
  • Sample size: n ≈ 15.7 × p(1−p) / δ² per arm. At p = 0.8, 200 cases detect only about 11 points; 5 points needs about 1,000 per arm. The shadow proves "not much worse".
  • Sizing (assumptions): 20,000 requests a day over 40 types, 3 new types a week, 30 requests a day for a new type (about 7 days of shadow), $0.03 a run, 50 candidates a week at $38.40 each, which is about 46% of the $4,200 weekly serving bill against a 10% cap.
  • Requirements (assumptions): 14-day time to competence, at most 150 ms p95 runtime adaptation overhead.
  • Worked failures: 79% to 81% aggregate hid a stratum falling 82% to 67%; a 94% offline routing fine-tune scored about 78% live, honest number near 83%; the old vendor resurfaced about one time in four.
  • Weights only for format at volume, missing vocabulary, or a cost or latency ceiling; never for missing knowledge.

Bounds, failures and the closing answer

The agent may choose skills and examples, write memories that pass the policy, propose candidates, retry within the cap and demote a regressing skill. Only a human may grant a tool, approve an irreversible procedure, change permissions or budgets, raise caps or re-promote a demoted skill. The gateway checks every call, irreversible actions go to a person, budgets cap every run, and a kill switch freezes learning.

Name the failures with their guards: forced fit, skill that worked once, stale skill, memory pollution, self-graded lessons, optimiser overfit, leaky training data, metric gaming, permission creep and runaway learning cost. Evaluate the full trajectory, not only the final answer.

Spend the hour on the ladder and the gate, and ship a walking skeleton of rungs 1 and 2 plus traces. For the cost pivot, dedupe and smoke-test candidates, scope suites to the strata a change touches, keep the prefix cache warm and track learning spend per promotion.

The thirty-second summary traces the whole system as one chain.

The thirty-second summary: user request, known-or-novel detection, approved skill or safe fallback, agent with policy-controlled tools, external outcome and trace store, then offline learning, a memory, skill or prompt candidate, evaluation, shadow, promotion, and monitoring with auto-demotion.Dark variant: The thirty-second summary: user request, known-or-novel detection, approved skill or safe fallback, agent with policy-controlled tools, external outcome and trace store, then offline learning, a memory, skill or prompt candidate, evaluation, shadow, promotion, and monitoring with auto-demotion.
The thirty-second summary: user request, known-or-novel detection, approved skill or safe fallback, agent with policy-controlled tools, external outcome and trace store, then offline learning, a memory, skill or prompt candidate, evaluation, shadow, promotion, and monitoring with auto-demotion. Open for full size.

The closing line: the agent can learn how to do something, but policy decides what it is allowed to do. Self-adapting should mean controlled learning, not uncontrolled self-modification.

Test your recall

Where next

Revise the concepts