Skip to content

Commit 25230fe

Browse files
authored
Merge pull request #1042 from JackJiang1234/master
Update AgentService.GetAgents.cs
2 parents 434cd44 + 91dda91 commit 25230fe

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,17 @@ public async Task<List<IdName>> GetAgentOptions(List<string>? agentIdsOrNames, b
4444
[SharpCache(10)]
4545
public async Task<Agent> GetAgent(string id)
4646
{
47-
var profile = _db.GetAgent(id);
47+
if (string.IsNullOrWhiteSpace(id))
48+
{
49+
return null;
50+
}
4851

49-
if (profile == null)
50-
{
51-
//_logger.LogError($"Can't find agent {id}");
52-
throw new ArgumentException($"Can't find agent {id}");
53-
}
52+
var profile = _db.GetAgent(id);
53+
if (profile == null)
54+
{
55+
_logger.LogError($"Can't find agent {id}");
56+
return null;
57+
}
5458

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

0 commit comments

Comments
 (0)