Research, plan, implement (RPI)
Working with a coding agent in three phases, each in a fresh context: research the code into a document, write a plan from it, then implement the plan.
HumanLayer described the approach in Advanced context engineering for coding agents. Research produces a short document on how the relevant code works, often using subagents to read widely without filling the main context. Planning turns it into exact steps, files and checks. Implementation follows the plan phase by phase. Between phases the context is cleared and only the document carries over, which the authors call frequent intentional compaction.
It fights context rot: a long session full of file reads and failed attempts makes the agent worse. It also moves human review to where it is cheapest: an error in the research becomes many wrong lines of code, so people review the research and the plan, not every line. A PRP is in effect the output of the first two phases.
Sources
Related terms
- Plan mode: A coding agent mode in which it can read code and run safe commands but not edit files, and ends with a plan for you to approve.
- Compaction: Replacing the older part of a long conversation with a summary so the agent can keep going.
- Context engineering: Deciding what goes into the model’s context, in what order and when, across a whole task.
- Subagent: A separate agent run with its own fresh context, started by a main agent for one subtask.
- PRP (Product Requirement Prompt): A PRD rewritten for a coding agent: the goal and why, plus the exact files, patterns to follow and commands that prove the work is done.
- Context rot: Model quality drops as the context fills with old, irrelevant or conflicting material.
