From 121ab17254347f8b64a35fec386fc9f6b374796c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 8 Apr 2026 23:34:37 +0000 Subject: [PATCH 1/3] Initial plan From 9cd0b478106cbc52e7001fccec4b639461fc03ef Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 8 Apr 2026 23:43:10 +0000 Subject: [PATCH 2/3] =?UTF-8?q?Implement=20exponential=20backoff=20for=20L?= =?UTF-8?q?LM=20log=20polling=20(setTimeout-based,=2015s=E2=86=9230s?= =?UTF-8?q?=E2=86=9260s=E2=86=922min=E2=86=925min=E2=86=9210min)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Agent-Logs-Url: https://github.com/CyberSecDef/NovelForge/sessions/fac5c436-d508-4afd-90e7-34f7c1b2efc5 Co-authored-by: CyberSecDef <17597068+CyberSecDef@users.noreply.github.com> --- static/js/script.js | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/static/js/script.js b/static/js/script.js index b30b648..b4e4f4a 100644 --- a/static/js/script.js +++ b/static/js/script.js @@ -1517,7 +1517,18 @@ $(function () { // LLM Log Display // ------------------------------------------------------------------- var _seenLogSignatures = {}; - var _logPollInterval = null; + var _logPollTimeout = null; + var _logPollSameCount = 0; // consecutive polls with no new entries + // Backoff schedule: 0-1 same polls → 15s, 2 → 30s, 3 → 60s, 4 → 2min, 5 → 5min, 6+ → 10min + var _LOG_POLL_DELAYS = [15000, 15000, 30000, 60000, 120000, 300000, 600000]; + + function _scheduleLogPoll() { + if (_logPollTimeout) { + clearTimeout(_logPollTimeout); + } + var delay = _LOG_POLL_DELAYS[Math.min(_logPollSameCount, _LOG_POLL_DELAYS.length - 1)]; + _logPollTimeout = setTimeout(pollLLMLog, delay); + } function entrySignature(entry) { if (!entry) return ""; @@ -1609,16 +1620,22 @@ $(function () { _hasInitializedLogSnapshot = true; _activeLLMRequests = 0; setStickyStatus(DEFAULT_STICKY_STATUS, { force: true }); + _scheduleLogPoll(); return; } - if (entries.length === 0) return; + if (entries.length === 0) { + _logPollSameCount++; + _scheduleLogPoll(); + return; + } // Clear placeholder on first visible log entry if (Object.keys(_seenLogSignatures).length === 0) { $("#llm-chat-messages").empty(); } + var foundNew = false; for (var i = 0; i < entries.length; i++) { var entry = entries[i]; var signature = entrySignature(entry); @@ -1626,6 +1643,7 @@ $(function () { continue; } + foundNew = true; _seenLogSignatures[signature] = true; if (entry.type === "request") { @@ -1646,16 +1664,24 @@ $(function () { addLogMessage(formatted); } } + + if (foundNew) { + _logPollSameCount = 0; + } else { + _logPollSameCount++; + } + _scheduleLogPoll(); }, error: function() { // Silently fail - log polling is non-critical + _logPollSameCount++; + _scheduleLogPoll(); } }); } - // Start polling for LLM log updates - _logPollInterval = setInterval(pollLLMLog, 15000); // Poll every 15 seconds - pollLLMLog(); // Initial poll + // Start polling for LLM log updates (with adaptive backoff) + pollLLMLog(); // Initial poll; subsequent polls are scheduled inside pollLLMLog // Clear log button — clears display and server-side log file $("#btn-clear-log").on("click", function() { @@ -1667,6 +1693,7 @@ $(function () { _seenLogSignatures = {}; _activeLLMRequests = 0; _hasInitializedLogSnapshot = false; + _logPollSameCount = 0; setStickyStatus(DEFAULT_STICKY_STATUS, { force: true }); // Clear the server-side log file From f5ce62a31a0e0175750acd1b64ef1e872245b567 Mon Sep 17 00:00:00 2001 From: Robert Weber Date: Wed, 8 Apr 2026 20:05:55 -0400 Subject: [PATCH 3/3] Update static/js/script.js Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- static/js/script.js | 1 + 1 file changed, 1 insertion(+) diff --git a/static/js/script.js b/static/js/script.js index b4e4f4a..2272ffd 100644 --- a/static/js/script.js +++ b/static/js/script.js @@ -1694,6 +1694,7 @@ $(function () { _activeLLMRequests = 0; _hasInitializedLogSnapshot = false; _logPollSameCount = 0; + _scheduleLogPoll(); setStickyStatus(DEFAULT_STICKY_STATUS, { force: true }); // Clear the server-side log file