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
+2 -2
View File
@@ -164,8 +164,8 @@ export class SDKAgent {
}
throw error;
} finally {
// Cleanup
this.sessionManager.deleteSession(session.sessionDbId).catch(() => {});
// NOTE: Do NOT delete session here - SessionRoutes.finally() handles cleanup
// and auto-restart logic. Deleting here races with pending work checks.
}
}