feat(ralph-loop): add strategy option for fresh context per iteration
Closes #1901 Add 'default_strategy' config option (default: 'continue') to control whether ralph-loop creates a new session per iteration ('reset') or keeps the same session ('continue'). The 'reset' strategy keeps the model in the smart zone by starting with fresh context for each iteration. Supports --strategy flag for per-command override.
This commit is contained in:
@@ -24,6 +24,7 @@ export function createLoopStateController(options: {
|
||||
maxIterations?: number
|
||||
completionPromise?: string
|
||||
ultrawork?: boolean
|
||||
strategy?: "reset" | "continue"
|
||||
},
|
||||
): boolean {
|
||||
const state: RalphLoopState = {
|
||||
@@ -37,6 +38,7 @@ export function createLoopStateController(options: {
|
||||
loopOptions?.completionPromise ??
|
||||
DEFAULT_COMPLETION_PROMISE,
|
||||
ultrawork: loopOptions?.ultrawork,
|
||||
strategy: loopOptions?.strategy ?? config?.default_strategy ?? "continue",
|
||||
started_at: new Date().toISOString(),
|
||||
prompt,
|
||||
session_id: sessionID,
|
||||
@@ -77,5 +79,19 @@ export function createLoopStateController(options: {
|
||||
incrementIteration(): RalphLoopState | null {
|
||||
return incrementIteration(directory, stateDir)
|
||||
},
|
||||
|
||||
setSessionID(sessionID: string): RalphLoopState | null {
|
||||
const state = readState(directory, stateDir)
|
||||
if (!state) {
|
||||
return null
|
||||
}
|
||||
|
||||
state.session_id = sessionID
|
||||
if (!writeState(directory, state, stateDir)) {
|
||||
return null
|
||||
}
|
||||
|
||||
return state
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user