File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44
55- Support ` ask_user ` tool allowing LLM to ask the user questions with optional selectable options. #338
66- Remove redundant system message when background jobs finish or are killed.
7+ - Remove timeout for ` ask_user ` tool so it waits indefinitely for user response.
78
89## 0.126.0
910
Original file line number Diff line number Diff line change 88(set! *warn-on-reflection* true )
99
1010(def ^:private logger-tag " [TOOLS-USER]" )
11- (def ^:private default-timeout-seconds 300 )
1211
1312(defn ^:private ask-user
14- [arguments {:keys [messenger config chat-id tool-call-id]}]
13+ [arguments {:keys [messenger chat-id tool-call-id]}]
1514 (let [question (get arguments " question" )
1615 options (get arguments " options" )
1716 allow-freeform (get arguments " allowFreeform" true )]
1817 (if (or (nil? question) (string/blank? question))
1918 (tools.util/single-text-content " INVALID_ARGS: `question` is required and must not be blank." :error )
20- (let [timeout-ms (* 1000 (get config :askQuestionTimeoutSeconds default-timeout-seconds ))
21- params (cond-> {:chatId chat-id
19+ (let [params (cond-> {:chatId chat-id
2220 :question question
2321 :allowFreeform allow-freeform}
2422 (seq options) (assoc :options options)
2826 {:chat-id chat-id
2927 :role :system
3028 :content {:type :progress :state :running :text " Waiting answer" }})
31- (let [response (deref (messenger/ask-question messenger params) timeout-ms ::timeout )]
32- (cond
33- (= response ::timeout )
34- (tools.util/single-text-content " Timeout waiting for user response." :error )
35-
36- (:cancelled response)
29+ (let [response @(messenger/ask-question messenger params)]
30+ (if (:cancelled response)
3731 (tools.util/single-text-content " User cancelled the question." :error )
38-
39- :else
4032 (tools.util/single-text-content (str " User answered: " (:answer response)))))
4133 (catch Exception e
4234 (logger/error logger-tag " Error asking user question: %s" (ex-message e))
Original file line number Diff line number Diff line change 6060 :text " User cancelled the question." }]}
6161 (call-ask-user {" question" " Which framework?" })))))
6262
63- (deftest ask-user-timeout-test
64- (testing " Timeout waiting for user response"
65- (reset! (:ask-question-response* (h/messenger )) :block )
66- (is (match?
67- {:error true
68- :contents [{:type :text
69- :text " Timeout waiting for user response." }]}
70- (call-ask-user {" question" " Which framework?" }
71- {:config {:askQuestionTimeoutSeconds 0 }})))))
72-
7363(deftest ask-user-missing-question-test
7464 (testing " Missing question parameter"
7565 (is (match?
You can’t perform that action at this time.
0 commit comments