Skip to content

Commit 81c76ae

Browse files
ericdalloeca-agent
andcommitted
Strip newlines from ask_user summary
🤖 Generated with [eca](https://eca.dev) Co-Authored-By: eca-agent <git@eca.dev>
1 parent 14e53e8 commit 81c76ae

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/eca/features/tools/ask_user.clj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@
5555
:enabled-fn (fn [{:keys [db]}] (-> db :client-capabilities :code-assistant :chat-capabilities :ask-question))
5656
:summary-fn (fn [{:keys [args]}]
5757
(if-let [q (get args "question")]
58-
(let [prefix "Q: "
58+
(let [q (string/replace q #"[\r\n]+" " ")
59+
prefix "Q: "
5960
max-len 50
6061
available (- max-len (count prefix))]
6162
(if (> (count q) available)

test/eca/features/tools/ask_user_test.clj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@
139139
(is (= "Q: Short question?" (summary-fn {:args {"question" "Short question?"}})))
140140
(is (= "Q: This is a very long question that exceeds th..."
141141
(summary-fn {:args {"question" "This is a very long question that exceeds the fifty character limit"}})))))
142+
(testing "Summary strips newlines from question"
143+
(let [summary-fn (get-in f.tools.ask-user/definitions ["ask_user" :summary-fn])]
144+
(is (= "Q: First line second line" (summary-fn {:args {"question" "First line\nsecond line"}})))))
142145
(testing "Summary shows preparing when question not yet available"
143146
(let [summary-fn (get-in f.tools.ask-user/definitions ["ask_user" :summary-fn])]
144147
(is (= "Preparing question" (summary-fn {:args {}}))))))

0 commit comments

Comments
 (0)