fix(ralph-loop): guard delayed start snapshots

Prevent delayed loop-start message counts from overwriting active Ralph Loop state after the loop has already advanced, so ULW completion can still enter Oracle verification instead of iterating forever.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
YeonGyu-Kim
2026-05-13 18:59:07 +09:00
parent 1fa97c6efe
commit 61ba4e3b41
3 changed files with 64 additions and 2 deletions
+6 -1
View File
@@ -73,6 +73,11 @@ export function createRalphLoopHook(
return startSuccess
}
const startedState = loopState.getState()
const expectedStartedAt = startedState?.session_id === sessionID
? startedState.started_at
: undefined
ctx.client.session
.messages({
path: { id: sessionID },
@@ -80,7 +85,7 @@ export function createRalphLoopHook(
})
.then((messagesResponse: unknown) => {
const messageCountAtStart = getMessageCountFromResponse(messagesResponse)
loopState.setMessageCountAtStart(sessionID, messageCountAtStart)
loopState.setMessageCountAtStart(sessionID, messageCountAtStart, expectedStartedAt)
})
.catch(() => {})