t27.aiEnglish

Один маленький шаг за промпт

Вы узнаете

Почему план из маленьких шагов с проверкой на каждом оставляет одного подозреваемого, когда что-то ломается.

Большая просьба - это цепочка маленьких, и агент может ошибиться в любом звене. В small_step.t27 в плане пять шагов, и каждый кончается проверкой, которую ты запускаешь до следующего промпта. Список PASSED хранит 1 для шага, чья проверка прошла, и 0 для шага, чья не прошла: 1, 1, 0, 0, 0. Самый ранний ноль - шаг 3, значит, править нужно только промпт шага 3. Один большой промпт на все пять шагов оставляет пять подозреваемых, один маленький шаг - одного. В уроке подкладывается одна ошибка: скажи, что раньше всех упал шаг 4, и тест, который читает список, это поймает.

Попробуйте

На схеме найди самый ранний шаг, чья проверка не прошла; затем в спецификации замени FIRST_FAILED с 3 на 4 и запусти тесты.

Открыть интерактивный урок →

Vibecoding: one small step per prompt ↗

A plan of five steps with a check each: the first step that fails is the only prompt to fix. One big prompt leaves five suspects, a small step leaves one. Vibecoding from zero.

specs/vibecoding/small_step.t27

// SPDX-License-Identifier: Apache-2.0
; Vibecoding, module Prompting, lesson 3: one small step per prompt.
; A big request is a chain of small ones. Each step ends with a check you run before the next
; prompt. If a step fails, you know which one: the last. This spec lists a plan of five steps,
; says which steps passed, and finds the first one that did not.

module vibecoding_small_step;

pub const STEP_COUNT : u8 = 5;
; 1 means the step's check passed, 0 means it failed or was not run yet.
pub const PASSED : [5]u8 = [1, 1, 0, 0, 0];

; first_failed walks the plan in order and returns the number of the first step that did not pass.
; It returns STEP_COUNT + 1 when every step passed.
pub fn first_failed(a: u8, b: u8, c: u8, d: u8, e: u8) -> u8 {
    if (a == 0) { return 1; }
    if (b == 0) { return 2; }
    if (c == 0) { return 3; }
    if (d == 0) { return 4; }
    if (e == 0) { return 5; }
    return 6;
}

; The first failed step in the plan above is step 3: that is the only prompt to fix.
pub const FIRST_FAILED : u8 = 3;
; One big prompt for all five steps: when it fails, any of the five could be the cause.
pub const SUSPECTS_ONE_BIG_PROMPT : u8 = 5;
; One small step per prompt: only the step that just ran can be the cause.
pub const SUSPECTS_SMALL_STEP : u8 = 1;

test the_first_two_steps_passed {
    assert PASSED[0] == 1;
    assert PASSED[1] == 1;
}

test step_three_is_the_first_to_fail {
    assert PASSED[FIRST_FAILED - 1] == 0;
    assert PASSED[FIRST_FAILED - 2] == 1;
}

test a_small_step_leaves_one_suspect {
    assert SUSPECTS_SMALL_STEP == 1;
    assert SUSPECTS_ONE_BIG_PROMPT == STEP_COUNT;
    assert SUSPECTS_SMALL_STEP < SUSPECTS_ONE_BIG_PROMPT;
}

test the_last_step_is_read {
    assert PASSED[STEP_COUNT - 1] == 0;
}

Открыть спеку урока в плеере ↗

Все уроки