Thanks to visit codestin.com
Credit goes to github.com

Skip to content

.NET: [Bug]: MissingMethodException in GitHubCopilotAgent.CopySessionConfig when using GitHub.Copilot.SDK >= 0.1.24 #4379

Description

@ankushbindlish2

Description

Title

MissingMethodException in GitHubCopilotAgent.CopySessionConfig when using GitHub.Copilot.SDK >= 0.1.24

What happened?

When invoking any agent through GitHubCopilotAgent, a System.MissingMethodException is thrown at runtime:

System.MissingMethodException
  HResult=0x80131513
  Message=Method not found: 'GitHub.Copilot.SDK.PermissionHandler GitHub.Copilot.SDK.SessionConfig.get_OnPermissionRequest()'.
  Source=Microsoft.Agents.AI.GitHub.Copilot
  StackTrace:
   at Microsoft.Agents.AI.GitHub.Copilot.GitHubCopilotAgent.CopySessionConfig(SessionConfig source)
   at Microsoft.Agents.AI.GitHub.Copilot.GitHubCopilotAgent.CopySessionConfig(SessionConfig source)
   at Microsoft.Agents.AI.GitHub.Copilot.GitHubCopilotAgent.<RunCoreStreamingAsync>d__15.MoveNext()
   at Microsoft.Agents.AI.GitHub.Copilot.GitHubCopilotAgent.<RunCoreStreamingAsync>d__15.System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult(Int16 token)
   at Microsoft.Agents.AI.AgentResponseExtensions.<AsChatResponseUpdatesWithAdditionalDetailsAsync>d__6.MoveNext()
   at Microsoft.Extensions.AI.ChatResponseExtensions.<<ToChatResponseAsync>g__ToChatResponseAsync|5_0>d.MoveNext()
   at Microsoft.Agents.AI.AgentResponseExtensions.<<ToAgentResponseAsync>g__ToAgentResponseAsync|4_0>d.MoveNext()

The root cause is a binary-breaking change in GitHub.Copilot.SDK. The PermissionHandler type was changed from a delegate to a static sealed class between versions 0.1.23 and 0.1.24+. The Microsoft.Agents.AI.GitHub.Copilot package was compiled against SDK 0.1.23.0 (confirmed via assembly metadata), so its IL expects get_OnPermissionRequest() to return the old delegate type. When the newer SDK is loaded at runtime, the CLR cannot resolve the method signature.

What did you expect to happen?

Since Microsoft.Agents.AI.GitHub.Copilot declares a NuGet dependency of GitHub.Copilot.SDK >= 0.1.23, NuGet resolves the latest compatible version (e.g., 0.1.29). I expected the agent to work correctly with any SDK version satisfying this constraint, without a runtime exception.

Steps to reproduce the issue

  1. Create a new .NET 10 console or WinUI 3 project
  2. Add the following package references:
    <PackageReference Include="Microsoft.Agents.AI.GitHub.Copilot" Version="1.0.0-preview.260225.1" />
    <PackageReference Include="GitHub.Copilot.SDK" Version="0.1.29" />
  3. Build the project (succeeds with no errors)
  4. Create a CopilotClient, start it, create an AIAgent using the Copilot adapter, and invoke it
  5. Observe the MissingMethodException at runtime

Code snippets

Minimal reproduction — agent invocation:

CopilotClient copilotClient = new(new CopilotClientOptions
{
    Logger = logger,
    LogLevel = "debug",
    Cwd = AppContext.BaseDirectory
});
await copilotClient.StartAsync();

// Create an agent using the Microsoft Agent Framework + Copilot adapter
AIAgent agent = new AIAgentBuilder()
    .WithName("TestAgent")
    .WithInstructions("You are a helpful assistant.")
    .WithChatClient(copilotClient)
    .Build();

// This call throws MissingMethodException inside CopySessionConfig
AgentResponse response = await agent.RunAsync("Hello");

Workaround — pin SDK version in the project file:

<!-- Pin to 0.1.23 which is the version Microsoft.Agents.AI.GitHub.Copilot was compiled against -->
<PackageReference Include="GitHub.Copilot.SDK" VersionOverride="0.1.23" />

Package details

Package Version Status
Microsoft.Agents.AI.GitHub.Copilot 1.0.0-preview.260225.1 Compiled against GitHub.Copilot.SDK assembly 0.1.23.0
GitHub.Copilot.SDK 0.1.29 (latest) Binary-incompatible — PermissionHandler is now a static class
GitHub.Copilot.SDK 0.1.23 Works — PermissionHandler is a delegate (matches compiled IL)
Microsoft.Agents.AI 1.0.0-rc2
Microsoft.Agents.AI.Workflows 1.0.0-rc2
Microsoft.Extensions.AI 10.3.0

Assembly metadata evidence:

# Microsoft.Agents.AI.GitHub.Copilot.dll
AssemblyRef: GitHub.Copilot.SDK Version=0.1.23.0
MemberRef: get_OnPermissionRequest, set_OnPermissionRequest

# GitHub.Copilot.SDK.dll v0.1.29
Type: GitHub.Copilot.SDK.PermissionHandler (Attrs: Public, Abstract, Sealed, BeforeFieldInit)  ← static class
  Method: get_ApproveAll
  Method: .cctor

# GitHub.Copilot.SDK.dll v0.1.23
Type: GitHub.Copilot.SDK.PermissionHandler  ← delegate

Suggested fix (pick one):

  1. Rebuild Microsoft.Agents.AI.GitHub.Copilot against GitHub.Copilot.SDK >= 0.1.29
  2. Tighten the NuGet dependency to [0.1.23, 0.1.24) to prevent resolving incompatible versions

Environment:

  • OS: Windows 11 (10.0.22621)
  • Target Framework: net10.0-windows10.0.22621.0
  • .NET SDK: 10.0

Code Sample

CopilotClient copilotClient = new(new CopilotClientOptions
{
    Logger = logger,
    LogLevel = "debug",
    Cwd = AppContext.BaseDirectory
});
await copilotClient.StartAsync();

// Create an agent using the Microsoft Agent Framework + Copilot adapter
AIAgent agent = new AIAgentBuilder()
    .WithName("TestAgent")
    .WithInstructions("You are a helpful assistant.")
    .WithChatClient(copilotClient)
    .Build();

// This call throws MissingMethodException inside CopySessionConfig
AgentResponse response = await agent.RunAsync("Hello");

Error Messages / Stack Traces

System.MissingMethodException
  HResult=0x80131513
  Message=Method not found: 'GitHub.Copilot.SDK.PermissionHandler GitHub.Copilot.SDK.SessionConfig.get_OnPermissionRequest()'.
  Source=Microsoft.Agents.AI.GitHub.Copilot
  StackTrace:
   at Microsoft.Agents.AI.GitHub.Copilot.GitHubCopilotAgent.CopySessionConfig(SessionConfig source)
   at Microsoft.Agents.AI.GitHub.Copilot.GitHubCopilotAgent.CopySessionConfig(SessionConfig source)
   at Microsoft.Agents.AI.GitHub.Copilot.GitHubCopilotAgent.<RunCoreStreamingAsync>d__15.MoveNext()
   at Microsoft.Agents.AI.GitHub.Copilot.GitHubCopilotAgent.<RunCoreStreamingAsync>d__15.System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult(Int16 token)
   at Microsoft.Agents.AI.AgentResponseExtensions.<AsChatResponseUpdatesWithAdditionalDetailsAsync>d__6.MoveNext()
   at Microsoft.Extensions.AI.ChatResponseExtensions.<<ToChatResponseAsync>g__ToChatResponseAsync|5_0>d.MoveNext()
   at Microsoft.Agents.AI.AgentResponseExtensions.<<ToAgentResponseAsync>g__ToAgentResponseAsync|4_0>d.MoveNext()

Package Versions

Microsoft.Agents.AI.GitHub.Copilot

.NET Version

net10.0-windows10.0.22621.0

Additional Context

No response

Metadata

Metadata

Assignees

Labels

.NETUsage: [Issues, PRs], Target: .NetbugUsage: [Issues], Target: all issues (Legacy, prefer issue type: bug)

Type

Fields

No fields configured for Bug.

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions