Skip to content

Commit 9c2b97c

Browse files
ericdalloeca-agent
andcommitted
Fix chat titles empty when conversation has thinking blocks (Anthropic)
When re-generating the title at the 3rd user message, the full conversation history was passed as past-messages. For thinking models (e.g. nubank-anthropic/opus-4.6), this history includes "reason" role messages. normalize-messages converts them to {:type "thinking" ...} content blocks, but title generation disables thinking (reason? false), so the request carries thinking blocks without the :thinking parameter. The Anthropic API responds with {:text ""}, which is truthy in Clojure, so sanitize-title returns "" and overwrites any previously good title. Fix: filter "reason" role messages out of title-past-messages before the sync prompt call. 🤖 Generated with [eca](https://eca.dev) Co-Authored-By: eca-agent <git@eca.dev>
1 parent 4359d05 commit 9c2b97c

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Unreleased
44

55
- Auto allow ask_user tool by default.
6+
- Fix chat titles becoming empty when conversation history contains thinking blocks (Anthropic).
67

78
## 0.127.0
89

src/eca/features/chat.clj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,8 @@
575575
(assert-compatible-apis-between-models! db chat-id provider model config)
576576
(when generate-title?
577577
(let [title-past-messages (when retitle?
578-
(get-in db [:chats chat-id :messages] []))]
578+
(->> (get-in db [:chats chat-id :messages] [])
579+
(filterv #(not= "reason" (:role %)))))]
579580
(future* config
580581
(when-let [{:keys [output-text]} (llm-api/sync-prompt!
581582
{:provider provider

0 commit comments

Comments
 (0)