Skip to content

Commit e2f2d0a

Browse files
committed
Merge branch 'master' of https://github.com/SciSharp/BotSharp into features/add-utility-visibility
2 parents 3bb50a6 + 82affd8 commit e2f2d0a

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.GetAgents.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff 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

src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.LoadAgent.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff 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)

0 commit comments

Comments
 (0)