|
57 | 57 | (defn ^:private get-active-tool-calls |
58 | 58 | "Returns a map of tool calls that are still active. |
59 | 59 |
|
60 | | - Active tool calls are those not in the following states: :completed, :rejected, :stopped." |
| 60 | + Active tool calls are those not in the following (terminal) states: :completed, :rejected, :stopped." |
61 | 61 | [db chat-id] |
62 | 62 | (->> (get-in db [:chats chat-id :tool-calls] {}) |
63 | 63 | (remove (fn [[_ state]] |
|
128 | 128 |
|
129 | 129 | ;; And now all the :stop-requested transitions |
130 | 130 |
|
131 | | - ;; In the future, when calls can be interrupted, |
| 131 | + ;; TODO: In the future, when calls can be interrupted, |
132 | 132 | ;; more states and actions will be required. |
133 | 133 |
|
134 | 134 | [:execution-approved :stop-requested] |
|
442 | 442 | (transition-tool-call! db* chat-ctx id :auto-approve)) |
443 | 443 | ;; Execute each tool call concurrently - this should be the return value of let |
444 | 444 | (future |
445 | | - (if @approved?* |
| 445 | + (if @approved?* ;TODO: Should there be a timeout here? If so, what would be the state transitions? |
446 | 446 | ;; assert: In :execution-approved state |
447 | 447 | (do |
448 | 448 | (assert-chat-not-stopped! chat-ctx) |
|
657 | 657 |
|
658 | 658 | ;; Handle each active tool call |
659 | 659 | (doseq [[tool-call-id _] (get-active-tool-calls @db* chat-id)] |
660 | | - (transition-tool-call! db* chat-ctx tool-call-id :stop-requested) |
661 | | - #_(let [{:keys [actions]} (stop-tool-call-atomically! db* chat-id tool-call-id)] |
662 | | - (doseq [action actions] |
663 | | - (case action |
664 | | - :send-reject |
665 | | - (when (should-send-notification? @db* chat-id tool-call-id :toolCallRejected) |
666 | | - (send-content! chat-ctx :assistant {:type :toolCallRejected |
667 | | - :id tool-call-id |
668 | | - :reason :stop}) |
669 | | - (mark-notification-sent! db* chat-id tool-call-id :toolCallRejected)) |
670 | | - |
671 | | - :reject-approval |
672 | | - ;; This will send a toolCallRejected |
673 | | - (deliver (get-in @db* [:chats chat-id :tool-calls tool-call-id :approved?*]) false) |
674 | | - |
675 | | - (:wait-for-completion :no-action) |
676 | | - nil)))) |
| 660 | + (transition-tool-call! db* chat-ctx tool-call-id :stop-requested)) |
677 | 661 | (finish-chat-prompt! :stopping chat-ctx)))) |
678 | 662 |
|
679 | 663 | (defn delete-chat |
|
0 commit comments