|
140 | 140 | (is (= 1 (count prepare-messages)) "Expected exactly one toolCallPrepare notification to be sent") |
141 | 141 |
|
142 | 142 | (is (match? {:chat-id chat-id |
143 | | - :request-id "req-1" |
144 | 143 | :role :assistant |
145 | 144 | :content (merge {:type :toolCallPrepare |
146 | 145 | :id tool-call-id} |
|
301 | 300 | ;; Step 4: :waiting-approval -> :execution-approved (user approves) |
302 | 301 | (let [result (#'f.chat/transition-tool-call! db* chat-ctx tool-call-id :user-approve)] |
303 | 302 | (is (match? {:status :execution-approved |
304 | | - :actions [:deliver-approval-true]} |
| 303 | + :actions [:set-decision-reason :deliver-approval-true]} |
305 | 304 | result) |
306 | 305 | "Expected transition to :execution-approved with deliver approval true action") |
307 | 306 |
|
|
341 | 340 | ;; Step 3: :check-approval -> :execution-approved (auto approval) |
342 | 341 | (let [result (#'f.chat/transition-tool-call! db* chat-ctx tool-call-id :config-allow)] |
343 | 342 | (is (match? {:status :execution-approved |
344 | | - :actions [:deliver-approval-true]} |
| 343 | + :actions [:set-decision-reason :deliver-approval-true]} |
345 | 344 | result) |
346 | 345 | "Expected transition to :execution-approved with deliver approval true action") |
347 | 346 |
|
|
369 | 368 |
|
370 | 369 | (let [result (#'f.chat/transition-tool-call! db* chat-ctx tool-call-id :user-reject)] |
371 | 370 | (is (match? {:status :rejected |
372 | | - :actions [:deliver-approval-false :log-rejection]} |
| 371 | + :actions [:set-decision-reason :deliver-approval-false :log-rejection]} |
373 | 372 | result) |
374 | 373 | "Expected transition to :rejected with deliver approval false and log rejection actions") |
375 | 374 |
|
|
430 | 429 | result (#'f.chat/transition-tool-call! db* chat-ctx tool-call-id :execution-end result-data)] |
431 | 430 |
|
432 | 431 | (is (match? {:status :completed |
433 | | - :actions [:send-toolCalled :record-metrics]} |
| 432 | + :actions [:send-toolCalled :log-metrics]} |
434 | 433 | result) |
435 | 434 | "Expected transition to :completed with send toolCalled and record metrics actions") |
436 | 435 |
|
|
445 | 444 | (is (= 1 (count completed-messages)) "Expected exactly one toolCalled notification to be sent") |
446 | 445 |
|
447 | 446 | (is (match? {:chat-id chat-id |
448 | | - :request-id "req-1" |
449 | 447 | :role :assistant |
450 | 448 | :content (merge {:type :toolCalled |
451 | 449 | :id tool-call-id} |
|
535 | 533 |
|
536 | 534 | (let [result (#'f.chat/transition-tool-call! db* chat-ctx "tool-1" :stop-requested)] |
537 | 535 | (is (match? {:status :stopped |
538 | | - :actions [:send-toolCallRejected]} |
| 536 | + :actions [:set-decision-reason :send-toolCallRejected]} |
539 | 537 | result) |
540 | 538 | "Expected transition to :stopped with send toolCallRejected action") |
541 | 539 | (is (= :stopped (:status (#'f.chat/get-tool-call-state @db* chat-id "tool-1"))) |
542 | 540 | "Expected tool call state to be in :stopped status"))) |
543 | 541 |
|
544 | | - (testing ":waiting-approval -> :stopped" |
| 542 | + (testing ":waiting-approval -> :rejected" |
545 | 543 | (let [approved?* (promise)] |
546 | 544 | (#'f.chat/transition-tool-call! db* chat-ctx "tool-2" :tool-prepare |
547 | 545 | {:name "test" :origin "test" :arguments-text "{}"}) |
|
551 | 549 | {:state :running :text "Waiting"}) |
552 | 550 |
|
553 | 551 | (let [result (#'f.chat/transition-tool-call! db* chat-ctx "tool-2" :stop-requested)] |
554 | | - (is (match? {:status :stopped |
555 | | - :actions [:deliver-approval-false]} |
| 552 | + (is (match? {:status :rejected |
| 553 | + :actions [:set-decision-reason :deliver-approval-false]} |
556 | 554 | result) |
557 | 555 | "Expected transition to :stopped with deliver approval false action") |
558 | 556 | (is (= :stopped (:status (#'f.chat/get-tool-call-state @db* chat-id "tool-2"))) |
|
731 | 729 |
|
732 | 730 | (let [result (#'f.chat/transition-tool-call! db* chat-ctx tool-call-id :config-allow)] |
733 | 731 | (is (match? {:status :execution-approved |
734 | | - :actions [:deliver-approval-true]} |
| 732 | + :actions [:set-decision-reason :deliver-approval-true]} |
735 | 733 | result) |
736 | 734 | "Expected transition to :execution-approved with deliver approval true action") |
737 | 735 |
|
|
815 | 813 | result (#'f.chat/transition-tool-call! db* chat-ctx tool-call-id :execution-end error-result)] |
816 | 814 |
|
817 | 815 | (is (match? {:status :completed |
818 | | - :actions [:send-toolCalled :record-metrics]} |
| 816 | + :actions [:send-toolCalled :log-metrics]} |
819 | 817 | result) |
820 | 818 | "Expected transition to :completed with send toolCalled and record metrics actions") |
821 | 819 |
|
|
0 commit comments