File tree Expand file tree Collapse file tree 2 files changed +8
-7
lines changed
src/Infrastructure/BotSharp.Core/Agents/Services Expand file tree Collapse file tree 2 files changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -70,6 +70,11 @@ public async Task<Agent> GetAgent(string id)
7070 }
7171
7272 profile . Plugin = GetPlugin ( profile . Id ) ;
73+
74+ //add default instruction to ChannelInstructions
75+ var defaultInstruction = new ChannelInstruction ( ) { Channel = string . Empty , Instruction = profile ? . Instruction } ;
76+ profile . ChannelInstructions . Insert ( 0 , defaultInstruction ) ;
77+
7378 return profile ;
7479 }
7580
Original file line number Diff line number Diff line change @@ -73,14 +73,10 @@ private void OverrideInstructionByChannel(Agent agent)
7373
7474 var state = _services . GetRequiredService < IConversationStateService > ( ) ;
7575 var channel = state . GetState ( "channel" ) ;
76-
77- if ( string . IsNullOrWhiteSpace ( channel ) )
78- {
79- return ;
80- }
81-
76+
8277 var found = instructions . FirstOrDefault ( x => x . Channel . IsEqualTo ( channel ) ) ;
83- agent . Instruction = ! string . IsNullOrWhiteSpace ( found ? . Instruction ) ? found . Instruction : agent . Instruction ;
78+ var defaultInstruction = instructions . FirstOrDefault ( x => x . Channel == string . Empty ) ;
79+ agent . Instruction = ! string . IsNullOrWhiteSpace ( found ? . Instruction ) ? found . Instruction : defaultInstruction ? . Instruction ;
8480 }
8581
8682 private void PopulateState ( Dictionary < string , object > dict )
You can’t perform that action at this time.
0 commit comments