How Review Loop Sessions Are Managed with Separate Reviewer and Fixer Sessions
The no-mistakes pipeline enforces strict isolation between reviewer and fixer agents by maintaining a persistent reviewer session for the entire run while creating fresh, disposable fixer sessions for each individual fix turn.
The kunchenguid/no-mistakes repository implements a robust adversarial review model that relies on clean review loop session management. By isolating the reviewer and fixer into distinct session objects, the system ensures that automated fixes remain independent from review findings, preventing contamination of the decision-making process.
Understanding the Dual-Session Architecture
The pipeline creates two fundamentally different session types in internal/pipeline/sessions.go to enforce role separation.
The Persistent Reviewer Session
The reviewer session drives the initial review phase and maintains state throughout the entire run. According to the source code, this session is instantiated once at the beginning of the pipeline execution:
func NewReviewerSession(runID string) *Session {
return &Session{
RunID: runID,
Role: SessionRoleReviewer,
Created: time.Now(),
}
}
This session persists across all potential fix rounds, collecting cumulative findings and maintaining the review history that determines when the pipeline can proceed to deployment steps.
The Ephemeral Fixer Session
Conversely, the fixer session is designed for single-use disposal. The NewFixerSession factory function creates a cold-started session for each specific fix turn:
func NewFixerSession(runID string) *Session {
return &Session{
RunID: runID,
Role: SessionRoleFixer,
Created: time.Now(),
}
}
Once the fixer agent completes its task, the session is discarded, ensuring no cached prompts or previous findings carry over to subsequent iterations.
Session Lifecycle and Orchestration
The executor orchestrates these sessions to maintain strict boundaries. The implementation follows a pattern where the reviewer session survives while fixer sessions are transient:
func (e *Executor) runReviewPhase(runID string) error {
// Create a persistent reviewer session for the whole run
revSess := sessions.NewReviewerSession(runID)
// Run the reviewer agent
revFindings, err := revSess.InvokeReviewerAgent(...)
if err != nil { return err }
// If fixes are needed, start a fresh fixer session for each turn
for i := range revFindings.NeedingFix {
fixSess := sessions.NewFixerSession(runID)
fixResult, err := fixSess.InvokeFixerAgent(...)
if err != nil { return err }
// Apply fixes, then continue the review loop …
}
return nil
}
This loop structure ensures that within internal/pipeline/steps/review.go, each invocation of the fixer agent operates on a clean slate:
func (s *Step) Run(ctx context.Context) error {
revSess := sessions.NewReviewerSession(s.run.ID())
findings, err := revSess.InvokeAgent(ctx, "reviewer")
if err != nil { return err }
for _, f := range findings.NeedingFix {
fixSess := sessions.NewFixerSession(s.run.ID())
_, err := fixSess.InvokeAgent(ctx, "fixer")
if err != nil { return err }
}
return nil
}
Key Design Invariants
The session management system enforces several critical invariants to maintain the adversarial model:
- Role isolation – The reviewer never reuses a fixer session, and the fixer never accesses the reviewer's findings. This prevents the fixer from being influenced by prior review decisions.
- Cold start guarantee – Each fixer session is freshly instantiated with no inherited state, clearing any cached prompts or intermediate artifacts from previous turns.
- Durable metadata only – Sessions store minimal metadata (run ID, role, timestamps) in the database without sharing intermediate artifacts between roles.
- Configurable session reuse – While the default behavior enforces the reviewer/fixer split, the
session_reuseflag in the repository configuration can force cold starts for either role when needed.
Testing Session Isolation
The implementation includes comprehensive test coverage to verify these boundaries. The file internal/pipeline/steps/review_session_test.go validates that reviewer sessions persist while fixer sessions are recreated on each fix turn, confirming the two session types never overlap inappropriately.
Additionally, internal/pipeline/executor_review_approval_test.go provides integration-level verification of the end-to-end review loop behavior, ensuring session isolation holds throughout complex multi-turn scenarios.
Summary
- The no-mistakes pipeline creates a single reviewer session that persists for the entire run, maintaining cumulative review history across all fix rounds.
- Fixer sessions are cold-started individually for each fix turn and immediately discarded, preventing state contamination between iterations.
- This architecture enforces strict role isolation between agents, ensuring the fixer cannot access or be influenced by reviewer findings.
- The session factory functions in
internal/pipeline/sessions.goinstantiate role-specific sessions with distinct lifecycles to support this adversarial review model.
Frequently Asked Questions
How does the no-mistakes pipeline prevent fixer sessions from accessing reviewer findings?
The pipeline enforces role isolation by never sharing session state between the reviewer and fixer agents. The fixer session is instantiated fresh for each fix turn in internal/pipeline/steps/review.go without access to the reviewer session's internal state or findings history. This ensures the fixer operates only on the specific change request provided, maintaining the adversarial integrity of the review process.
What happens to fixer session data after a fix turn completes?
Fixer sessions are ephemeral by design. Once the fixer agent completes its task and the session object goes out of scope, it is discarded entirely. No cached prompts, conversation history, or intermediate artifacts persist to the next fix turn, ensuring each iteration starts with a clean slate as implemented in the NewFixerSession factory function.
Can the session behavior be configured to reuse fixer sessions across multiple turns?
Yes, though the default behavior enforces cold starts. The repository configuration includes a session_reuse flag that can modify session lifecycle behavior. However, the standard implementation in internal/pipeline/sessions.go maintains strict separation between reviewer and fixer roles regardless of this setting, ensuring the adversarial model remains intact even when reuse is enabled for other purposes.
Where is the session isolation logic tested in the codebase?
Session isolation is validated in internal/pipeline/steps/review_session_test.go, which specifically tests that reviewer sessions survive across fix rounds while fixer sessions are recreated for each turn. Integration testing in internal/pipeline/executor_review_approval_test.go confirms these boundaries hold during complete end-to-end pipeline executions involving multiple review and fix iterations.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →