From: Marcel Menzel Date: Thu, 16 Jul 2026 10:55:55 +0000 (+0000) Subject: Fix synchronous context_augment firing two GPT requests for one model X-Git-Tag: 4.1.2~1^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F6142%2Fhead;p=thirdparty%2Frspamd.git Fix synchronous context_augment firing two GPT requests for one model When your context_augment function calls the callback synchronously (e.g., return function(task, content, cb) cb('some context') end), the pending_fetches counter drops to 0 inside the callback, triggering maybe_proceed() which calls proceed(). Then control returns to the main flow where the now-redundant guard also sees pending_fetches == 0 and calls proceed(nil) a second time — this time without the context snippet. The else branch (line 1324) already handles the case where none of the context features are enabled, so the removed fallback was purely a duplicate path for synchronous callbacks. --- diff --git a/src/plugins/lua/gpt.lua b/src/plugins/lua/gpt.lua index 0bc6488ad0..1b4b21d06b 100644 --- a/src/plugins/lua/gpt.lua +++ b/src/plugins/lua/gpt.lua @@ -1316,11 +1316,6 @@ local function gpt_check(task) maybe_proceed() end end - - -- If no fetches were initiated, proceed immediately - if pending_fetches == 0 then - proceed(nil) - end else proceed(nil) end