Skip to content

Commit 8f587b3

Browse files
committed
Fix generated API compatibility checks
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 812b44f2-ef93-4b32-b051-c7092f612279
1 parent 96d3c9d commit 8f587b3

5 files changed

Lines changed: 25 additions & 9 deletions

File tree

dotnet/src/Generated/SessionEvents.cs

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

python/copilot/generated/session_events.py

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/tests/e2e/rpc_session_state_extras.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ async fn should_add_byok_provider_and_model_at_runtime() {
304304
id: "small".to_string(),
305305
max_context_window_tokens: None,
306306
max_output_tokens: None,
307-
max_prompt_tokens: Some(4096.0),
307+
max_prompt_tokens: Some(4096),
308308
model_id: None,
309309
name: Some("Rust Added Model".to_string()),
310310
provider: "rust-e2e-provider".to_string(),

scripts/codegen/csharp.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1387,9 +1387,6 @@ function resolveSessionPropertyType(
13871387

13881388
function generateDataClass(variant: EventVariant, knownTypes: Map<string, string>, nestedClasses: Map<string, string>, enumOutput: string[]): string {
13891389
const dataVisibility = isSchemaInternal(variant.dataSchema) ? "internal" : "public";
1390-
if (!variant.dataSchema?.properties) return `${dataVisibility} sealed partial class ${variant.dataClassName} { }`;
1391-
1392-
const required = new Set(variant.dataSchema.required || []);
13931390
const lines: string[] = [];
13941391
if (variant.dataDescription) {
13951392
lines.push(...xmlDocComment(variant.dataDescription, ""));
@@ -1402,6 +1399,12 @@ function generateDataClass(variant: EventVariant, knownTypes: Map<string, string
14021399
if (isSchemaDeprecated(variant.dataSchema)) {
14031400
pushObsoleteAttributes(lines);
14041401
}
1402+
if (!variant.dataSchema?.properties) {
1403+
lines.push(`${dataVisibility} sealed partial class ${variant.dataClassName} { }`);
1404+
return lines.join("\n");
1405+
}
1406+
1407+
const required = new Set(variant.dataSchema.required || []);
14051408
lines.push(`${dataVisibility} sealed partial class ${variant.dataClassName}`, `{`);
14061409

14071410
for (const [propName, propSchema] of Object.entries(variant.dataSchema.properties).sort(([a], [b]) => a.localeCompare(b))) {

scripts/codegen/python.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,17 @@ function collectPythonExternalEnumNames(
201201
return enumNames;
202202
}
203203

204+
function preservePythonSessionEventConstructorOrder(schema: JSONSchema7): void {
205+
for (const definitions of [schema.definitions, schema.$defs]) {
206+
if (!definitions) continue;
207+
const customTool = definitions.PermissionRequestCustomTool;
208+
if (!customTool || typeof customTool !== "object") continue;
209+
const skipPermission = (customTool as JSONSchema7).properties?.skipPermission;
210+
if (!skipPermission || typeof skipPermission !== "object") continue;
211+
(skipPermission as Record<string, unknown>)["x-copilot-sdk-append-last"] = true;
212+
}
213+
}
214+
204215
function preservePythonRpcStringDateFields(definitions: Record<string, JSONSchema7>): void {
205216
const quotaSnapshot = definitions.AccountQuotaSnapshot;
206217
const resetDate = quotaSnapshot?.properties?.resetDate as JSONSchema7 | undefined;
@@ -2944,6 +2955,7 @@ async function generateSessionEvents(schemaPath?: string): Promise<void> {
29442955
const schema = addManagedApprovalRequiredToPermissionRequests(
29452956
(await loadSchemaJson(resolvedPath)) as JSONSchema7
29462957
);
2958+
preservePythonSessionEventConstructorOrder(schema);
29472959
const processed = propagateInternalVisibility(postProcessSchema(schema));
29482960
let code = generatePythonSessionEventsCode(processed);
29492961
const { typeNames } = collectInternalSymbols(processed);

0 commit comments

Comments
 (0)