Skip to content

.NET SDK events not firing - session hangs indefinitely #21

@ssfdre38

Description

@ssfdre38

.NET SDK events not firing - session hangs indefinitely

Environment

  • CLI Version: 0.0.382 (latest)
  • SDK Version: 0.1.12 (latest)
  • Platform: Ubuntu 24.04, .NET 10.0.1
  • Transport: stdio (default)

Problem

The .NET SDK successfully creates sessions and sends messages, but no events are ever received. Event handlers registered via session.On() are never called, causing applications to hang indefinitely waiting for SessionIdleEvent.

Reproduction

using GitHub.Copilot.SDK;

await using var client = new CopilotClient(new CopilotClientOptions
{
    LogLevel = "debug",
    AutoStart = true
});

await client.StartAsync();
Console.WriteLine("Client connected"); // ✅ This works

await using var session = await client.CreateSessionAsync(new SessionConfig
{
    Model = "gpt-5",
    Streaming = true
});

Console.WriteLine($"Session created: {session.SessionId}"); // ✅ This works

var done = new TaskCompletionSource();

session.On(evt =>
{
    Console.WriteLine($"Event received: {evt.Type}"); // ❌ NEVER CALLED
    
    if (evt is SessionIdleEvent)
    {
        done.SetResult();
    }
});

var messageId = await session.SendAsync(new MessageOptions { Prompt = "What is 2+2?" });
Console.WriteLine($"Message sent: {messageId}"); // ✅ This works

await done.Task; // ❌ HANGS FOREVER - no events received

Expected Behavior

Based on the SDK tests and documentation, should receive:

  1. UserMessageEvent
  2. AssistantMessageEvent with content
  3. SessionIdleEvent when complete

Actual Behavior

  • Session creates successfully
  • SendAsync() returns a message ID successfully
  • Zero events are dispatched - event handler never fires
  • Application hangs indefinitely waiting for SessionIdleEvent

Testing

CLI works fine standalone:

$ echo "What is 2+2?" | copilot --allow-all
2 + 2 = 4
# Works in 4 seconds

But SDK never receives events from the same CLI process.

Debug Logs

dbug: GitHub.Copilot.SDK.CopilotClient[0]
      Starting Copilot client
info: GitHub.Copilot.SDK.CopilotClient[0]
      Copilot client connected
✅ Session created: 5f4457da-1c80-49e1-9d54-dce685b10b40
📤 Sent message: msg-1768508202337
[hangs here - no events ever arrive]

Analysis

The RpcHandler.OnSessionEvent() method in Client.cs appears to never be called, suggesting:

  1. CLI is not sending session.event JSON-RPC notifications, OR
  2. StreamJsonRpc event subscription mechanism is broken, OR
  3. Protocol version mismatch between SDK and CLI

Impact

This makes the .NET SDK completely unusable - all async operations hang indefinitely.

Workaround

None found. Cannot use the SDK at all.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions