Skip to content

Instantly share code, notes, and snippets.

@wullemsb
Created May 8, 2026 19:56
Show Gist options
  • Select an option

  • Save wullemsb/6e3a4782fe03c39aeca9d4f82e878431 to your computer and use it in GitHub Desktop.

Select an option

Save wullemsb/6e3a4782fe03c39aeca9d4f82e878431 to your computer and use it in GitHub Desktop.
var session = await client.CreateSessionAsync(new SessionConfig
{
Model = "gpt-4.1",
OnPermissionRequest = async (request, invocation) =>
{
// Approve read operations automatically, prompt for anything else
if (request.Kind == "read")
return new PermissionRequestResult() {Kind=PermissionRequestResultKind.Approved };
Console.WriteLine("Agent wants to perform: {request.Kind} — {request.Description}");
Console.Write("Approve? (y/n): ");
var answer = Console.ReadLine();
return answer?.ToLower() == "y"
? new PermissionRequestResult() {Kind=PermissionRequestResultKind.Approved }
: new PermissionRequestResult() {Kind=PermissionRequestResultKind.UserNotAvailable };
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment