diff options
| author | Arun Isaac | 2026-04-12 03:51:54 +0100 |
|---|---|---|
| committer | Arun Isaac | 2026-04-12 03:51:54 +0100 |
| commit | f1224eed4ab9676fbfb50392cda7f14669586dcf (patch) | |
| tree | a94cfcbf6756fc1541ce7d987a72daa3958bac28 | |
| parent | f94644bcfaa76ac73ba7e7ff58890089fdbc7c0d (diff) | |
| download | kaagum-f1224eed4ab9676fbfb50392cda7f14669586dcf.tar.gz kaagum-f1224eed4ab9676fbfb50392cda7f14669586dcf.tar.lz kaagum-f1224eed4ab9676fbfb50392cda7f14669586dcf.zip | |
Strip message fields based on role.
| -rw-r--r-- | kaakaa/tea.scm | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/kaakaa/tea.scm b/kaakaa/tea.scm index 05881f3..3986340 100644 --- a/kaakaa/tea.scm +++ b/kaakaa/tea.scm @@ -141,14 +141,21 @@ in @var{state}." ;; progress; dispatch to LLM. (list (llm-request session-id (map (lambda (message) - ;; Strip out all fields (such as reasoning - ;; fields) other than role, content and - ;; tool_calls. - (filter (match-lambda - ((key . _) - (member key (list "role" "content" - "tool_calls")))) - message)) + ;; Strip unnecessary fields (such as reasoning + ;; fields) based on role. + (let* ((role (focus (key-ref "role") message)) + (allowed-fields + (cond + ((string=? role "user") + '("role" "content")) + ((string=? role "assistant") + '("role" "content" "tool_calls")) + ((string=? role "tool") + '("role" "content" "tool_call_id"))))) + (filter (match-lambda + ((key . _) + (member key allowed-fields))) + message))) ;; Reverse because we have been prepending new ;; messages onto the list. (reverse (focus (state-messages session-id) |
