Problem with Model / Behavior configuration in multiple chats
To upvote this issue, give it a thumbs up. See this list for the most upvoted issues.
Describe the bug
- When I change model or behavior in second chat it will change it in the first chat as well.
- After I selected the model in the second chat and switched back to the first one, i can't change the model there, it changes the model in the second one only (both chats are waiting for tool approval, maybe it is related).
Expected behavior These settings are chat specific only.
Ah, i just found out that the first chat is now completely broken and I can't even approve the tool. I can't reproduce it though, but maybe the broken model switchers isn't related to the main problem (change in one chat influence the other).
toggle-debug-on-error does nothing when this happens.
And now it did. cc @ericdallo
Debugger entered--Lisp error: (wrong-type-argument stringp nil)
eca-chat-select-model()
funcall-interactively(eca-chat-select-model)
command-execute(eca-chat-select-model)
@zikajk I pushed yesterday or so improvements to agent (behavior) on eca-emacs, I just tried to repro your issue and everything worked.
Is that all the stacktrace?
I also can't reproduce it. It happens rarely (like in <5% cases). I was just dropping notes there, when it happens next time I will do the debug with LLM and find out what went wrong.
A deterministic server-side case that may help investigate this issue: selecting an agent for a fresh chat ID, before its first prompt, still emits a session-wide model selection on current master (d19f10e5f6155ba88de650061b926ec8d1c71f46). This is not confirmation that it explains the original intermittent UI failure.
Measured with the test messenger (no provider request), from a source checkout with the Clojure CLI:
clojure -Sdeps '{:paths ["src" "resources" "test"]}' -M -e '
(require (quote [eca.handlers :as handlers]) (quote [eca.test-helper :as h]))
(h/reset-components!)
(h/config! {:agent {"plan" {:defaultModel "openai/gpt-4.1"}}})
(swap! (h/db*) assoc :chats {"existing" {:id "existing" :model "other/model"}})
(def id "4a0622d1-a458-4265-a7b3-496fdd0bf827")
(handlers/chat-selected-agent-changed (h/components) {:chat-id id :agent "plan"})
(def update-message (first (:config-updated (h/messages))))
(prn update-message)
(assert (= "openai/gpt-4.1" (get-in update-message [:chat :select-model])))
(assert (not (contains? update-message :chat-id)))
(assert (nil? (get-in (h/db) [:chats id])))
(assert (= "other/model" (get-in (h/db) [:chats "existing" :model])))
(shutdown-agents)'
Actual captured notification payload:
{:chat {:select-model "openai/gpt-4.1", :variants [], :select-variant nil}}
Expected: a selection addressed to a fresh chat should not announce a session-wide model change. The existing server chat record remains unchanged; the risk of other chats adopting the model is inferred from the unscoped notification, not re-tested end-to-end in a client here.
update-agent-model-and-variants! explicitly takes the session-wide fallback when the ID has no existing chat record (src/eca/handlers.clj). The existing chat-selected-agent-changed-per-chat-scoping-test passes (18 assertions) and explicitly covers this fallback. #533 fixed restoration during open/resume/import, but this fresh-ID agent-selection path remains.