|
| 1 | +--- |
| 2 | +title: Why the RPI Workflow Works |
| 3 | +description: The psychology, research, and principles behind the Research-Plan-Implement framework, plus guidance on when to use RPI vs rpi-agent |
| 4 | +author: Microsoft |
| 5 | +ms.date: 2026-01-05 |
| 6 | +ms.topic: concept |
| 7 | +keywords: |
| 8 | + - rpi workflow |
| 9 | + - ai constraints |
| 10 | + - research first |
| 11 | + - hallucination prevention |
| 12 | + - ai coding |
| 13 | +estimated_reading_time: 8 |
| 14 | +--- |
| 15 | + |
| 16 | +AI coding assistants are brilliant at simple tasks. Ask for a function that reverses a string, and you'll get working code in seconds. Ask for a feature that touches twelve files across three services, and you'll get something that looks right, compiles cleanly, and breaks everything it touches. |
| 17 | + |
| 18 | +If you've spent hours debugging AI-generated code that ignored your project's conventions, used variable names that don't match anything in your codebase, or confidently called APIs that don't exist, you're not alone. The problem isn't that AI is incapable. The problem is that we're asking it to do too many things at once. |
| 19 | + |
| 20 | +## The Real Problem |
| 21 | + |
| 22 | +Here's what took us a while to figure out: AI is doing exactly what it's designed to do. When you ask it to "build a feature," it generates plausible output quickly. The issue is that "plausible" and "correct" aren't the same thing. |
| 23 | + |
| 24 | +> [!WARNING] |
| 25 | +> **The failure mode you'll recognize** |
| 26 | +> |
| 27 | +> You: "Build me a Terraform module for Azure IoT" |
| 28 | +> |
| 29 | +> AI: *immediately generates 2000 lines of code* |
| 30 | +> |
| 31 | +> Reality: Missing dependencies, wrong variable names, outdated patterns, breaks existing infrastructure |
| 32 | +
|
| 33 | +Why does this happen? Because AI can't tell the difference between investigating and implementing. When you ask for code, it writes code. It doesn't stop to verify that the variable naming convention it chose matches your existing modules. It doesn't check whether the resource it's creating already exists. It doesn't ask itself whether the API it's calling is current or deprecated. |
| 34 | + |
| 35 | +AI writes first and thinks never. Not because it's broken, but because that's the only mode it has when you give it unrestricted access to both research and implementation. |
| 36 | + |
| 37 | +## The Counterintuitive Insight |
| 38 | + |
| 39 | +The solution isn't teaching AI to be smarter. It's preventing AI from doing certain things at certain times. |
| 40 | + |
| 41 | +RPI (Research → Plan → Implement) works by separating AI work into three distinct phases, each handled by a specialized mode: |
| 42 | + |
| 43 | +* [Task Researcher](task-researcher.md): investigates your codebase and external sources, producing verified findings with citations |
| 44 | +* [Task Planner](task-planner.md): transforms research into actionable implementation plans with clear success criteria |
| 45 | +* [Task Implementor](task-implementor.md): executes plans methodically, following established patterns discovered during research |
| 46 | + |
| 47 | +The magic happens because each phase starts fresh. When you clear context between phases, the implementation session doesn't carry forward the assumptions from research. It only has the documented artifacts: verified findings, explicit decisions, and cited evidence. |
| 48 | + |
| 49 | +### The Difference in Practice |
| 50 | + |
| 51 | +**Without RPI**, AI thinks: "This looks like a reasonable variable name. I'll use `prefix`." |
| 52 | + |
| 53 | +**With RPI**, Task Researcher finds: "12 existing modules in this repository use `resource_prefix`, not `prefix`. See [variables.tf#L47](../infrastructure/modules/base/variables.tf#L47) for the established pattern." |
| 54 | + |
| 55 | +When AI knows it cannot implement during research, it stops optimizing for "plausible code" and starts optimizing for "verified truth." The constraint changes the goal. |
| 56 | + |
| 57 | +## What Happens in Each Phase |
| 58 | + |
| 59 | +Understanding what AI does differently in each phase helps explain why separation works. |
| 60 | + |
| 61 | +### Research Phase: Investigating, Not Guessing |
| 62 | + |
| 63 | +Task Researcher knows it will never write the code. This single constraint transforms its behavior: |
| 64 | + |
| 65 | +* Searches for existing patterns instead of inventing new ones. |
| 66 | +* Cites specific files and line numbers as evidence. |
| 67 | +* Questions its own assumptions because it can't hide them in implementation. |
| 68 | +* Documents dependencies, APIs, and conventions with precision. |
| 69 | + |
| 70 | +The output is a research document that anyone can verify. No tribal knowledge. No "I think this is how it works." |
| 71 | + |
| 72 | +### Planning Phase: Sequencing, Not Improvising |
| 73 | + |
| 74 | +Task Planner receives verified research and transforms it into actionable steps. Because it can't implement, it focuses entirely on: |
| 75 | + |
| 76 | +* Breaking work into logical, sequenced tasks. |
| 77 | +* Identifying dependencies between changes. |
| 78 | +* Defining clear success criteria for each step. |
| 79 | +* Anticipating edge cases before code is written. |
| 80 | + |
| 81 | +The plan becomes a contract. When implementation begins, the AI follows the plan rather than making decisions on the fly. |
| 82 | + |
| 83 | +### Implementation Phase: Following, Not Inventing |
| 84 | + |
| 85 | +Task Implementor has one job: execute the plan using the patterns documented in research. This is where the payoff becomes obvious: |
| 86 | + |
| 87 | +* No time wasted rediscovering conventions. |
| 88 | +* No "creative" decisions that break existing patterns. |
| 89 | +* No assumptions about how things work, only verified facts. |
| 90 | +* Clear accountability when something goes wrong. |
| 91 | + |
| 92 | +## The Quality Difference |
| 93 | + |
| 94 | +RPI produces measurably different outcomes than traditional AI coding: |
| 95 | + |
| 96 | +| Aspect | Traditional Approach | RPI Approach | |
| 97 | +|------------------------|----------------------------------------------------|----------------------------------------------| |
| 98 | +| **Pattern matching** | Invents plausible patterns | Uses verified existing patterns | |
| 99 | +| **Traceability** | "The AI wrote it this way" | "Research document cites lines 47-52" | |
| 100 | +| **Knowledge transfer** | Tribal knowledge in your head | Research documents anyone can follow | |
| 101 | +| **Rework** | Frequent, after discovering assumptions were wrong | Rare, because assumptions are verified first | |
| 102 | + |
| 103 | +### The Paradigm Shift |
| 104 | + |
| 105 | +Stop asking AI: "Write this code." |
| 106 | + |
| 107 | +Start asking: "Help me research, plan, then implement with evidence." |
| 108 | + |
| 109 | +RPI treats AI as a research partner first, code generator second. The code comes last, after the hard work of understanding is complete. |
| 110 | + |
| 111 | +## The Learning Curve |
| 112 | + |
| 113 | +Let's be honest: your first RPI workflow will feel slower. You're learning a new process, building muscle memory for context clearing, and adjusting to the handoff between phases. |
| 114 | + |
| 115 | +By your third feature, the workflow feels natural. The research phase becomes faster because you know what questions to ask. The planning phase tightens because you recognize what level of detail works for your codebase. Implementation becomes almost mechanical. |
| 116 | + |
| 117 | +The value compounds over time. Research documents accumulate into institutional memory. New team members can read how past decisions were made. Patterns get documented once and referenced forever. |
| 118 | + |
| 119 | +## Choosing Your Workflow: RPI vs rpi-agent |
| 120 | + |
| 121 | +HVE Core provides two workflow options. The right choice depends on the task, not personal preference. |
| 122 | + |
| 123 | +### Strict RPI: When Quality Matters Most |
| 124 | + |
| 125 | +Use the three-phase workflow ([Task Researcher](task-researcher.md) → [Task Planner](task-planner.md) → [Task Implementor](task-implementor.md)) when: |
| 126 | + |
| 127 | +* 🔍 **Deep research needed**: new frameworks, external APIs, compliance requirements |
| 128 | +* 📁 **Multi-file changes**: pattern discovery across the codebase |
| 129 | +* 👥 **Team handoff**: artifacts document decisions for others |
| 130 | +* 🔧 **Long-term maintenance**: work you'll maintain and evolve over time |
| 131 | + |
| 132 | +**The workflow:** |
| 133 | + |
| 134 | +1. Invoke Task Researcher → produces research document with citations |
| 135 | +2. Clear context, invoke Task Planner → produces implementation plan |
| 136 | +3. Clear context, invoke Task Implementor → implements following the plan |
| 137 | + |
| 138 | +### rpi-agent: When Simplicity Fits |
| 139 | + |
| 140 | +Use the [autonomous agent](../../.github/chatmodes/rpi-agent.chatmode.md) when: |
| 141 | + |
| 142 | +* ✅ **Clear scope**: straightforward feature or bug fix |
| 143 | +* ✅ **Minimal research**: codebase-only investigation |
| 144 | +* ✅ **Quick iteration**: active development with fast feedback loops |
| 145 | + |
| 146 | +**The workflow:** Single rpi-agent session that handles research and implementation together. |
| 147 | + |
| 148 | +### Matching Tool to Task |
| 149 | + |
| 150 | +| Factor | Strict RPI | rpi-agent | |
| 151 | +|-----------------------|--------------------------------|-----------------------------| |
| 152 | +| Research depth | Deep, verified, cited | Moderate, inline | |
| 153 | +| Context contamination | Eliminated via `/clear` | Possible | |
| 154 | +| Audit trail | Complete artifacts | Summary only | |
| 155 | +| Best for | Complex, unfamiliar, team work | Simple, familiar, solo work | |
| 156 | + |
| 157 | +### Escalation Path |
| 158 | + |
| 159 | +rpi-agent can hand off to Task Researcher when it encounters complexity beyond its scope. This hybrid approach gives you speed for simple tasks and depth when needed. You don't have to decide upfront; start with rpi-agent and escalate if the task reveals hidden complexity. |
| 160 | + |
| 161 | +## Next Steps |
| 162 | + |
| 163 | +Ready to try it yourself? |
| 164 | + |
| 165 | +* [Your First RPI Workflow](../getting-started/first-workflow.md): 15-minute hands-on tutorial |
| 166 | +* [Using the Modes Together](using-together.md): context management and handoffs |
| 167 | +* [RPI Overview](README.md): the three modes explained |
| 168 | + |
| 169 | +--- |
| 170 | + |
| 171 | +🤖 *Crafted with precision by ✨Copilot using the RPI workflow* |
0 commit comments