diff --git a/dotnet/src/Generated/SessionEvents.cs b/dotnet/src/Generated/SessionEvents.cs index 996f3f010..dfdaf2178 100644 --- a/dotnet/src/Generated/SessionEvents.cs +++ b/dotnet/src/Generated/SessionEvents.cs @@ -119,6 +119,11 @@ public partial class SessionEvent [JsonPropertyName("ephemeral")] public bool? Ephemeral { get; set; } + /// Sub-agent instance identifier. Absent for events from the root/main agent and session-level events. + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + [JsonPropertyName("agentId")] + public string? AgentId { get; set; } + /// /// The event type discriminator. /// diff --git a/dotnet/test/ForwardCompatibilityTests.cs b/dotnet/test/ForwardCompatibilityTests.cs index d3f5b7785..8b61868b5 100644 --- a/dotnet/test/ForwardCompatibilityTests.cs +++ b/dotnet/test/ForwardCompatibilityTests.cs @@ -97,4 +97,41 @@ public void SessionEvent_Type_DefaultsToUnknown() Assert.Equal("unknown", evt.Type); } + + [Fact] + public void FromJson_WithAgentId_DeserializesAgentId() + { + var json = """ + { + "id": "12345678-1234-1234-1234-123456789abc", + "timestamp": "2026-06-15T10:30:00Z", + "parentId": null, + "agentId": "sub-agent-42", + "type": "future.feature_from_server", + "data": {} + } + """; + + var result = SessionEvent.FromJson(json); + + Assert.Equal("sub-agent-42", result.AgentId); + } + + [Fact] + public void FromJson_WithoutAgentId_AgentIdIsNull() + { + var json = """ + { + "id": "12345678-1234-1234-1234-123456789abc", + "timestamp": "2026-06-15T10:30:00Z", + "parentId": null, + "type": "future.feature_from_server", + "data": {} + } + """; + + var result = SessionEvent.FromJson(json); + + Assert.Null(result.AgentId); + } } diff --git a/scripts/codegen/csharp.ts b/scripts/codegen/csharp.ts index 9c8332c09..01bd29cca 100644 --- a/scripts/codegen/csharp.ts +++ b/scripts/codegen/csharp.ts @@ -739,6 +739,8 @@ namespace GitHub.Copilot.SDK; lines.push(` [JsonPropertyName("parentId")]`, ` public Guid? ParentId { get; set; }`, ""); lines.push(...xmlDocComment(baseDesc("ephemeral"), " ")); lines.push(` [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]`, ` [JsonPropertyName("ephemeral")]`, ` public bool? Ephemeral { get; set; }`, ""); + lines.push(...xmlDocComment(baseDesc("agentId"), " ")); + lines.push(` [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]`, ` [JsonPropertyName("agentId")]`, ` public string? AgentId { get; set; }`, ""); lines.push(` /// `, ` /// The event type discriminator.`, ` /// `); lines.push(` [JsonIgnore]`, ` public virtual string Type => "unknown";`, ""); lines.push(` /// Deserializes a JSON string into a .`);