|
| 1 | +# Plan: add-failure-investigation-to-skill-builder |
| 2 | + |
| 3 | +## Goal |
| 4 | + |
| 5 | +When `cat:instruction-builder-agent`'s SPRT benchmark rejects one or more test cases, automatically |
| 6 | +run a structured failure investigation before presenting results to the user. The investigation mirrors |
| 7 | +the methodology in `plugin/skills/learn/phase-investigate.md`: use `cat:get-history-agent` and |
| 8 | +`session-analyzer` to examine raw conversation transcripts, thinking blocks, agent context at the time |
| 9 | +of failure, and sources of priming (e.g., prior runs sharing subagent context, model defaults, escape |
| 10 | +clauses in instructions). |
| 11 | + |
| 12 | +## Background |
| 13 | + |
| 14 | +Currently, when SPRT rejects, the instruction-builder shows aggregated pass/fail counts and asks the |
| 15 | +user what to do next. The root cause is not investigated — the assumption is that the skill instructions |
| 16 | +are at fault. This assumption can be wrong (see: batch contamination producing spurious TC5 failures |
| 17 | +where runs 1-13 were 100% pass but runs 14-27 contaminated by shared context were ~7% pass). |
| 18 | + |
| 19 | +## Approach |
| 20 | + |
| 21 | +Add a new investigation sub-step after SPRT completes and before presenting results to the user: |
| 22 | + |
| 23 | +1. Identify which test cases were Rejected |
| 24 | +2. For each rejected test case, retrieve the subagent IDs for the failing runs using session-analyzer |
| 25 | +3. Examine the subagent conversation logs: what did the agent receive as context? What was in its |
| 26 | + `<output>` tag injection? Were there thinking blocks showing the agent rationalizing adding follow-ups? |
| 27 | +4. Look for priming sources: |
| 28 | + - Batch contamination (multiple runs in one subagent context) |
| 29 | + - Model-default behaviors overriding "Do not..." instructions |
| 30 | + - Escape clauses ("unless user requests") being exploited |
| 31 | + - Prior successful patterns in context being replicated |
| 32 | +5. Present findings to the user alongside the SPRT results |
| 33 | + |
| 34 | +## Sub-Agent Waves |
| 35 | + |
| 36 | +### Wave 1 |
| 37 | +- Read `plugin/skills/instruction-builder-agent/SKILL.md` (worktree copy) |
| 38 | +- Read `plugin/skills/learn/phase-investigate.md` for investigation methodology |
| 39 | +- Design the investigation sub-step: where it fits in Step 3 of the SPRT loop, what it reads, what it outputs |
| 40 | +- Update `plugin/skills/instruction-builder-agent/SKILL.md` to add the investigation sub-step after SPRT and before the user-facing results presentation |
| 41 | +- The investigation should: |
| 42 | + - Use `session-analyzer analyze <SESSION_ID>` to discover subagent IDs for failing benchmark runs |
| 43 | + - Use `session-analyzer search <SESSION_ID>/subagents/agent-<ID> "Would you like|What would you"` to find failure instances |
| 44 | + - Report: which runs failed, what the agent output was, whether batch contamination is present (multiple runs in one subagent), and what priming sources were detected |
| 45 | + |
| 46 | +## Post-conditions |
| 47 | + |
| 48 | +- [ ] `plugin/skills/instruction-builder-agent/SKILL.md` contains an investigation sub-step that runs automatically on SPRT Reject |
| 49 | +- [ ] The investigation step uses `cat:get-history-agent` / `session-analyzer` to examine raw subagent conversations |
| 50 | +- [ ] The investigation identifies batch contamination, thinking block patterns, and instruction priming sources |
| 51 | +- [ ] Investigation findings are presented to the user before asking whether to improve the skill |
| 52 | +- [ ] No regressions to the existing SPRT benchmark loop |
0 commit comments