MAESTRO: Merge PR #693 - prevent infinite restart loop that causes runaway API costs

Add restart limit (max 3 consecutive restarts) with exponential backoff
to prevent infinite generator restart loops. Also add defensive
memorySessionId checks in GeminiAgent and OpenRouterAgent before
expensive LLM calls to fail fast when session ID hasn't been captured.

Based on PR #693 by @ajbmachon (applied to current main).

Co-Authored-By: Andre Machon <ajbmachon2@gmail.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Alex Newman
2026-02-06 01:43:12 -05:00
parent 1ae6c5708c
commit 6382d6f9c7
6 changed files with 112 additions and 62 deletions
+2 -1
View File
@@ -153,7 +153,8 @@ export class SessionManager {
cumulativeOutputTokens: 0,
earliestPendingTimestamp: null,
conversationHistory: [], // Initialize empty - will be populated by agents
currentProvider: null // Will be set when generator starts
currentProvider: null, // Will be set when generator starts
consecutiveRestarts: 0 // Track consecutive restart attempts to prevent infinite loops
};
logger.debug('SESSION', 'Creating new session object (memorySessionId cleared to prevent stale resume)', {