Skip to content

Commit 69c2866

Browse files
committed
Fix Copilot 1.0.81 protocol compatibility
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 812b44f2-ef93-4b32-b051-c7092f612279
1 parent b9e60f3 commit 69c2866

15 files changed

Lines changed: 81 additions & 45 deletions

File tree

dotnet/src/Client.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,7 +1215,7 @@ public async Task<CopilotSession> CreateSessionAsync(SessionConfig config, Cance
12151215
config.DisabledSkills,
12161216
config.InfiniteSessions,
12171217
config.SessionLimits,
1218-
Commands: config.Commands?.Select(c => new CommandWireDefinition(c.Name, c.Description)).ToList(),
1218+
Commands: config.Commands?.Select(c => new CommandWireDefinition(c.Name, c.Description ?? string.Empty)).ToList(),
12191219
RequestElicitation: config.OnElicitationRequest != null,
12201220
RequestMcpApps: config.EnableMcpApps ? true : null,
12211221
Traceparent: traceparent,
@@ -1436,7 +1436,7 @@ public async Task<CopilotSession> ResumeSessionAsync(string sessionId, ResumeSes
14361436
config.DisabledSkills,
14371437
config.InfiniteSessions,
14381438
config.SessionLimits,
1439-
Commands: config.Commands?.Select(c => new CommandWireDefinition(c.Name, c.Description)).ToList(),
1439+
Commands: config.Commands?.Select(c => new CommandWireDefinition(c.Name, c.Description ?? string.Empty)).ToList(),
14401440
RequestElicitation: config.OnElicitationRequest != null,
14411441
RequestMcpApps: config.EnableMcpApps ? true : null,
14421442
Traceparent: traceparent,
@@ -2954,7 +2954,7 @@ internal record ResumeSessionResponse(
29542954

29552955
internal record CommandWireDefinition(
29562956
string Name,
2957-
string? Description);
2957+
string Description);
29582958

29592959
internal record GetLastSessionIdResponse(
29602960
string? SessionId);

dotnet/src/Session.cs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,7 +1364,10 @@ public async Task<ElicitationResult> ElicitAsync(ElicitationParams elicitationPa
13641364
Required = elicitationParams.RequestedSchema.Required
13651365
};
13661366

1367-
var result = await session.Rpc.Ui.ElicitationAsync(elicitationParams.Message, schema, cancellationToken);
1367+
var result = await session.Rpc.Ui.ElicitationAsync(
1368+
elicitationParams.Message,
1369+
schema,
1370+
cancellationToken: cancellationToken);
13681371
return new ElicitationResult
13691372
{
13701373
Action = result.Action,
@@ -1388,7 +1391,7 @@ public async Task<bool> ConfirmAsync(string message, CancellationToken cancellat
13881391
Required = ["confirmed"]
13891392
};
13901393

1391-
var result = await session.Rpc.Ui.ElicitationAsync(message, schema, cancellationToken);
1394+
var result = await session.Rpc.Ui.ElicitationAsync(message, schema, cancellationToken: cancellationToken);
13921395
if (result.Action == UIElicitationResponseAction.Accept
13931396
&& result.Content != null
13941397
&& result.Content.TryGetValue("confirmed", out var val))
@@ -1422,7 +1425,7 @@ public async Task<bool> ConfirmAsync(string message, CancellationToken cancellat
14221425
Required = ["selection"]
14231426
};
14241427

1425-
var result = await session.Rpc.Ui.ElicitationAsync(message, schema, cancellationToken);
1428+
var result = await session.Rpc.Ui.ElicitationAsync(message, schema, cancellationToken: cancellationToken);
14261429
if (result.Action == UIElicitationResponseAction.Accept
14271430
&& result.Content != null
14281431
&& result.Content.TryGetValue("selection", out var val))
@@ -1457,7 +1460,7 @@ public async Task<bool> ConfirmAsync(string message, CancellationToken cancellat
14571460
Required = ["value"]
14581461
};
14591462

1460-
var result = await session.Rpc.Ui.ElicitationAsync(message, schema, cancellationToken);
1463+
var result = await session.Rpc.Ui.ElicitationAsync(message, schema, cancellationToken: cancellationToken);
14611464
if (result.Action == UIElicitationResponseAction.Accept
14621465
&& result.Content != null
14631466
&& result.Content.TryGetValue("value", out var val))
@@ -1830,14 +1833,14 @@ public async Task SetModelAsync(string model, SetModelOptions options, Cancellat
18301833
ThrowIfDisposed();
18311834

18321835
await Rpc.Model.SwitchToAsync(
1833-
model,
1834-
options.ReasoningEffort,
1835-
options.ReasoningSummary,
1836-
null,
1837-
options.ModelCapabilities,
1838-
options.ContextTier,
1839-
null,
1840-
cancellationToken);
1836+
modelId: model,
1837+
reasoningEffort: options.ReasoningEffort,
1838+
reasoningSummary: options.ReasoningSummary,
1839+
verbosity: null,
1840+
modelCapabilities: options.ModelCapabilities,
1841+
contextTier: options.ContextTier,
1842+
source: null,
1843+
cancellationToken: cancellationToken);
18411844
}
18421845

18431846
/// <summary>

go/rpc/generated_rpc_api_shape_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ func TestGeneratedRPCAPIShape(t *testing.T) {
3535
assertTypeExpr(t, fileSet, findTypeSpec(t, file, "FilterMappingEnumMap").Type, "map[string]ContentFilterMode")
3636

3737
assertInterfaceType(t, file, "MCPServerConfig")
38-
assertStructFieldType(t, file, fileSet, "MCPConfigAddRequest", "Config", "MCPServerConfig")
39-
assertStructFieldType(t, file, fileSet, "MCPConfigList", "Servers", "map[string]MCPServerConfig")
40-
assertStructFieldType(t, file, fileSet, "MCPConfigUpdateRequest", "Config", "MCPServerConfig")
38+
assertStructFieldType(t, file, fileSet, "MCPConfigAddRequest", "Config", "MCPSerializableServerConfig")
39+
assertStructFieldType(t, file, fileSet, "MCPConfigList", "Servers", "map[string]MCPSerializableServerConfig")
40+
assertStructFieldType(t, file, fileSet, "MCPConfigUpdateRequest", "Config", "MCPSerializableServerConfig")
4141
assertStructFieldType(t, file, fileSet, "MCPServerConfigHTTP", "FilterMapping", "FilterMapping")
4242
assertStructFieldType(t, file, fileSet, "MCPServerConfigStdio", "FilterMapping", "FilterMapping")
4343

java/scripts/codegen/java.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,24 @@ function normalizeBrandCasingNode(node: unknown): void {
6666
if (node === null || typeof node !== "object") return;
6767
const obj = node as Record<string, unknown>;
6868

69+
if (obj.title === "ProviderModelConfig" && obj.properties && typeof obj.properties === "object") {
70+
const tokenFields = new Set([
71+
"maxPromptTokens",
72+
"maxContextWindowTokens",
73+
"maxOutputTokens",
74+
]);
75+
for (const [key, value] of Object.entries(obj.properties as Record<string, unknown>)) {
76+
if (
77+
tokenFields.has(key) &&
78+
value !== null &&
79+
typeof value === "object" &&
80+
(value as Record<string, unknown>).type === "number"
81+
) {
82+
(value as Record<string, unknown>).type = "integer";
83+
}
84+
}
85+
}
86+
6987
for (const defsKey of ["definitions", "$defs"] as const) {
7088
const defs = obj[defsKey];
7189
if (defs && typeof defs === "object" && !Array.isArray(defs)) {

java/sdk/src/generated/java/com/github/copilot/generated/rpc/ProviderModelConfig.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ public record ProviderModelConfig(
3232
/** Display name for model pickers. Defaults to the provider-qualified selection id (`provider/id`). */
3333
@JsonProperty("name") String name,
3434
/** Maximum prompt/input tokens for the model. */
35-
@JsonProperty("maxPromptTokens") Double maxPromptTokens,
35+
@JsonProperty("maxPromptTokens") Long maxPromptTokens,
3636
/** Maximum context window tokens for the model. */
37-
@JsonProperty("maxContextWindowTokens") Double maxContextWindowTokens,
37+
@JsonProperty("maxContextWindowTokens") Long maxContextWindowTokens,
3838
/** Maximum output tokens for the model. */
39-
@JsonProperty("maxOutputTokens") Double maxOutputTokens,
39+
@JsonProperty("maxOutputTokens") Long maxOutputTokens,
4040
/** Optional capability overrides (vision, tool_calls, reasoning, etc.). */
4141
@JsonProperty("capabilities") ModelCapabilitiesOverride capabilities
4242
) {

java/sdk/src/main/java/com/github/copilot/rpc/CommandWireDefinition.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public CommandWireDefinition() {
3131
/** Creates a definition with name and description. */
3232
public CommandWireDefinition(String name, String description) {
3333
this.name = name;
34-
this.description = description;
34+
this.description = description == null ? "" : description;
3535
}
3636

3737
/** Gets the command name. @return the name */
@@ -52,7 +52,7 @@ public String getDescription() {
5252

5353
/** Sets the description. @param description the description @return this */
5454
public CommandWireDefinition setDescription(String description) {
55-
this.description = description;
55+
this.description = description == null ? "" : description;
5656
return this;
5757
}
5858
}

java/sdk/src/test/java/com/github/copilot/CommandsTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ void buildCreateRequestIncludesCommandWireDefinitions() {
9595
assertEquals("deploy", request.getCommands().get(0).getName());
9696
assertEquals("Deploy", request.getCommands().get(0).getDescription());
9797
assertEquals("rollback", request.getCommands().get(1).getName());
98-
assertNull(request.getCommands().get(1).getDescription());
98+
assertEquals("", request.getCommands().get(1).getDescription());
9999
}
100100

101101
@Test
@@ -130,11 +130,11 @@ void commandWireDefinitionHasNameAndDescription() {
130130
}
131131

132132
@Test
133-
void commandWireDefinitionNullDescriptionAllowed() {
133+
void commandWireDefinitionNormalizesNullDescription() {
134134
var wire = new CommandWireDefinition("rollback", null);
135135

136136
assertEquals("rollback", wire.getName());
137-
assertNull(wire.getDescription());
137+
assertEquals("", wire.getDescription());
138138
}
139139

140140
@Test

nodejs/src/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,7 +1569,7 @@ export class CopilotClient {
15691569
canvasProvider: config.canvasProvider,
15701570
commands: config.commands?.map((cmd) => ({
15711571
name: cmd.name,
1572-
description: cmd.description,
1572+
description: cmd.description ?? "",
15731573
})),
15741574
systemMessage: wireSystemMessage,
15751575
availableTools: toolFilterOptions.availableTools,
@@ -1827,7 +1827,7 @@ export class CopilotClient {
18271827
canvasProvider: config.canvasProvider,
18281828
commands: config.commands?.map((cmd) => ({
18291829
name: cmd.name,
1830-
description: cmd.description,
1830+
description: cmd.description ?? "",
18311831
})),
18321832
provider: bearerWireProvider,
18331833
capi: config.capi,

nodejs/test/client.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3119,7 +3119,7 @@ describe("CopilotClient", () => {
31193119
const payload = spy.mock.calls.find((c) => c[0] === "session.create")![1] as any;
31203120
expect(payload.commands).toEqual([
31213121
{ name: "deploy", description: "Deploy the app" },
3122-
{ name: "rollback", description: undefined },
3122+
{ name: "rollback", description: "" },
31233123
]);
31243124
});
31253125

python/copilot/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2454,7 +2454,7 @@ async def create_session(
24542454
# Serialize commands (name + description only) into payload
24552455
if commands:
24562456
payload["commands"] = [
2457-
{"name": cmd.name, "description": cmd.description} for cmd in commands
2457+
{"name": cmd.name, "description": cmd.description or ""} for cmd in commands
24582458
]
24592459

24602460
# Enable hooks callback if any hook handler provided
@@ -3211,7 +3211,7 @@ async def resume_session(
32113211
# Serialize commands (name + description only) into payload
32123212
if commands:
32133213
payload["commands"] = [
3214-
{"name": cmd.name, "description": cmd.description} for cmd in commands
3214+
{"name": cmd.name, "description": cmd.description or ""} for cmd in commands
32153215
]
32163216

32173217
if hooks and any(hooks.values()):

0 commit comments

Comments
 (0)