Skip to main content

GitHub Copilot SDK issue after upgrading to the 1.0.0-beta.10

After upgrading the GitHub Copilot SDK to the 1.0.0-beta.10 version, initiating the CopilotClient no longer worked. Instead I got the following error message:

System.Text.Json.JsonException: The JSON value could not be converted to System.DateTimeOffset. Path: $.timestamp | LineNumber: 0 | BytePositionInLine: 43.  ---> System.InvalidOperationException: Cannot get the value of a token type 'Number' as a string.    at System.Text.Json.ThrowHelper.ThrowInvalidOperationException_ExpectedString(JsonTokenType tokenType)    at System.Text.Json.Utf8JsonReader.TryGetDateTimeOffset(DateTimeOffset& value)    at System.Text.Json.Utf8JsonReader.GetDateTimeOffset()    at System.Text.Json.Serialization.Converters.DateTimeOffsetConverter.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options)    at System.Text.Json.Serialization.Metadata.JsonPropertyInfo`1.ReadJsonAndSetMember(Object obj, ReadStack& state, Utf8JsonReader& reader)    at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)    at System.Text.Json.Serialization.Converters.JsonMetadataServicesConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)    at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue)    at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, T& value, JsonSerializerOptions options, ReadStack& state)    --- End of inner exception stack trace ---    at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, Utf8JsonReader& reader, Exception ex)    at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, T& value, JsonSerializerOptions options, ReadStack& state)    at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.Deserialize(Utf8JsonReader& reader, ReadStack& state)    at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.DeserializeAsObject(Utf8JsonReader& reader, ReadStack& state)    at System.Text.Json.JsonSerializer.ReadFromSpanAsObject(ReadOnlySpan`1 utf8Json, JsonTypeInfo jsonTypeInfo, Nullable`1 actualByteCount)    at System.Text.Json.JsonSerializer.Deserialize(JsonElement element, JsonTypeInfo jsonTypeInfo)    at GitHub.Copilot.JsonRpc.InvokeAsync[T](String method, Object[] args, CancellationToken cancellationToken, Action`1 onResponseInline)    at GitHub.Copilot.JsonRpc.InvokeAsync[T](String method, Object[] args, CancellationToken cancellationToken, Action`1 onResponseInline)    at GitHub.Copilot.CopilotClient.InvokeRpcAsync[T](JsonRpc rpc, String method, Object[] args, StringBuilder stderrBuffer, CancellationToken cancellationToken, Action`1 onResponseInline)    at GitHub.Copilot.CopilotClient.VerifyProtocolVersionAsync(Connection connection, CancellationToken cancellationToken)    at GitHub.Copilot.CopilotClient.g__StartCoreAsync|24_0(CancellationToken ct)    at GitHub.Copilot.CopilotClient.g__StartCoreAsync|24_0(CancellationToken ct)    at GitHub.Copilot.CopilotClient.CreateSessionAsync(SessionConfig config, CancellationToken cancellationToken)    at PowerPilot.Agents.ChatAgentService.GetOrCreateSessionAsync(CancellationToken ct) in D:\Projects\PowerPilot\src\PowerPilot.Agents\ChatAgentService.cs:line 161    at PowerPilot.Agents.ChatAgentService.ChatAsync(String userMessage, CancellationToken cancellationToken)+MoveNext() in D:\Projects\PowerPilot\src\PowerPilot.Agents\ChatAgentService.cs:line 85

I was using the default CopilotClient object which uses the included Copilot CLI and spawns it up as a child process.

The workaround

My first solution was more a workaround. I changed the code to use an already running Copilot CLI instance that was using the headless mode:

copilot --headless

I updated the CopilotClient to use this instance:

    var clientOptions = new CopilotClientOptions();
    if (!string.IsNullOrEmpty(options.CliUrl))
    {
          clientOptions.Connection = RuntimeConnection.ForUri(options.CliUrl);
    }
    return new CopilotClient(clientOptions);

When making this stitch, the error disappeared at least my application was working again. Of course, this is not a final solution. But this gives us a clue that the problem is probably related with the integrated Copilot CLI.

The solution

We accidently found a solution by upgrading our application to .NET 10. At the moment we encountered the error, the app was still using .NET 8. But after doing the upgrade, the issue disappeared.

Could it be that their was a problem with the .NET 8 version of the latest SDK?

I created a minimal example to reproduce the issue. However when I ran the .NET 8 version of this minimal example, it just worked.

Than I noticed the following in the output:

1>------ Build started: Project: CopilotSDKIssueNET810, Configuration: Debug Any CPU ------ 1>C:\Program Files\dotnet\sdk\10.0.300-preview.0.26177.108\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(383,5): message NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy 1> Downloading Copilot CLI 1.0.56-1 for win32-x64... 1> Downloading from "https://registry.npmjs.org/@github/copilot-win32-x64/-/copilot-win32-x64-1.0.56-1.tgz" to "D:\Projects\Test\CopilotSDKIssueNET810\CopilotSDKIssueNET810\obj\Debug\net8.0\copilot-cli\1.0.56-1\win32-x64\copilot.tgz" (84859620 bytes). 1> Skipping analyzers to speed up the build. You can execute 'Build' or 'Rebuild' command to run analyzers.

Aha! When updating the Copilot SDK package to the latest beta version, I assume it didn't update the corresponding CLI version. So that could be a valid reason.

As it is working now, I decided to leave it there. If the issue reappears, I’ll update this post.

Case closed…

Popular posts from this blog

Podman– Command execution failed with exit code 125

After updating WSL on one of the developer machines, Podman failed to work. When we took a look through Podman Desktop, we noticed that Podman had stopped running and returned the following error message: Error: Command execution failed with exit code 125 Here are the steps we tried to fix the issue: We started by running podman info to get some extra details on what could be wrong: >podman info OS: windows/amd64 provider: wsl version: 5.3.1 Cannot connect to Podman. Please verify your connection to the Linux system using `podman system connection list`, or try `podman machine init` and `podman machine start` to manage a new Linux VM Error: unable to connect to Podman socket: failed to connect: dial tcp 127.0.0.1:2655: connectex: No connection could be made because the target machine actively refused it. That makes sense as the podman VM was not running. Let’s check the VM: >podman machine list NAME         ...

Azure DevOps/ GitHub emoji

I’m really bad at remembering emoji’s. So here is cheat sheet with all emoji’s that can be used in tools that support the github emoji markdown markup: All credits go to rcaviers who created this list.

VS Code Planning mode

After the introduction of Plan mode in Visual Studio , it now also found its way into VS Code. Planning mode, or as I like to call it 'Hannibal mode', extends GitHub Copilot's Agent Mode capabilities to handle larger, multi-step coding tasks with a structured approach. Instead of jumping straight into code generation, Planning mode creates a detailed execution plan. If you want more details, have a look at my previous post . Putting plan mode into action VS Code takes a different approach compared to Visual Studio when using plan mode. Instead of a configuration setting that you can activate but have limited control over, planning is available as a separate chat mode/agent: I like this approach better than how Visual Studio does it as you have explicit control when plan mode is activated. Instead of immediately diving into execution, the plan agent creates a plan and asks some follow up questions: You can further edit the plan by clicking on ‘Open in Editor’: ...