@@ -42,6 +42,10 @@ export default function AgentSetupOrchestrator({
4242 setMainAgentModelId,
4343 mainAgentMaxStep,
4444 setMainAgentMaxStep,
45+ businessLogicModel,
46+ setBusinessLogicModel,
47+ businessLogicModelId,
48+ setBusinessLogicModelId,
4549 tools,
4650 subAgentList = [ ] ,
4751 loadingAgents = false ,
@@ -212,8 +216,6 @@ export default function AgentSetupOrchestrator({
212216 if ( ! isEditingAgent ) {
213217 // Only clear and get new Agent configuration in creating mode
214218 setBusinessLogic ( "" ) ;
215- setMainAgentModel ( null ) ; // Clear model selection when creating new agent
216- setMainAgentModelId ( null ) ; // Clear model ID when creating new agent
217219 fetchSubAgentIdAndEnableToolList ( t ) ;
218220 } else {
219221 // In edit mode, data is loaded in handleEditAgent, here validate the form
@@ -323,8 +325,31 @@ export default function AgentSetupOrchestrator({
323325 setIsEditingAgent ( false ) ;
324326 setEditingAgent ( null ) ;
325327 setIsCreatingNewAgent ( true ) ;
326- // Note: Don't clear content here - let the parent component's useEffect handle restoration
327- // The parent component will restore cached content if available
328+
329+ // Clear all content when creating new agent to avoid showing cached data
330+ setBusinessLogic ( "" ) ;
331+ setDutyContent ?.( "" ) ;
332+ setConstraintContent ?.( "" ) ;
333+ setFewShotsContent ?.( "" ) ;
334+ setAgentName ?.( "" ) ;
335+ setAgentDescription ?.( "" ) ;
336+ setAgentDisplayName ?.( "" ) ;
337+
338+ // Clear tool and agent selections
339+ setSelectedTools ( [ ] ) ;
340+ setEnabledToolIds ( [ ] ) ;
341+ setEnabledAgentIds ( [ ] ) ;
342+
343+ // Clear business logic model to allow default from global settings
344+ // The useEffect in PromptManager will set it to the default from localStorage
345+ setBusinessLogicModel ( null ) ;
346+ setBusinessLogicModelId ( null ) ;
347+
348+ // Clear main agent model selection to trigger default model selection
349+ // The useEffect in AgentConfigModal will set it to the default from localStorage
350+ setMainAgentModel ( null ) ;
351+ setMainAgentModelId ( null ) ;
352+
328353 onEditingStateChange ?.( false , null ) ;
329354 } ;
330355
@@ -417,7 +442,9 @@ export default function AgentSetupOrchestrator({
417442 constraintContent ,
418443 fewShotsContent ,
419444 agentDisplayName ,
420- mainAgentModelId ?? undefined
445+ mainAgentModelId ?? undefined ,
446+ businessLogicModel ?? undefined ,
447+ businessLogicModelId ?? undefined
421448 ) ;
422449 } else {
423450 result = await updateAgent (
@@ -433,7 +460,9 @@ export default function AgentSetupOrchestrator({
433460 constraintContent ,
434461 fewShotsContent ,
435462 agentDisplayName ,
436- mainAgentModelId ?? undefined
463+ mainAgentModelId ?? undefined ,
464+ businessLogicModel ?? undefined ,
465+ businessLogicModelId ?? undefined
437466 ) ;
438467 }
439468
@@ -555,6 +584,8 @@ export default function AgentSetupOrchestrator({
555584 setMainAgentModelId ( agentDetail . model_id ) ;
556585 setMainAgentMaxStep ( agentDetail . max_step ) ;
557586 setBusinessLogic ( agentDetail . business_description || "" ) ;
587+ setBusinessLogicModel ( agentDetail . business_logic_model_name || null ) ;
588+ setBusinessLogicModelId ( agentDetail . business_logic_model_id || null ) ;
558589
559590 // Use backend returned sub_agent_id_list to set enabled agent list
560591 if (
@@ -595,21 +626,30 @@ export default function AgentSetupOrchestrator({
595626 } ;
596627
597628 // Handle the update of the model
629+ // Handle Business Logic Model change
630+ const handleBusinessLogicModelChange = ( value : string , modelId ?: number ) => {
631+ setBusinessLogicModel ( value ) ;
632+ if ( modelId !== undefined ) {
633+ setBusinessLogicModelId ( modelId ) ;
634+ }
635+ } ;
636+
598637 const handleModelChange = async ( value : string , modelId ?: number ) => {
599638 const targetAgentId =
600639 isEditingAgent && editingAgent ? editingAgent . id : mainAgentId ;
601640
602- if ( ! targetAgentId ) {
603- message . error ( t ( "businessLogic.config.error.noAgentId" ) ) ;
604- return ;
605- }
606-
607641 // Update local state first
608642 setMainAgentModel ( value ) ;
609643 if ( modelId !== undefined ) {
610644 setMainAgentModelId ( modelId ) ;
611645 }
612646
647+ // If no agent ID yet (e.g., during initial creation setup), just update local state
648+ // The model will be saved when the agent is fully created
649+ if ( ! targetAgentId ) {
650+ return ;
651+ }
652+
613653 // Call updateAgent API to save the model change
614654 try {
615655 const result = await updateAgent (
@@ -961,6 +1001,9 @@ export default function AgentSetupOrchestrator({
9611001 }
9621002 onMaxStepChange = { handleMaxStepChange }
9631003 onBusinessLogicChange = { ( value : string ) => setBusinessLogic ( value ) }
1004+ onBusinessLogicModelChange = { handleBusinessLogicModelChange }
1005+ businessLogicModel = { businessLogicModel }
1006+ businessLogicModelId = { businessLogicModelId }
9641007 onGenerateAgent = { onGenerateAgent || ( ( ) => { } ) }
9651008 onSaveAgent = { handleSaveAgent }
9661009 isGeneratingAgent = { isGeneratingAgent }
0 commit comments