Merge pull request #1067 from yileicn/master

hotfix agent instruction cache question
This commit is contained in:
Haiping 2025-05-28 20:10:41 -05:00 committed by GitHub
commit 82affd8bb9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 7 deletions

View file

@ -70,6 +70,11 @@ public partial class AgentService
}
profile.Plugin = GetPlugin(profile.Id);
//add default instruction to ChannelInstructions
var defaultInstruction = new ChannelInstruction() { Channel = string.Empty, Instruction = profile?.Instruction };
profile.ChannelInstructions.Insert(0, defaultInstruction);
return profile;
}

View file

@ -71,14 +71,10 @@ public partial class AgentService
var state = _services.GetRequiredService<IConversationStateService>();
var channel = state.GetState("channel");
if (string.IsNullOrWhiteSpace(channel))
{
return;
}
var found = instructions.FirstOrDefault(x => x.Channel.IsEqualTo(channel));
agent.Instruction = !string.IsNullOrWhiteSpace(found?.Instruction) ? found.Instruction : agent.Instruction;
var defaultInstruction = instructions.FirstOrDefault(x => x.Channel == string.Empty);
agent.Instruction = !string.IsNullOrWhiteSpace(found?.Instruction) ? found.Instruction : defaultInstruction?.Instruction;
}
private void PopulateState(Dictionary<string, object> dict)