Update AgentService.GetAgents.cs

fix can't find agent issue
This commit is contained in:
Jack 2025-04-30 17:13:53 +08:00 committed by GitHub
parent ba827378f0
commit 91dda91ee1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -44,13 +44,17 @@ public partial class AgentService
[SharpCache(10)]
public async Task<Agent> GetAgent(string id)
{
var profile = _db.GetAgent(id);
if (string.IsNullOrWhiteSpace(id))
{
return null;
}
if (profile == null)
{
//_logger.LogError($"Can't find agent {id}");
throw new ArgumentException($"Can't find agent {id}");
}
var profile = _db.GetAgent(id);
if (profile == null)
{
_logger.LogError($"Can't find agent {id}");
return null;
}
// Load llm config
var agentSetting = _services.GetRequiredService<AgentSettings>();