Skip to content

Commit 03bb2eb

Browse files
Better type info for result
Co-Authored-By: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 1521ab2 commit 03bb2eb

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

dotnet/src/Generated/Rpc.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,11 +374,26 @@ internal class SessionAgentListRequest
374374
public string SessionId { get; set; } = string.Empty;
375375
}
376376

377+
public class SessionAgentGetCurrentResultAgent
378+
{
379+
/// <summary>Unique identifier of the custom agent</summary>
380+
[JsonPropertyName("name")]
381+
public string Name { get; set; } = string.Empty;
382+
383+
/// <summary>Human-readable display name</summary>
384+
[JsonPropertyName("displayName")]
385+
public string DisplayName { get; set; } = string.Empty;
386+
387+
/// <summary>Description of the agent's purpose</summary>
388+
[JsonPropertyName("description")]
389+
public string Description { get; set; } = string.Empty;
390+
}
391+
377392
public class SessionAgentGetCurrentResult
378393
{
379394
/// <summary>Currently selected custom agent, or null if using the default agent</summary>
380395
[JsonPropertyName("agent")]
381-
public object? Agent { get; set; }
396+
public SessionAgentGetCurrentResultAgent? Agent { get; set; }
382397
}
383398

384399
internal class SessionAgentGetCurrentRequest
@@ -794,6 +809,7 @@ public async Task<SessionCompactionCompactResult> CompactAsync(CancellationToken
794809
[JsonSerializable(typeof(SessionAgentDeselectResult))]
795810
[JsonSerializable(typeof(SessionAgentGetCurrentRequest))]
796811
[JsonSerializable(typeof(SessionAgentGetCurrentResult))]
812+
[JsonSerializable(typeof(SessionAgentGetCurrentResultAgent))]
797813
[JsonSerializable(typeof(SessionAgentListRequest))]
798814
[JsonSerializable(typeof(SessionAgentListResult))]
799815
[JsonSerializable(typeof(SessionAgentSelectRequest))]

dotnet/test/AgentAndCompactRpcTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ public async Task Should_Select_And_Get_Current_Agent()
8989
// Verify getCurrent returns the selected agent
9090
var currentResult = await session.Rpc.Agent.GetCurrentAsync();
9191
Assert.NotNull(currentResult.Agent);
92+
Assert.Equal("test-agent", currentResult.Agent.Name);
9293
}
9394

9495
[Fact]

scripts/codegen/csharp.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,14 @@ function singularPascal(s: string): string {
467467
}
468468

469469
function resolveRpcType(schema: JSONSchema7, isRequired: boolean, parentClassName: string, propName: string, classes: string[]): string {
470+
// Handle anyOf: [T, null] → T? (nullable typed property)
471+
if (schema.anyOf) {
472+
const hasNull = schema.anyOf.some((s) => typeof s === "object" && (s as JSONSchema7).type === "null");
473+
const nonNull = schema.anyOf.filter((s) => typeof s === "object" && (s as JSONSchema7).type !== "null");
474+
if (nonNull.length === 1) {
475+
return resolveRpcType(nonNull[0] as JSONSchema7, isRequired && !hasNull, parentClassName, propName, classes);
476+
}
477+
}
470478
// Handle enums (string unions like "interactive" | "plan" | "autopilot")
471479
if (schema.enum && Array.isArray(schema.enum)) {
472480
const enumName = getOrCreateEnum(parentClassName, propName, schema.enum as string[], rpcEnumOutput);

0 commit comments

Comments
 (0)