Skip to content

Commit 7a3171c

Browse files
authored
Merge pull request #1134 from yileicn/master
optimize GetAgents
2 parents 944869e + 7e1a91f commit 7a3171c

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

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

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,18 @@ public async Task<List<IdName>> GetAgentOptions(List<string>? agentIdsOrNames, b
4444
[SharpCache(10)]
4545
public async Task<Agent> GetAgent(string id)
4646
{
47-
if (string.IsNullOrWhiteSpace(id))
48-
{
49-
return null;
50-
}
51-
52-
var profile = _db.GetAgent(id);
53-
if (profile == null)
54-
{
55-
_logger.LogError($"Can't find agent {id}");
56-
return null;
57-
}
47+
if (string.IsNullOrWhiteSpace(id) || id == Guid.Empty.ToString())
48+
{
49+
_logger.LogWarning($"Can't find agent {id}, AgentId is empty.");
50+
return null;
51+
}
52+
53+
var profile = _db.GetAgent(id);
54+
if (profile == null)
55+
{
56+
_logger.LogError($"Can't find agent {id}");
57+
return null;
58+
}
5859

5960
// Load llm config
6061
var agentSetting = _services.GetRequiredService<AgentSettings>();

0 commit comments

Comments
 (0)