When registering tools with WithAITool the DI container is not built yet so you can't use it. That's not great because tools usually have dependencies. This problem could be solved with a method like this
IHostedAgentBuilder WithAITools(this IHostedAgentBuilder builder, Func<IServiceProvider, IEnumerable<AITool>> factory);
used like this
builder.Services.AddAIAgent("my_agent", "")
.WithAITools(sp =>
{
var userService = sp.GetRequiredService<UserService>();
return [AIFunctionFactory.Create(userService.GetUser)];
});