You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
AIFunctionFactory Tools does not go through permission handler | Dotnet | NodeJS #254
Issue: Tools defined through AIFunctionFactory does not follow approval or permission workflow and are invoked automatically. There should be an option to specify permissionRequired within the tool definition and they should seek permission from user before invoking the tool if not specified otherwise.
// Define a tool that Copilot can call
var getWeather = AIFunctionFactory.Create(
([Description("The city name")] string city) =>
{
// In a real app, you'd call a weather API here
var conditions = new[] { "sunny", "cloudy", "rainy", "partly cloudy" };
var temp = Random.Shared.Next(50, 80);
var condition = conditions[Random.Shared.Next(conditions.Length)];
return new { city, temperature = $"{temp}°F", condition };
},
"get_weather",
"Get the current weather for a city"
);
await using var client = new CopilotClient(new CopilotClientOptions { LogLevel = "all" });
await using var session = await client.CreateSessionAsync(new SessionConfig
{
Model = "gpt-5.2",
Streaming = true,
Tools = [getWeather],
OnPermissionRequest = async (permissionRequest, permissionInvocation) =>
{
Console.WriteLine($"\n⚠️ Permission Requested: {permissionRequest.Kind}");
Console.WriteLine($" Details: {System.Text.Json.JsonSerializer.Serialize(permissionRequest.ExtensionData)}");
// For custom tools, ask the user
Console.Write("Allow? (Y/N): ");
var response = Console.ReadLine();
if (string.Equals(response, "Y", StringComparison.OrdinalIgnoreCase))
{
return await Task.FromResult(new PermissionRequestResult { Kind = "approved" });
}
else
{
return await Task.FromResult(new PermissionRequestResult { Kind = "denied-interactively-by-user" });
}
}
});
Expected Behaviur: All tool invocations by the assistant, regardless of their implementation, must follow permission workflow and go through permission handler unless stated otherwise. AIFunctionFactory should also expose a property to set whether permission required or not. For example, approvalMode set to AutoApproved or NeverRequire or Always etc.
Output:
You: Whats the weather in Sambhal
Assistant: I’m fetching the current weather for Sambhal. Sambhal weather right now: **58°F (cloudy)**.
bug — Tools bypassing the permission handler is unintended behavior
sdk/dotnet & sdk/nodejs — Affects both SDKs (version 0.1.19)
security — Permission controls should not be bypassed
The issue is well-documented with reproduction steps, expected behavior, and actual output. The team will review this security concern regarding AIFunctionFactory tools not respecting the OnPermissionRequest handler.
Activity
github-actions commentedon Jan 29, 2026
Thank you for reporting this issue, @ShrayRastogi!
I've labeled this as:
bug— Tools bypassing the permission handler is unintended behaviorsdk/dotnet&sdk/nodejs— Affects both SDKs (version 0.1.19)security— Permission controls should not be bypassedThe issue is well-documented with reproduction steps, expected behavior, and actual output. The team will review this security concern regarding AIFunctionFactory tools not respecting the
OnPermissionRequesthandler.ShrayRastogi commentedon Feb 8, 2026
@copilot - any updates here?
SteveSandersonMS commentedon Feb 24, 2026
Thanks for reporting this, @ShrayRastogi. It will be addressed by #555