diff --git a/frontend/src/features/agents/hooks/useAgentDrillDown.js b/frontend/src/features/agents/hooks/useAgentDrillDown.js index 55eddce..92b9435 100644 --- a/frontend/src/features/agents/hooks/useAgentDrillDown.js +++ b/frontend/src/features/agents/hooks/useAgentDrillDown.js @@ -73,20 +73,34 @@ if (!found) throw new Error("Agent not found"); setAgent(found); - setEditConfig(prev => prev || { - name: found.template?.name || "", - system_prompt: found.template?.system_prompt_content || found.template?.system_prompt_path || "", - max_loop_iterations: found.template?.max_loop_iterations || 20, - mesh_node_id: found.mesh_node_id || "", - provider_name: found.session?.provider_name || "", - model_name: found.session?.model_name || "", - restrict_skills: found.session?.restrict_skills || false, - allowed_skill_ids: found.session?.skills ? found.session.skills.map(s => s.id) : [], - is_locked: found.session?.is_locked || false, - auto_clear_history: found.session?.auto_clear_history || false, - co_worker_quality_gate: found.template?.co_worker_quality_gate || false, - rework_threshold: found.template?.rework_threshold || 80, - max_rework_attempts: found.template?.max_rework_attempts || 3 + setEditConfig(prev => { + const base = prev || { + name: found.template?.name || "", + system_prompt: found.template?.system_prompt_content || found.template?.system_prompt_path || "", + max_loop_iterations: found.template?.max_loop_iterations || 20, + mesh_node_id: found.mesh_node_id || "", + provider_name: found.session?.provider_name || "", + model_name: found.session?.model_name || "", + restrict_skills: found.session?.restrict_skills || false, + allowed_skill_ids: found.session?.skills ? found.session.skills.map(s => s.id) : [], + is_locked: found.session?.is_locked || false, + auto_clear_history: found.session?.auto_clear_history || false, + co_worker_quality_gate: found.template?.co_worker_quality_gate || false, + rework_threshold: found.template?.rework_threshold || 80, + max_rework_attempts: found.template?.max_rework_attempts || 3 + }; + + // Apply fallbacks if userConfig is available + if (userConfig?.effective) { + if (!base.provider_name) { + base.provider_name = userConfig.effective.llm?.active_provider || "gemini"; + } + if (!base.model_name) { + const defaultProvider = base.provider_name; + base.model_name = userConfig.effective.llm?.providers?.[defaultProvider]?.model || ""; + } + } + return base; }); // Fetch Providers @@ -194,6 +208,22 @@ setUserConfig(conf); setNodes(nList); setAllSkills(sList); + + // Update editConfig with fallbacks if it was already initialized but empty + setEditConfig(prev => { + if (!prev) return prev; + const updated = { ...prev }; + let changed = false; + if (!updated.provider_name) { + updated.provider_name = conf.effective?.llm?.active_provider || "gemini"; + changed = true; + } + if (!updated.model_name && updated.provider_name) { + updated.model_name = conf.effective?.llm?.providers?.[updated.provider_name]?.model || ""; + changed = true; + } + return changed ? updated : prev; + }); } catch (e) {} }; loadConf();