]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Fix synchronous context_augment firing two GPT requests for one model 6142/head
authorMarcel Menzel <mail@mcl.gg>
Thu, 16 Jul 2026 10:55:55 +0000 (10:55 +0000)
committerMarcel Menzel <mail@mcl.gg>
Thu, 16 Jul 2026 10:58:04 +0000 (12:58 +0200)
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.

src/plugins/lua/gpt.lua

index 0bc6488ad0117e6f9d83ee91513d9d5fa384a608..1b4b21d06b48904df74a4c7057ee9c4cb6e81fbe 100644 (file)
@@ -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