Skip to content
This repository was archived by the owner on Apr 11, 2026. It is now read-only.

Commit 5cde86e

Browse files
committed
feat(worker): add self-reflection and structured output to phase content
- Phase 2.5: add SELF-AWARENESS and RECOGNIZE YOUR RATIONALIZATIONS sections to combat verification shortcuts - Phase 6: replace free-text return with structured Scope/Result/Files/Tests/Issues format - Add smoke tests verifying both patterns in worker-phase content - Fix lifecycle test to include phase 5b in completion sequence Task: fn-1-prompt-optimization-official-patterns.2
1 parent 76b6a1d commit 5cde86e

2 files changed

Lines changed: 53 additions & 3 deletions

File tree

agents/worker.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,19 @@ Capture `BASE_COMMIT=$(git rev-parse HEAD)`. For 3+ files use Wave-Checkpoint-Wa
5757
<!-- section:core -->
5858
## Phase 2.5: Verify & Fix
5959
Run `$FLOWCTL guard`, fix until green. Review `git diff` for debug code, hardcoded values, missing error handling. Fix and re-guard.
60+
61+
=== SELF-AWARENESS ===
62+
You are Claude, and you are bad at verification:
63+
- You read code and write "PASS" instead of running it.
64+
- You trust self-reports ("tests pass") without running them yourself.
65+
- You see code that looks correct and skip the actual test.
66+
Knowing this, run every check. Reading is not verification.
67+
68+
=== RECOGNIZE YOUR RATIONALIZATIONS ===
69+
- "The code looks correct" → Run it.
70+
- "Tests already pass" → Run them yourself.
71+
- "This is probably fine" → Probably is not verified.
72+
- "I just changed one line" → One line can break everything.
6073
<!-- /section:core -->
6174
<!-- section:core -->
6275
## Phase 3: Commit
@@ -76,5 +89,13 @@ Save only non-obvious pitfalls/conventions/decisions via `$FLOWCTL memory add`.
7689
<!-- /section:memory -->
7790
<!-- section:core -->
7891
## Phase 6: Return
79-
Report: what was implemented, key files changed, tests run, review verdict. Verify commit exists and task status is "done".
92+
Your response MUST use this format:
93+
94+
Scope: <echo back task title in one sentence>
95+
Result: <what was implemented, key decisions made>
96+
Files changed: <list with commit hash>
97+
Tests: <pass/fail with counts>
98+
Issues: <any flags, blockers, or notes -- "none" if clean>
99+
100+
Verify commit exists (`git log --oneline -1`) and task status is "done" (`$FLOWCTL show $TASK_ID --json`).
80101
<!-- /section:core -->

scripts/smoke_test.sh

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1950,6 +1950,35 @@ else
19501950
FAIL=$((FAIL + 1))
19511951
fi
19521952

1953+
# Test: worker-phase 2.5 content contains SELF-AWARENESS pattern
1954+
wph_content_2_5="$(echo "$wph_next2_5" | "$PYTHON_BIN" -c 'import json,sys; print(json.load(sys.stdin).get("content",""))')"
1955+
if echo "$wph_content_2_5" | grep -q "SELF-AWARENESS"; then
1956+
echo -e "${GREEN}${NC} worker-phase 2.5 content: contains SELF-AWARENESS pattern"
1957+
PASS=$((PASS + 1))
1958+
else
1959+
echo -e "${RED}${NC} worker-phase 2.5 content: missing SELF-AWARENESS pattern"
1960+
FAIL=$((FAIL + 1))
1961+
fi
1962+
1963+
# Test: worker-phase 6 content contains structured output format (Scope:)
1964+
# Advance through remaining phases to reach phase 6
1965+
EPIC_PH2_JSON="$(scripts/flowctl.py epic create --title "Phase content test" --json)"
1966+
EPIC_PH2="$(echo "$EPIC_PH2_JSON" | "$PYTHON_BIN" -c 'import json,sys; print(json.load(sys.stdin)["id"])')"
1967+
scripts/flowctl.py task create --epic "$EPIC_PH2" --title "Content task" --json >/dev/null
1968+
scripts/flowctl.py start "${EPIC_PH2}.1" --json >/dev/null
1969+
for phase in 0 1 2 2.5 3 5 5b; do
1970+
scripts/flowctl.py worker-phase done --task "${EPIC_PH2}.1" --phase "$phase" --json >/dev/null
1971+
done
1972+
wph_next6="$(scripts/flowctl.py worker-phase next --task "${EPIC_PH2}.1" --json)"
1973+
wph_content_6="$(echo "$wph_next6" | "$PYTHON_BIN" -c 'import json,sys; print(json.load(sys.stdin).get("content",""))')"
1974+
if echo "$wph_content_6" | grep -q "Scope:"; then
1975+
echo -e "${GREEN}${NC} worker-phase 6 content: contains structured output format (Scope:)"
1976+
PASS=$((PASS + 1))
1977+
else
1978+
echo -e "${RED}${NC} worker-phase 6 content: missing structured output format (Scope:)"
1979+
FAIL=$((FAIL + 1))
1980+
fi
1981+
19531982
# Test: worker-prompt --bootstrap outputs <300 tokens
19541983
wp_boot_json="$(CLAUDE_PLUGIN_ROOT="$TEST_DIR/repo" scripts/flowctl.py worker-prompt --task "${EPIC1}.1" --bootstrap --json)"
19551984
wp_boot_tokens="$(echo "$wp_boot_json" | "$PYTHON_BIN" -c 'import json,sys; print(json.load(sys.stdin)["estimated_tokens"])')"
@@ -1963,8 +1992,8 @@ else
19631992
fi
19641993

19651994
# Test: complete all remaining default phases → all_done
1966-
# Phases 0, 1, 2 already done above; complete remaining: 2.5, 3, 5, 6
1967-
for phase in 2.5 3 5 6; do
1995+
# Phases 0, 1, 2 already done above; complete remaining: 2.5, 3, 5, 5b, 6
1996+
for phase in 2.5 3 5 5b 6; do
19681997
scripts/flowctl.py worker-phase done --task "${EPIC_PH}.1" --phase "$phase" --json >/dev/null
19691998
done
19701999
wph_final="$(scripts/flowctl.py worker-phase next --task "${EPIC_PH}.1" --json)"

0 commit comments

Comments
 (0)