Skip to content

Instantly share code, notes, and snippets.

View wullemsb's full-sized avatar

Wullems Bart wullemsb

View GitHub Profile
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}");
builder.Services.AddSingleton<CopilotClient>(sp =>
{
var clientOptions = new CopilotClientOptions();
clientOptions.AutoStart=true;
var client = new CopilotClient(clientOptions);
return client;
});
using GitHub.Copilot.SDK;
await using var client = new CopilotClient();
await using var session = await client.CreateSessionAsync(new SessionConfig
{
Model = "gpt-4.1",
OnPermissionRequest = PermissionHandler.ApproveAll
});
var response = await session.SendAndWaitAsync(new MessageOptions { Prompt = "What does this codebase do?" });
import asyncio
from copilot import CopilotClient
from copilot.session import PermissionHandler
async def main():
client = CopilotClient()
await client.start()
session = await client.create_session(on_permission_request=PermissionHandler.approve_all, model="gpt-4.1")
response = await session.send_and_wait("What does this codebase do?")
// Register the factory, not the workflow
services.AddSingleton<Func<MyWorkflow>>(sp =>
() => new MyWorkflow(sp.GetRequiredService<IMyDependency>()));
// At call site
var wf = workflowFactory(); // fresh each time
await env.RunAsync(wf, input, sessionId);
// Fresh instance per resolution
services.AddKeyedTransient<MyWorkflow>("my-workflow");
// New object every call
var wf = sp.GetRequiredKeyedService<MyWorkflow>("my-workflow");
await env.RunAsync(wf, input, sessionId);
// Registered once, shared forever
services.AddKeyedSingleton<MyWorkflow>("my-workflow");
// Same instance every call
var wf = sp.GetRequiredKeyedService<MyWorkflow>("my-workflow");
await env.RunAsync(wf, input, sessionId);
{
"autoentities": {
"public-read": {
"patterns": {
"include": [ "dbo.%" ],
"exclude": [ "dbo.internal%", "dbo.audit%" ],
"name": "{object}"
},
"template": {
"rest": { "enabled": true },
{
"autoentities": {
"public-api": {
"patterns": { "include": [ "dbo.%" ] },
"permissions": [ { "role": "anonymous", "actions": [ { "action": "read" } ] } ]
}
},
"entities": {
"Products": {
"source": "dbo.Products",
{
"autoentities": {
"public-api": {
"patterns": {
"include": [ "dbo.%" ],
"exclude": [ "dbo.internal%" ],
"name": "{schema}_{object}"
},
"permissions": [
{ "role": "anonymous", "actions": [ { "action": "read" } ] }