Skip to content

Commit 2a20bd0

Browse files
committed
Modified tests to check for toolCallRejected params.
The tests now check to see whether the parameters to toolCallRejected are populated as much as possible.
1 parent 3f605e1 commit 2a20bd0

File tree

1 file changed

+31
-7
lines changed

1 file changed

+31
-7
lines changed

test/eca/features/chat_tool_call_state_test.clj

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,14 @@
601601
"Expected system message to contain 'stopped' text")
602602

603603
(is (< 0 (count tool-reject-messages))
604-
"Expected at least one toolCallRejected notification to be sent for active tool calls")))))
604+
"Expected at least one toolCallRejected notification to be sent for active tool calls")
605+
606+
(is (every? (comp :id :content) tool-reject-messages)
607+
"Expected every toolCallRejected message to have an :id")
608+
(is (every? (comp :name :content) tool-reject-messages)
609+
"Expected every toolCallRejected message to have a :name")
610+
(is (every? (comp :origin :content) tool-reject-messages)
611+
"Expected every toolCallRejected message to have an :origin")))))
605612

606613
(deftest test-stop-prompt-message-count
607614
;; Test that stop-prompt sends appropriate number of messages
@@ -630,21 +637,38 @@
630637
(h/reset-components!)
631638
(let [db* (h/db*)
632639
chat-id "test-chat"
633-
chat-ctx {:chat-id chat-id :request-id "req-123" :messenger (h/messenger)}]
640+
tool-call-id "tool-call-1"
641+
chat-ctx {:chat-id chat-id :request-id "req-123" :messenger (h/messenger)}
642+
approved?* (promise)]
634643

635644
(swap! db* assoc-in [:chats chat-id]
636645
{:status :running
637646
:current-request-id "req-123"})
638647

639-
(#'f.chat/transition-tool-call! db* chat-ctx "tool-1" :tool-prepare
648+
(#'f.chat/transition-tool-call! db* chat-ctx tool-call-id :tool-prepare
640649
{:name "list_files" :origin "filesystem" :arguments-text "{}"})
641-
650+
(#'f.chat/transition-tool-call! db* chat-ctx tool-call-id :tool-run
651+
{:approved?* approved?*
652+
:name "list_files"
653+
:origin "filesystem"
654+
:arguments {"id" 123 "value" 42}})
642655
(f.chat/prompt-stop {:chat-id chat-id} db* (h/messenger))
656+
(when-not @approved?*
657+
(#'f.chat/transition-tool-call! db* chat-ctx tool-call-id :send-reject
658+
{:approved?* approved?*
659+
:name "list_files"
660+
:origin "filesystem"
661+
:arguments {"id" 123 "value" 42}}))
643662

644663
(let [chat-messages (:chat-content-received (h/messages))
645-
message-types (map #(get-in % [:content :type]) chat-messages)]
646-
(is (some #{:toolCallRejected} message-types)
647-
"Expected toolCallRejected notifications when stopping with active tool calls")))))
664+
tool-call-rejected-messages (filter #(= :toolCallRejected (get-in % [:content :type]))
665+
chat-messages)]
666+
667+
(is (< 0 (count tool-call-rejected-messages))
668+
"Expected toolCallRejected notifications when stopping with active tool calls")
669+
670+
(is (some #(get-in % [:content :arguments] %) tool-call-rejected-messages)
671+
"Expected at least one toolCallRejected message to include non-nil :arguments")))))
648672

649673
(deftest test-stop-prompt-with-non-running-chat
650674
;; Test stop-prompt behavior when chat is not running.

0 commit comments

Comments
 (0)