Skip to content

Commit 14e53e8

Browse files
ericdalloeca-agent
andcommitted
Remove timeout for ask_user tool
The ask_user tool should wait indefinitely for user response rather than timing out after 5 minutes. Users may be away or thinking. 🤖 Generated with [eca](https://eca.dev) Co-Authored-By: eca-agent <git@eca.dev>
1 parent 1c3b92d commit 14e53e8

3 files changed

Lines changed: 5 additions & 22 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
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

src/eca/features/tools/ask_user.clj

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,15 @@
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)
@@ -28,15 +26,9 @@
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))

test/eca/features/tools/ask_user_test.clj

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,6 @@
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?

0 commit comments

Comments
 (0)