fix(daemon): launch_agent + switch_agent fall back to conf model too

28dae15 made /api/inject carry modelPref into the inject payload, but
execute_launch_agent and execute_switch_agent in the daemon only read
model from their queue payload. So the autopilot watchdog (which
spawns fresh agents via launch_agent without pinning a model) and the
agent dropdown's switch flow (when called without an explicit model)
both fell back to each agent's built-in default — a project pinned to
"opus" still got Sonnet when autopilot restarted it.

Pattern matches the execute_inject auto-launch path (501a6e7): when
payload model is empty, look up _conf_model_for_tab. Three call sites
now do the same fallback consistently — auto-launch, launch_agent,
switch_agent.

No payload schema change; pure daemon-side defensive lookup. Caller-
supplied model still wins; conf model fills the gap.
This commit is contained in:
g-but committed 2026-05-31 01:57:46 +02:00
1 parent 28dae157b8
commit 9a3bd61216
1 file changed
+14
+14
View File
@@ -457,6 +457,13 @@ execute_close_tab() {
execute_launch_agent() {
local id="$1" tab="$2" dir="$3" agent="$4" model="${5:-}" initial_prompt="${6:-}"
# Fall back to agent-projects.conf 4th column when caller didn't pin a model.
# The autopilot watchdog and direct hook callers don't carry modelPref in
# their payload, so without this they'd launch each agent at its built-in
# default — a project pinned to "opus" still got Sonnet, etc.
if [ -z "$model" ] && type _conf_model_for_tab >/dev/null 2>&1; then
model=$(_conf_model_for_tab "$tab" 2>/dev/null || true)
fi
local session command
command=$(_agent_launch_cmd "$agent" "$dir" "$model")
if [ -z "$command" ]; then
@@ -544,6 +551,13 @@ execute_switch_agent() {
return 0
fi
# Fall back to conf model when caller didn't pin one — same reasoning as
# execute_launch_agent. A user switching from Claude→Gemini on a project
# pinned to flash now actually gets flash instead of 1.5-pro.
if [ -z "$model" ] && type _conf_model_for_tab >/dev/null 2>&1; then
model=$(_conf_model_for_tab "$tab" 2>/dev/null || true)
fi
local launch_cmd
launch_cmd=$(_agent_launch_cmd "$to_agent" "$dir" "$model")
if [ -z "$launch_cmd" ]; then