Free self-study · No account needed · Progress stays in this browser. Back it up before clearing site data or changing devices.

← Week 16: Self-Improving AI Systems

Week 16 / Lesson 1

Turning failures into candidate improvements

Propose bounded prompt, skill, or configuration changes from recorded failures.

Section 1.1 1 of 7

Overview

Focus

Propose bounded prompt, skill, or configuration changes from recorded failures.

Your route through the lesson

  • 1.2 Reflection grounded in error evidence
  • 1.3 Generating skill and prompt candidates
  • 1.4 Search spaces and evolutionary selection
  • 1.5 Put it into practice
  • 1.6 Guided comparison
  • 1.7 A candidate that copies benchmark answers

All required teaching is included here. Review selections are saved. Choose a correct answer for every question to continue; retries are unlimited. Study time and personal notes are optional.

Section 1.2 2 of 7

Reflection grounded in error evidence

Focus

Turn recorded failures into a falsifiable improvement hypothesis.

Reflection is useful when it connects an observed failure to a proposed mechanism. A paragraph saying be more careful does not identify what changes or how success would be measured. Start with a case record: input, expected behavior, actual behavior, artifact version, and failure category. Then propose a change that could plausibly address that category.

Suppose a proposal classifier accepts confidence 0.35 even though the development label is reject. The baseline threshold is 0.2. A concrete hypothesis is that raising the threshold will reduce low-confidence false accepts. It also predicts a possible regression: some legitimate proposals near the new threshold may be rejected. Recording both predictions prevents reflection from becoming a story told only after seeing results.

Separate evidence from conjecture. The failure establishes one incorrect decision; it does not prove confidence is calibrated or that a threshold change will generalize. A candidate is a versioned proposal, not an improvement until compared fairly. Keep the original failing example for development diagnosis while reserving other cases for selection and final evaluation. Otherwise repeated reflection can memorize the benchmark rather than improve the supported behavior.

// Quick review

Check your understanding.

Choose an answer for immediate feedback. Retry freely; a correct answer for every question unlocks the next section.

1. A 0.35 proposal is wrongly accepted under threshold 0.2. Which hypothesis is testable?
2. One development failure motivates a candidate. What is established already?
3. Why record a predicted regression alongside a proposed fix?

Section 1.3 3 of 7

Generating skill and prompt candidates

Focus

Version bounded prompt, skill, and configuration proposals without granting deployment authority.

A candidate may change a prompt, a reusable skill instruction, or a configuration parameter. These are distinct artifacts. A prompt supplies task instructions; a skill packages a bounded procedure and supporting resources; configuration sets explicit choices such as thresholds or retry limits. None of these automatically changes model weights.

Give each candidate a version, editable fields, hypothesis, parent version, and development evidence. For a threshold search, five candidates can use 0.2, 0.4, 0.5, 0.7, and 0.9. A skill candidate might add a required unit-validation step after failures involving milliseconds. Its acceptance still requires behavioral checks; a more detailed instruction is not automatically a better instruction.

The candidate generator must not edit the evaluator, reserved cases, permission rules, or active deployment pointer. Otherwise it can obtain a better score by changing what counts as success. Treat generated text as a proposed artifact. Any agent-generated executable code belongs only in a bounded disposable environment with enforced restrictions before execution. The supplied core lab searches trusted scalar configuration dictionaries, so it needs no arbitrary code execution or model download.

// Quick review

Check your understanding.

Choose an answer for immediate feedback. Retry freely; a correct answer for every question unlocks the next section.

1. Changing a prompt or threshold necessarily trains model weights. True?
2. Which field should a candidate generator be allowed to change in the threshold fixture?
3. A generated skill adds unit validation. What establishes improvement?

Section 1.4 4 of 7

Search spaces and evolutionary selection

Focus

Define search spaces and evolutionary selection without treating search as weight training.

A search space is the set of permitted candidates. Exhaustive search evaluates every listed option; random search samples options; evolutionary search keeps selected candidates and creates variations from them. The evolutionary terminology is a search metaphor: a parent configuration produces modified child configurations, and a fitness rule ranks their observed outcomes.

For a worked five-threshold search, compute development success for each threshold, retain candidates meeting a minimum, then rank them on selection cases. A mutation might change threshold 0.5 to 0.55 within declared bounds. Keep version lineage and the exact scoring rule so the chosen result can be reproduced. Do not let a candidate redefine its own fitness.

Search consumes evaluation budget and can overfit selection data when repeated too often. More candidates increase the chance that a narrow benchmark favors a lucky or memorized variant. Bound candidate count and rounds, preserve a baseline, and keep final cases untouched until a version is frozen. This is configuration optimization, not reinforcement training. No policy weights change in the core fixture, and a deterministic threshold score cannot demonstrate a language model's ability to generate useful improvements.

// Quick review

Check your understanding.

Choose an answer for immediate feedback. Retry freely; a correct answer for every question unlocks the next section.

1. An evolutionary search mutates threshold 0.5 to 0.55 and ranks results. What changed?
2. Why bound the number of search rounds?
3. Which record makes a selected candidate reproducible?

Section 1.5 5 of 7

Put it into practice

Focus

Generate five versioned candidates inside a protected search space.

Download week16.py, save it in an exercise folder, and run python week16.py --lesson 1. This single practice writes five configuration files into a temporary folder and checks their permitted fields. The processor-only standard-library run finishes within seconds, needs no account or model, and executes no generated source code.

The candidates function returns dictionaries with version, threshold, and hypothesis. enumerate supplies an index and value while traversing the five thresholds. An f-string such as f'v{i}' inserts the index into a version label. json.dumps serializes each dictionary, and Path.write_text writes a versioned file. These files are disposable artifacts rather than active deployments.

The field assertion converts each dictionary's keys into a set and compares it with the exact permitted set. A candidate containing evaluator_path or deployment_target would fail that admission check. The count assertion verifies five candidates exist. PASS means the generator respected this bounded configuration format. It does not mean any candidate is better, that a skill was learned by a model, or that final evaluation has occurred. Candidate generation and measurement are deliberately separate steps of the same weekly artifact.

Download this week’s Python lab ↓

// Quick review

Check your understanding.

Choose an answer for immediate feedback. Retry freely; a correct answer for every question unlocks the next section.

1. The fixture generates thresholds 0.2,0.4,0.5,0.7,0.9. How many candidates?
2. A candidate adds evaluator_path to the permitted three keys. Expected admission result?
3. What does f"v{i}" do when i equals 4?

Section 1.6 6 of 7

Guided comparison

Focus

Read candidate-generation evidence without confusing proposal count with improvement.

The worked generator creates versions v1 through v5 with a shared hypothesis and different thresholds. Versioning makes each choice identifiable; the identical hypothesis explains the common mechanism being tested. The output files can be inspected during a modified local run, but the default script cleans its temporary directory, leaving no persistent deployment change.

The exact-key check protects the boundary between proposing behavior and changing the judge. It is an admission rule, not operating-system isolation. The dictionaries never contain executable code, and the fixture never launches candidate programs. In a real agent system, candidate files and evaluator files should have separate write permissions so a producer cannot bypass that rule through another path.

Five admitted candidates are five hypotheses awaiting evidence. Some may make the same decisions on a small set; others may trade false accepts for false rejects. Retain the baseline so selection can be compared against known behavior. A search that reports only its best score without the baseline or candidate budget hides whether improvement came from useful reasoning, extensive trial, or simple benchmark specialization. The next stage must freeze a version before accessing reserved final cases.

// Quick review

Check your understanding.

Choose an answer for immediate feedback. Retry freely; a correct answer for every question unlocks the next section.

1. Five files satisfy the candidate schema. What is proven?
2. Does an exact dictionary-key check isolate arbitrary executable code?
3. Why retain the baseline during search?

Section 1.7 7 of 7

A candidate that copies benchmark answers

Focus

Reject benchmark-answer copying as an improvement mechanism.

A prompt candidate contains a table mapping every visible benchmark identifier to its expected answer. Its development score becomes perfect. This may be useful as a lookup system if lookup is the real product requirement, but it does not demonstrate general improvement on unseen tasks. When the stated goal is transferable task behavior, copying benchmark answers exploits the evaluation surface.

The worked evaluator checks candidate scope and provenance before promotion. The proposal is flagged because it embeds development case identifiers and answers instead of a general rule. Selection cases use distinct identifiers, and final cases remain unseen until a version is frozen. A candidate that memorized the visible table may then fail, revealing the limited mechanism.

Do not repair the situation by repeatedly exposing final answers and asking for another candidate. Once those answers guide revision, they become development data and a new reserved evaluation is needed. Record the exposure honestly. The transferable lesson is that improvement claims depend on the intended task distribution and data separation. A high score can represent memorization, leakage, or a legitimate narrow lookup; the mechanism and requirement determine which claim is warranted.

// Quick review

Check your understanding.

Choose an answer for immediate feedback. Retry freely; a correct answer for every question unlocks the next section.

1. A prompt embeds every visible benchmark answer. What does a perfect visible score establish?
2. Final answers are exposed and then used to revise a candidate. What are those cases now?
3. When could an answer table be a legitimate solution?

Your personal notes

Optional, ungraded, and saved only in this browser. Export a backup from the Academy homepage to keep them.

References and further reading
Ask your own AI assistant

Copy this prompt into an assistant you already use. Nothing is sent automatically, and your personal notes are not included.

Next lesson: Measuring whether a change helps →