Enhance queue processing and recovery mechanisms

- Implement auto-recovery of orphaned queues on startup in WorkerService.
- Introduce startSessionWithAutoRestart method for continuous processing of pending work.
- Modify SDKAgent to prevent session deletion during processing to avoid race conditions.
- Update SessionManager to allow continued processing after yielding summaries.
- Add logic in SessionRoutes to mark processing messages as failed upon generator errors.
- Create detailed documentation for the queue system logic, including recovery mechanisms and potential issues.
This commit is contained in:
Alex Newman
2025-12-28 15:44:54 -05:00
parent 2d92e8a63f
commit 4ecdc4c9b3
6 changed files with 927 additions and 88 deletions
+1 -5
View File
@@ -472,11 +472,7 @@ export class SessionManager {
// Remove from in-memory queue after yielding
session.pendingMessages.shift();
// If we just yielded a summary, that's the end of this batch - stop the iterator
if (message.type === 'summarize') {
logger.info('SESSION', `Summary yielded - ending generator`, { sessionId: sessionDbId });
return;
}
// Continue processing - don't stop after summary, let the queue drain completely
}
}