From a7648d9820010e346d720e786865492f78e7c5bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hozda?= Date: Sun, 15 Nov 2026 23:39:59 +0100 Subject: [PATCH 1/2] Allow parallel calls in compaction requests like ordinary ones --- src/provider/client.lisp | 15 ++++++++------- src/provider/openai-api.lisp | 8 +++++--- src/provider/wire-protocol.lisp | 4 ++-- tests/openai-compatible-provider-tests.lisp | 1 - tests/provider-tests.lisp | 3 +-- tests/test-support.lisp | 14 ++++++++------ 6 files changed, 24 insertions(+), 21 deletions(-) diff --git a/src/provider/client.lisp b/src/provider/client.lisp index a6032968f..367c22321 100644 --- a/src/provider/client.lisp +++ b/src/provider/client.lisp @@ -468,15 +468,16 @@ root's key, as the Codex reference does at commit 6f51c65958." ;; for Fast mode, only when the current model advertises support. This follows ;; Codex reference commit 287587c32c9cbc1e78edbf2aaae6a6d84f5b0c56. -(-> provider--codex-responses-request-fields - (codex-subscription-provider conversation &key (:compaction-p boolean)) - list) -(defun provider--codex-responses-request-fields - (provider conversation &key compaction-p) - "Return Codex fields shared by the concrete and generic Responses views." +(-> provider--codex-responses-request-fields (codex-subscription-provider conversation) list) +(defun provider--codex-responses-request-fields (provider conversation) + "Return Codex fields shared by the concrete and generic Responses views. + +Every request allows parallel calls, a compaction request too: the service +renders that setting into the tool section, where the cached prompt begins. +With another value there, a live compaction request read nothing from the cache." (let ((configuration (provider-configuration provider))) (append - (list "parallel_tool_calls" (if compaction-p (json-false) t) + (list "parallel_tool_calls" t "include" (json-array "reasoning.encrypted_content") "prompt_cache_key" (provider--codex-prompt-cache-key provider conversation) diff --git a/src/provider/openai-api.lisp b/src/provider/openai-api.lisp index 765541c1f..1eae8c593 100644 --- a/src/provider/openai-api.lisp +++ b/src/provider/openai-api.lisp @@ -50,11 +50,13 @@ "Disable server-side response storage and allow parallel calls for public API requests. Parallel calls let one response carry independent calls, which the agent runs -in waves, instead of spending a model request on each. Compaction calls none. +in waves, instead of spending a model request on each. A compaction request +allows them too: the service renders the setting into the tool section, where +the cached prompt begins. CONVERSATION's prompt cache key routes its requests to the same cache." - (declare (ignore provider)) + (declare (ignore provider compaction-p)) (list "store" yason:false - "parallel_tool_calls" (if compaction-p yason:false t) + "parallel_tool_calls" t "prompt_cache_key" (conversation-prompt-cache-key conversation))) (defmethod provider-wire-tool-name diff --git a/src/provider/wire-protocol.lisp b/src/provider/wire-protocol.lisp index 677c2ec03..2512b8e39 100644 --- a/src/provider/wire-protocol.lisp +++ b/src/provider/wire-protocol.lisp @@ -632,8 +632,8 @@ NIL leaves the service default in place.")) (conversation conversation) &key compaction-p) "Return the fields sent by one Codex Responses request." - (provider--codex-responses-request-fields - provider conversation :compaction-p compaction-p)) + (declare (ignore compaction-p)) + (provider--codex-responses-request-fields provider conversation)) (defmethod provider-request-object ((provider responses-api-provider) (conversation conversation) diff --git a/tests/openai-compatible-provider-tests.lisp b/tests/openai-compatible-provider-tests.lisp index 3f9828464..8ebb3fa6c 100644 --- a/tests/openai-compatible-provider-tests.lisp +++ b/tests/openai-compatible-provider-tests.lisp @@ -1569,7 +1569,6 @@ "wire projection leaves canonical validation intact") (let ((compaction (test-compaction-request provider conversation))) (test-assert (and (eq yason:false (json-get compaction "store")) - (eq yason:false (json-get compaction "parallel_tool_calls")) (not (gethash "reasoning" compaction))) "compaction uses the public API policy")) (dolist (pair '(("search" "content") ("custom__ns" "some.name") diff --git a/tests/provider-tests.lisp b/tests/provider-tests.lisp index b39104762..0f4116ae2 100644 --- a/tests/provider-tests.lisp +++ b/tests/provider-tests.lisp @@ -1001,8 +1001,7 @@ (json-get compaction-request "tools") :key (lambda (tool) (json-get tool "name")) :test #'equal))) (test-assert - (and (json-false-p (gethash "parallel_tool_calls" compaction-request)) - (json-string= (json-get submit "type") "function") + (and (json-string= (json-get submit "type") "function") (eq t (json-get submit "strict")) (test-object-contains-string-p (aref input (1- (length input))) "Call compaction.submit once")) diff --git a/tests/test-support.lisp b/tests/test-support.lisp index b3d5b4c5e..c93a07277 100644 --- a/tests/test-support.lisp +++ b/tests/test-support.lisp @@ -60,8 +60,9 @@ "Return the request PROVIDER makes to compact CONVERSATION, checked against an ordinary one. FORCED-P checks whether the tool's wire name appears again in the forced -choice. The request repeats the ordinary instructions, tool declarations -and history, which lets the provider read them from its cache." +choice. The request repeats the ordinary instructions, tool declarations, +parallel call setting and history, which lets the provider read them from its +cache. A service renders the parallel call setting into the tool section." (let* ((tools (concatenate 'vector (json-array @@ -87,10 +88,11 @@ and history, which lets the provider read them from its cache." count t)) "a compaction request declares the submit tool and uses the expected tool choice") (test-assert (every (lambda (field) - (string= (json-encode (json-get (body ordinary) field)) - (json-encode (json-get (body compaction) field)))) - '("instructions" "system" "systemInstruction" "tools")) - "a compaction request repeats the ordinary instructions and tool declarations") + (string= (json-encode (gethash field (body ordinary))) + (json-encode (gethash field (body compaction))))) + '("instructions" "system" "systemInstruction" "tools" + "parallel_tool_calls")) + "a compaction request repeats the ordinary instructions, tool declarations and parallel call setting") (let ((shared (1- (length (test-request-history compaction))))) (test-assert (equal (subseq (test-request-history ordinary) 0 shared) (subseq (test-request-history compaction) 0 shared)) From 2c0452d9b410b1bff0776775d41622585e53edb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hozda?= Date: Sun, 15 Nov 2026 23:39:59 +0100 Subject: [PATCH 2/2] Document the request settings a compaction request keeps --- docs/architecture.org | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/architecture.org b/docs/architecture.org index 8fc88c2e3..693975c5c 100644 --- a/docs/architecture.org +++ b/docs/architecture.org @@ -283,7 +283,11 @@ The test fails for that version and every later version. request that offers tools declares =compaction.submit=, except in an inference frame, which never compacts. The compaction request repeats the same instructions, tools and history, puts its own instructions after the - history and forces that call. + history and forces that call. It also keeps the request settings a service + renders into that prefix: OpenAI writes =parallel_tool_calls= into the tool + section, and a compaction request that sent another value there read nothing + from the cache. The forced call and the reasoning summary do not change the + prefix. - =src/conversation/input-history.lisp= maintains complete editable input recall in the CACHE namespace above. Missing or invalid indexes rebuild from authoritative records, including retired segments. Each new input appends one