Skip to content

AIAgent.CreateSessionAsync does not allow SessionConfig (OnPermissionRequest), causing runtime exception #1115

@NarasimhaMurty

Description

@NarasimhaMurty

Description

When using Microsoft Agent Framework with GitHub Copilot SDK in .NET,
AIAgent.CreateSessionAsync() does not provide a way to pass SessionConfig.

This results in a runtime exception because OnPermissionRequest is required by the Copilot SDK during session creation.


Exception

System.ArgumentException:
"An OnPermissionRequest handler is required when creating a session.
For example, use CreateSessionAsync(new() { OnPermissionRequest = PermissionHandler.ApproveAll });"


Minimal Repro

using GitHub.Copilot.SDK;
using Microsoft.Agents.AI;

await using var copilotClient = new CopilotClient();
await copilotClient.StartAsync();

var agent = copilotClient.AsAIAgent(
    tools: [],
    instructions: "Test agent"
);

// ❌ No way to pass SessionConfig here
AgentSession session = await agent.CreateSessionAsync();

// ❌ Throws at runtime
var response = await agent.RunAsync("Hello", session);

Observed Behavior

* AIAgent.CreateSessionAsync() internally creates a Copilot session without SessionConfig
* This causes a runtime exception due to missing OnPermissionRequest
* CopilotClientOptions.SessionConfig is not honored during agent session creation

Expected Behavior

One of the following should be supported:
1. Provide overload:
AIAgent.CreateSessionAsync(SessionConfig config)
2. Ensure CopilotClientOptions.SessionConfig is used internally when creating sessions via AIAgent
3. Provide a unified session abstraction between:
    * CopilotSession
    * AgentSession
   Additional Findings

* CopilotClient.CreateSessionAsync(SessionConfig) works correctly
* However, CopilotSession cannot be used with AIAgent.RunAsync(...) due to type mismatch with AgentSession
* This creates a gap where:
    * SessionConfig can be set* OR Agent abstraction can be used ❌
    * But not both together


Impact

* Cannot configure permission handling (OnPermissionRequest)
* Tool calling scenarios are blocked
* Limits production usage of AIAgent
Environment

* GitHub.Copilot.SDK: [0.2.2]
* Microsoft.Agents.AI: [1.1.0-preview.260410.1]
* .NET SDK: [.net 8]
* OS: [Windows]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions