Skip to content

Commit afd7a19

Browse files
committed
Fix regression in /compact command.
1 parent d12f05f commit afd7a19

File tree

5 files changed

+13
-27
lines changed

5 files changed

+13
-27
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
- Fix regression in `/compact` command.
6+
57
## 0.71.1
68

79
- Use web-search false if model capabiltiies are not found.

src/eca/features/chat.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@
697697
;; assert: In :executing
698698
(logger/debug logger-tag "Just set up the call promise"
699699
{:tool-call-id id})
700-
(let [result (f.tools/call-tool! name arguments behavior chat-id id db* config messenger metrics
700+
(let [result (f.tools/call-tool! name arguments chat-id id behavior db* config messenger metrics
701701
(partial get-tool-call-state @db* chat-id id)
702702
(partial transition-tool-call! db* chat-ctx id))
703703
details (f.tools/tool-call-details-after-invocation name arguments details result)

src/eca/features/commands.clj

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,12 @@
205205
{:type :send-prompt
206206
:on-finished-side-effect (fn []
207207
;; Replace chat history with summary
208-
(swap! db* assoc-in [:chats chat-id :messages]
209-
[{:role "user"
210-
:content [{:type :text
211-
:text (str "The conversation was compacted/summarized, consider this summary:\n"
212-
(get-in @db* [:chats chat-id :last-summary]))}]}])
208+
(swap! db* (fn [db]
209+
(assoc-in db [:chats chat-id :messages]
210+
[{:role "user"
211+
:content [{:type :text
212+
:text (str "The conversation was compacted/summarized, consider this summary:\n"
213+
(get-in db [:chats chat-id :last-summary]))}]}])))
213214

214215
;; Zero chat usage
215216
(swap! db* assoc-in [:chats chat-id :total-input-tokens] nil)

src/eca/features/tools/chat.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
;; Save summary to replace chat history later
1313
(swap! db* assoc-in [:chats chat-id :last-summary] summary)
1414

15-
(tools.util/single-text-content summary)))
15+
(tools.util/single-text-content "Compacted successfully!")))
1616

1717
(def definitions
1818
{"eca_compact_chat"

test/eca/features/tools/chat_test.clj

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
{:db* db* :chat-id chat-id})]
2121
(testing "returns correct response format"
2222
(is (match?
23-
{:contents [{:type :text :text test-summary}]}
23+
{:contents [{:type :text :text "Compacted successfully!"}]}
2424
result)))
2525

2626
(testing "updates database state correctly"
@@ -40,29 +40,12 @@
4040
{"summary" empty-summary}
4141
{:db* db* :chat-id chat-id})]
4242
(is (match?
43-
{:contents [{:type :text :text empty-summary}]}
43+
{:contents [{:type :text :text "Compacted successfully!"}]}
4444
result))
4545

4646
(let [chat-state (get-in @db* [:chats chat-id])]
4747
(is (= false (:compacting? chat-state)))
48-
(is (= empty-summary (:last-summary chat-state)))))))
49-
50-
(testing "Handles missing summary parameter gracefully"
51-
(let [db* (h/db*)
52-
chat-id "test-chat-789"]
53-
(swap! db* assoc-in [:chats chat-id :compacting?] true)
54-
55-
;; This should not throw, but handle the missing parameter
56-
(try
57-
(let [result ((get-in f.tools.chat/definitions ["eca_compact_chat" :handler])
58-
{}
59-
{:db* db* :chat-id chat-id})]
60-
(is (match?
61-
{:contents [{:type :text :text nil}]}
62-
result)))
63-
(catch Exception _
64-
;; If it throws, that's also acceptable behavior for missing required parameter
65-
(is true "Exception is acceptable for missing required parameter"))))))
48+
(is (= empty-summary (:last-summary chat-state))))))))
6649

6750
(deftest compact-chat-enabled-test
6851
(testing "Tool is enabled when chat is compacting"

0 commit comments

Comments
 (0)