Fresh Context
One of Ralph’s core design principles is that each iteration spawns a completely fresh AI instance with clean context. This is not just an implementation detail—it’s a fundamental feature that makes Ralph reliable and scalable.What Does “Fresh Context” Mean?
Every time Ralph starts a new iteration, it:- Terminates the previous AI instance completely
- Spawns a new AI process (Amp or Claude Code)
- Starts with zero conversation history from the previous iteration
- Reads the prompt template from scratch (
prompt.mdorCLAUDE.md)
Think of it like rebooting a computer between tasks. Each iteration is a completely new session.
Why Fresh Context?
1. Avoids Context Window Exhaustion
AI models have limited context windows. In a long-running conversation:- The chat history grows with every message
- Code diffs and file contents accumulate
- Eventually, the model runs out of context
- Quality degrades or the session crashes
- Each iteration starts at 0 tokens
- The AI can use its full context window for the current task
- No risk of hitting limits mid-implementation
2. Prevents Context Pollution
In long conversations, the AI can:- Accumulate incorrect assumptions
- Remember abandoned approaches
- Get confused by contradictory instructions
- Develop “bad habits” from trial-and-error
- Each iteration starts with a clean mental model
- No baggage from previous failed attempts
- Consistent behavior across iterations
3. Enables Parallel Development
Because iterations are independent:- You could theoretically run multiple Ralph instances on different branches
- Each instance works on a different story
- No shared state to synchronize (except git)
4. Makes Debugging Easier
When something goes wrong:- You can examine exactly one iteration in isolation
- The input is always the same: prompt template + persistent files
- No hidden conversation history to untangle
- Easy to reproduce issues
What Persists Between Iterations?
If each iteration is fresh, how does Ralph remember what it’s done?Git History
Every completed story is committed to git. The next iteration sees:
- All code changes from previous stories
- Commit messages describing what was done
- The full git log
progress.txt
Each iteration appends to
progress.txt with:- What was implemented
- Files changed
- Learnings and patterns discovered
- Gotchas to avoid
These four persistence mechanisms (git, progress.txt, prd.json, AGENTS.md) are the only memory between iterations. Everything else is fresh.
How Fresh Context Changes Your Workflow
Story Size Matters
Each user story must be completable in a single context window: ✅ Good story sizes:- Add a database column and migration
- Add a UI component to an existing page
- Update a server action with new logic
- Add a filter dropdown to a list
- “Build the entire dashboard”
- “Add authentication”
- “Refactor the API”
Write Good Progress Reports
Because the next iteration can’t see your conversation history, your progress report inprogress.txt is critical:
Bad progress report:
Update AGENTS.md Files
Since AI tools automatically readAGENTS.md files, updating them is like giving permanent memory to all future iterations:
Debugging Fresh Context Issues
If an iteration seems to “forget” something:- Check progress.txt - Did the previous iteration document the learning?
- Check AGENTS.md - Is the pattern documented in the relevant directory?
- Check git log - Is the code change actually committed?
- Check prd.json - Is the story marked as
passes: true?
Benefits vs. Stateful Agents
Compared to a single long-running AI conversation:| Fresh Context (Ralph) | Stateful Conversation |
|---|---|
| ✅ Never runs out of context | ❌ Eventually hits context limits |
| ✅ Consistent behavior | ❌ Can develop bad habits |
| ✅ Easy to debug | ❌ Hidden conversation history |
| ✅ Can run in parallel | ❌ Sequential only |
| ❌ Requires good documentation | ✅ Remembers everything |
| ❌ Stories must be atomic | ✅ Can handle messy, exploratory work |
Summary
Fresh context is what allows Ralph to run indefinitely without degradation:- Each iteration is independent and self-contained
- Memory persists through git, progress.txt, prd.json, and AGENTS.md
- Stories must be small enough for one context window
- Good documentation is essential for continuity

