NoRaincheck

Ralph Loop and Frequent Intentional Context Compaction

Ralph Loop and Frequent Intentional Context Compaction

February 2026

There’s been a few things I’ve been playing around and thinking about, specifically around how one might ‘implement’ the ideas.

To that end, I have a single Python script example.

This aims to address a few items:

In general this loop works well, particularly for more complex tasks. The Ralph loop guarentees that it will at least see the task to completion.

Other Practical Thoughts

Explicitly Reviewing Outputs

By explicitly outputting the artifacts so that it can be reviewed post-hoc was invaluable. Seeing the ‘research’ plan (i.e. looks through the project files to understand where things are at) before ‘planning’ (i.e. coming up with a task list to build), meant that sources of issues could be discovered and rectified at the appropriate step. Linking these artifacts to a particular ticket was also helpful in matching tickets created (the initial goal) with the context and plan that was created before implementation.

Enabling a Fast Mode

Sometimes tasks are not complicated. In that scenario, a ‘research’ and ‘implement’ flow was sufficient as there was minimal value created from the additional planning. This shortcut made things a lot quicker with minimal impact to the final outcome.

Next Steps and Extensions

The trial for this was rather limited, using only opencode and ignoring ‘SKILLS’. It also had the makings of a simplified ‘Gas Town’ setup where there was one primary agent starting with the initial ticket and optional agents downstream. By explicitly encoding the steps (the steps are in code not from the LLM), meant that there were implicitly sub-agent pattern which came from it.

flowchart LR
    Start([Start]) --> CreateTicket[Create Ticket]
    CreateTicket --> AutoClassify{Auto-Classify Task}
    
    AutoClassify -->|Simple| FastMode[Fast Mode]
    AutoClassify -->|Medium/Complex| FullMode[Full Mode]
    
    FastMode --> ImplFast[Direct Implementation]
    ImplFast --> CheckFast{Output contains<br/>COMPLETE?}
    CheckFast -->|Yes| CloseTicketFast[Close Ticket]
    CheckFast -->|No| ImplFast
    CloseTicketFast --> GenerateSummaryFast[Generate Summary]
    
    FullMode --> Research[Research Phase]
    Research --> SaveResearch[Save to<br/>.tickets/artifacts/<br/>TICKET/research.md]
    SaveResearch --> CheckResearch{Output contains<br/>READY_FOR_NEXT_TASK?}
    CheckResearch -->|No| Research
    CheckResearch -->|Yes| Planning[Planning Phase]
    
    Planning --> SavePlan[Save to<br/>.tickets/artifacts/<br/>TICKET/plan.md]
    SavePlan --> CheckPlan{Output contains<br/>READY_FOR_NEXT_TASK?}
    CheckPlan -->|No| Planning
    CheckPlan -->|Yes| Implementation[Implementation Phase]
    
    Implementation --> CheckImpl{Output contains<br/>COMPLETE?}
    CheckImpl -->|No| Implementation
    CheckImpl -->|Yes| CloseTicket[Close Ticket]
    CloseTicket --> GenerateSummary[Generate Summary]
    
    GenerateSummaryFast --> End([End])
    GenerateSummary --> End

<< Previous Post

|

Next Post >>

🎲 Random post

|

All posts

#LLM #Python