about summary refs log tree commit diff
diff options
context:
space:
mode:
authorArun Isaac2026-08-06 02:15:44 +0100
committerArun Isaac2026-08-06 02:16:18 +0100
commit241436306483045454cd08125a9baa4eff6329cd (patch)
tree260df02bbc4f999d62d76e6947147ee0f8ff5a64
parent54385b3100cbcf451be172f7faa13759f84d92e0 (diff)
downloadkaagum-241436306483045454cd08125a9baa4eff6329cd.tar.gz
kaagum-241436306483045454cd08125a9baa4eff6329cd.tar.lz
kaagum-241436306483045454cd08125a9baa4eff6329cd.zip
tea: End turn with refusal if LLM query fails.
-rw-r--r--kaagum/tea.scm10
1 files changed, 10 insertions, 0 deletions
diff --git a/kaagum/tea.scm b/kaagum/tea.scm
index d6108da..12d455c 100644
--- a/kaagum/tea.scm
+++ b/kaagum/tea.scm
@@ -36,6 +36,7 @@
   #:use-module (kaagum tools)
   #:use-module (kaagum trace)
   #:use-module (kaagum utils)
+  #:use-module (kaagum web)
   #:export (run-tea-loop))
 
 (define %tool-allow-once
@@ -950,6 +951,15 @@ in @code{tea-loop}."
                                          request-id
                                          state)))))
            (client-request-effects json-message models tools)))))
+   ;; End turn if message is an LLM response containing an HTTP error.
+   ((and (llm-response? message)
+         (http-error? (llm-response-json message)))
+    (end-turn-effects (llm-response-session-id message)
+                      models
+                      ;; TODO: The v2 version of the protocol allows custom stop
+                      ;; reasons. Perhaps we can use that here to be more
+                      ;; specific about the cause of the failure.
+                      "refusal"))
    ((llm-response? message)
     (llm-response-effects message tools models))
    ((tool-call-result? message)