# Self-Review Protocol for Repeated Failures in Reverse‑Skill: 2‑3 Consecutive Attempts Rule

> Learn the self-review protocol for reverse-skill failures. Stop retrying failed commands after 2-3 consecutive attempts and switch to a new approach to ensure progress.

- Repository: [ZhaoXu/reverse-skill](https://github.com/zhaoxuya520/reverse-skill)
- Tags: best-practices
- Published: 2026-08-19

---

**When a tool or command fails 2‑3 times in a row, the agent must stop, assess progress against the goal, cite concrete error evidence, and switch to an alternative approach—never retrying the same command again.**

The `zhaoxuya520/reverse-skill` repository enforces a strict **self-review loop** designed to prevent infinite retry loops and wasted computational budget. This protocol, documented in **[`RULES.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/RULES.md)**, governs how automated reverse‑engineering agents respond when identical tool invocations fail repeatedly.

---

## When to Trigger the Self-Review Protocol

According to the **Self‑Supervision** section of [`RULES.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/RULES.md), the agent must maintain a counter for every tool call:

- After **any tool execution**, count how many times the **same tool with identical parameters** has been invoked
- On the **second or third consecutive failure**, the agent **must stop** and **must not** issue the same command again

This hard limit prevents the common automation anti‑pattern of "poke it until it works."

---

## What the Review Process Requires

The protocol demands active self‑assessment before proceeding. The agent must answer two diagnostic questions drawn directly from [`RULES.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/RULES.md) lines 27‑33:

**"Am I actually making progress toward the goal?"**

**"Can I clearly explain the last error message?"**

Each answer requires **concrete evidence**: log excerpts, stderr output, or return codes that demonstrate why the failure occurred. Vague assertions like "it didn't work" violate the protocol.

---

## How to Switch the Approach

When the failure threshold is reached, the agent must select a **different tactic** that satisfies the same higher‑level objective. The repository specifies three categories of alternatives:

| Category | Example Substitution |
|----------|-------------------|
| **Static → Dynamic** | Replace IDA Pro with radare2, or add runtime instrumentation |
| **Tool Substitution** | Swap `jadx` for `apktool`, or `nmap` for `masscan` |
| **Parameter Alteration** | Adjust timeouts, change output formats, or modify flags |

The decision and its outcome must be recorded in [`skills/field-journal/_index.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/field-journal/_index.md) under the **Experience Reuse** policy, building a reusable knowledge base for future operations.

---

## Budget Caps and User Escalation

The [`RULES.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/RULES.md) protocol includes a fail‑safe ceiling: any sub‑task requiring **more than 30 tool calls** triggers mandatory user notification. The agent must:

- Inform the user of the current progress
- Request explicit permission to continue
- Document the escalation in the field journal

This prevents runaway automation on intractable problems.

---

## Final Self‑Audit After Switching

Before resuming normal operation, the agent must complete the **Completion Checklist** at the end of [`RULES.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/RULES.md):

- Verify the new approach executed successfully
- Confirm the method is documented in the field journal
- Store all generated evidence (artifacts, logs, outputs)

Only after this audit may the behavior chain continue.

---

## Implementation Example: Enforcing the Protocol

The following Bash script demonstrates how to programmatically implement the 2‑failure rule from [`RULES.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/RULES.md):

```bash
#!/usr/bin/env bash

# self_review.sh – enforce RULES.md protocol

MAX_RETRIES=2               # Fail after 2 identical attempts

CALL_COUNT=0
LAST_CMD=""

run_tool () {
    local cmd="$1"
    echo "Running: $cmd"
    eval "$cmd"
    local rc=$?
    ((CALL_COUNT++))

    if (( rc != 0 )); then
        echo "🔴 Error (exit $rc)."
        # If the same command failed twice, switch strategy

        if [[ "$cmd" == "$LAST_CMD" && $CALL_COUNT -ge $MAX_RETRIES ]]; then
            echo "⚠️ Same approach failed $CALL_COUNT times – switching strategy."
            switch_strategy "$cmd"
        fi
    else
        echo "✅ Success."
        # Reset counters on success

        CALL_COUNT=0
        LAST_CMD=""
    fi
    LAST_CMD="$cmd"
}

switch_strategy () {
    local failed_cmd="$1"
    echo "🔄 Choosing alternative for: $failed_cmd"

    case "$failed_cmd" in
        *"jadx"* )
            echo "→ Trying apktool instead of jadx."
            run_tool "apktool d target.apk -o out_dir"
            ;;
        *"nmap"* )
            echo "→ Using masscan as fallback."
            run_tool "masscan -p0-65535 target_ip"
            ;;
        *"ida"* )
            echo "→ Switching to radare2."
            run_tool "r2 -A target.bin"
            ;;
        * )
            echo "→ No known fallback – reporting to user."
            echo "Please provide a manual step or alternative tool."
            ;;
    esac
}

# Example usage:

run_tool "jadx -d output target.apk"
run_tool "jadx -d output target.apk"   # second identical attempt

run_tool "jadx -d output target.apk"   # third attempt triggers switch

```

The `switch_strategy` function encodes the **tool‑substitution logic** recommended in [`RULES.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/RULES.md), with automatic escalation to human oversight when no fallback exists.

---

## Key Source Files

| File | Purpose |
|------|---------|
| [`RULES.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/RULES.md) | Central authority for self‑review, tool‑call budgeting, and behavior‑chain logic |
| `skills/scripts/master-route.ps1` / [`master-route.sh`](https://github.com/zhaoxuya520/reverse-skill/blob/main/master-route.sh) | Entry points that invoke downstream self‑review logic |
| [`skills/field-journal/_index.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/field-journal/_index.md) | Persistent storage for self‑review decisions and reusable experience |

---

## Summary

The reverse‑skill self‑review protocol for repeated failures follows these strict rules:

- **Count identical tool calls** and halt at 2‑3 consecutive failures
- **Assess progress** by answering the two diagnostic questions with concrete evidence
- **Switch approach** through static→dynamic migration, tool substitution, or parameter changes
- **Log decisions** to [`skills/field-journal/_index.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/field-journal/_index.md) for experience reuse
- **Escalate to user** if >30 calls are needed for any sub‑task
- **Complete self‑audit** before resuming the behavior chain

---

## Frequently Asked Questions

### Does the protocol distinguish between different error types?

No. The [`RULES.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/RULES.md) protocol triggers on **any non‑zero exit code** or failure condition, regardless of whether the error is transient (network timeout) or permanent (missing file). The agent must still switch approaches after 2‑3 identical failures, though the choice of alternative may be informed by the specific error message captured during self‑assessment.

### Can I configure the failure threshold above 3 attempts?

The repository enforces **2‑3 as the maximum** in [`RULES.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/RULES.md). Lower thresholds are permitted for high‑cost operations, but exceeding 3 identical retries violates the Self‑Supervision policy and risks budget overrun. The >30 call cap provides a secondary safeguard.

### What happens if no alternative tool exists?

The `switch_strategy` logic in the reference implementation includes a default case that reports to the user: *"No known fallback – reporting to user."* This aligns with the [`RULES.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/RULES.md) escalation requirement, pausing automation until human guidance provides a viable path forward.

### Is the field journal required or optional?

**Required**. The **Experience Reuse** section of [`RULES.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/RULES.md) mandates that all self‑review decisions, successful alternatives, and failure contexts be recorded in [`skills/field-journal/_index.md`](https://github.com/zhaoxuya520/reverse-skill/blob/main/skills/field-journal/_index.md). This prevents repeated failures across sessions and enables pattern recognition for future automation.