Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion docs/architecture.org
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 8 additions & 7 deletions src/provider/client.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 5 additions & 3 deletions src/provider/openai-api.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/provider/wire-protocol.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion tests/openai-compatible-provider-tests.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
3 changes: 1 addition & 2 deletions tests/provider-tests.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
14 changes: 8 additions & 6 deletions tests/test-support.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))
Expand Down
Loading