|
1198 | 1198 | {:role :assistant :content {:type :toolCalled :id "call-3" :name "ro_tool_3" :arguments {} |
1199 | 1199 | :outputs [{:type :text :text "RO tool call 3 result"}]}} |
1200 | 1200 | {:role :system :content {:type :progress :state :running :text "Generating"}} |
1201 | | - {:role :system :content {:type :text :text "\nPrompt stopped"}} |
| 1201 | + {:role :system :content {:type :text :text "\nPrompt stopped\n"}} |
1202 | 1202 | {:role :system :content {:type :progress :state :finished}} |
1203 | 1203 | {:role :assistant :content {:type :toolCallRejected :id "call-2" :name "ro_tool_2" :arguments {} :reason :user}} |
1204 | 1204 | {:role :assistant :content {:type :toolCallRejected :id "call-1" :name "ro_tool_1" :arguments {} :reason :user}}]} |
|
1656 | 1656 | (is (= 2 @build-calls*) "Next message rebuilds the system prompt") |
1657 | 1657 | (is (empty? (system-prompt-notices)) "Explicit sync rebuild does not notify")))))) |
1658 | 1658 |
|
| 1659 | +(deftest clear-chat-resets-prompt-cache-test |
| 1660 | + (testing "Clearing a chat drops the prompt cache so a model switch does not warn (#530)" |
| 1661 | + (h/reset-components!) |
| 1662 | + (let [mocks {:all-tools-mock (constantly []) |
| 1663 | + :api-mock (fn [{:keys [on-message-received]}] |
| 1664 | + (on-message-received {:type :finish}))} |
| 1665 | + {:keys [chat-id]} (prompt! {:message "Hi" :model "openai/gpt-5.2"} mocks)] |
| 1666 | + (is (some? (get-in (h/db) [:chats chat-id :prompt-cache]))) |
| 1667 | + (f.chat/clear-chat {:chat-id chat-id :messages true} (h/db*) (h/messenger) (h/metrics)) |
| 1668 | + (is (nil? (get-in (h/db) [:chats chat-id :prompt-cache])) |
| 1669 | + "Clearing messages drops the prompt cache") |
| 1670 | + (swap! (h/db*) update :models #(merge % {"anthropic/claude-opus-4" {:tools true}})) |
| 1671 | + (h/reset-messenger!) |
| 1672 | + (prompt! {:message "Fresh" :chat-id chat-id :model "anthropic/claude-opus-4"} mocks) |
| 1673 | + (is (empty? (system-prompt-notices)) |
| 1674 | + "No prompt cache invalidation notice on an empty chat")))) |
| 1675 | + |
1659 | 1676 | (deftest prompt-cache-key-includes-agent-test |
1660 | 1677 | (testing "sync-or-async-prompt! receives prompt-cache-key scoped by active agent" |
1661 | 1678 | (h/reset-components!) |
|
0 commit comments