Skip to content

Commit 3daa147

Browse files
stephentoubCopilot
andcommitted
Fix generated type collisions after Copilot update
Remove handwritten ContextTier definitions now owned by generated schema types, update Attachment type references, and keep generated outputs in sync. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent b923719 commit 3daa147

18 files changed

Lines changed: 124 additions & 148 deletions

File tree

docs/features/image-input.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func main() {
120120
session.Send(ctx, copilot.MessageOptions{
121121
Prompt: "Describe what you see in this image",
122122
Attachments: []copilot.Attachment{
123-
&copilot.UserMessageAttachmentFile{
123+
&copilot.AttachmentFile{
124124
DisplayName: "screenshot.png",
125125
Path: path,
126126
},
@@ -146,7 +146,7 @@ path := "/absolute/path/to/screenshot.png"
146146
session.Send(ctx, copilot.MessageOptions{
147147
Prompt: "Describe what you see in this image",
148148
Attachments: []copilot.Attachment{
149-
&copilot.UserMessageAttachmentFile{
149+
&copilot.AttachmentFile{
150150
DisplayName: "screenshot.png",
151151
Path: path,
152152
},
@@ -179,9 +179,9 @@ public static class ImageInputExample
179179
await session.SendAsync(new MessageOptions
180180
{
181181
Prompt = "Describe what you see in this image",
182-
Attachments = new List<UserMessageAttachment>
182+
Attachments = new List<Attachment>
183183
{
184-
new UserMessageAttachmentFile
184+
new AttachmentFile
185185
{
186186
Path = "/absolute/path/to/screenshot.png",
187187
DisplayName = "screenshot.png",
@@ -208,9 +208,9 @@ await using var session = await client.CreateSessionAsync(new SessionConfig
208208
await session.SendAsync(new MessageOptions
209209
{
210210
Prompt = "Describe what you see in this image",
211-
Attachments = new List<UserMessageAttachment>
211+
Attachments = new List<Attachment>
212212
{
213-
new UserMessageAttachmentFile
213+
new AttachmentFile
214214
{
215215
Path = "/absolute/path/to/screenshot.png",
216216
DisplayName = "screenshot.png",
@@ -344,7 +344,7 @@ func main() {
344344
session.Send(ctx, copilot.MessageOptions{
345345
Prompt: "Describe what you see in this image",
346346
Attachments: []copilot.Attachment{
347-
&copilot.UserMessageAttachmentBlob{
347+
&copilot.AttachmentBlob{
348348
Data: base64ImageData,
349349
MIMEType: mimeType,
350350
DisplayName: &displayName,
@@ -361,7 +361,7 @@ displayName := "screenshot.png"
361361
session.Send(ctx, copilot.MessageOptions{
362362
Prompt: "Describe what you see in this image",
363363
Attachments: []copilot.Attachment{
364-
&copilot.UserMessageAttachmentBlob{
364+
&copilot.AttachmentBlob{
365365
Data: base64ImageData, // base64-encoded string
366366
MIMEType: mimeType,
367367
DisplayName: &displayName,
@@ -396,9 +396,9 @@ public static class BlobAttachmentExample
396396
await session.SendAsync(new MessageOptions
397397
{
398398
Prompt = "Describe what you see in this image",
399-
Attachments = new List<UserMessageAttachment>
399+
Attachments = new List<Attachment>
400400
{
401-
new UserMessageAttachmentBlob
401+
new AttachmentBlob
402402
{
403403
Data = base64ImageData,
404404
MimeType = "image/png",
@@ -415,9 +415,9 @@ public static class BlobAttachmentExample
415415
await session.SendAsync(new MessageOptions
416416
{
417417
Prompt = "Describe what you see in this image",
418-
Attachments = new List<UserMessageAttachment>
418+
Attachments = new List<Attachment>
419419
{
420-
new UserMessageAttachmentBlob
420+
new AttachmentBlob
421421
{
422422
Data = base64ImageData,
423423
MimeType = "image/png",

dotnet/src/Session.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1705,7 +1705,7 @@ internal record SendMessageRequest
17051705
public string SessionId { get; init; } = string.Empty;
17061706
public string Prompt { get; init; } = string.Empty;
17071707
public string? DisplayPrompt { get; init; }
1708-
public IList<UserMessageAttachment>? Attachments { get; init; }
1708+
public IList<Attachment>? Attachments { get; init; }
17091709
public string? Mode { get; init; }
17101710
[JsonPropertyName("agentMode")]
17111711
public AgentMode? AgentMode { get; init; }
@@ -1776,7 +1776,7 @@ internal void ThrowIfDisposed()
17761776
[JsonSerializable(typeof(SessionStartHookOutput))]
17771777
[JsonSerializable(typeof(SystemMessageTransformRpcResponse))]
17781778
[JsonSerializable(typeof(SystemMessageTransformSection))]
1779-
[JsonSerializable(typeof(UserMessageAttachment))]
1779+
[JsonSerializable(typeof(Attachment))]
17801780
[JsonSerializable(typeof(UserPromptSubmittedHookInput))]
17811781
[JsonSerializable(typeof(UserPromptSubmittedHookOutput))]
17821782
internal partial class SessionJsonContext : JsonSerializerContext;

dotnet/src/Types.cs

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2390,65 +2390,6 @@ public sealed class CloudSessionOptions
23902390
public CloudSessionRepository? Repository { get; set; }
23912391
}
23922392

2393-
/// <summary>
2394-
/// Context window tier for models that support tiered context windows.
2395-
/// </summary>
2396-
[JsonConverter(typeof(ContextTier.Converter))]
2397-
[DebuggerDisplay("{Value,nq}")]
2398-
public readonly struct ContextTier : IEquatable<ContextTier>
2399-
{
2400-
private readonly string? _value;
2401-
2402-
/// <summary>Initializes a new instance of the <see cref="ContextTier"/> struct.</summary>
2403-
/// <param name="value">The value to associate with this <see cref="ContextTier"/>.</param>
2404-
[JsonConstructor]
2405-
public ContextTier(string value)
2406-
{
2407-
ArgumentException.ThrowIfNullOrWhiteSpace(value);
2408-
_value = value;
2409-
}
2410-
2411-
/// <summary>Gets the value associated with this <see cref="ContextTier"/>.</summary>
2412-
public string Value => _value ?? string.Empty;
2413-
2414-
/// <summary>Default context tier with standard context window size.</summary>
2415-
public static ContextTier Default { get; } = new("default");
2416-
2417-
/// <summary>Extended context tier with a larger context window.</summary>
2418-
public static ContextTier LongContext { get; } = new("long_context");
2419-
2420-
/// <summary>Returns a value indicating whether two <see cref="ContextTier"/> instances are equivalent.</summary>
2421-
public static bool operator ==(ContextTier left, ContextTier right) => left.Equals(right);
2422-
2423-
/// <summary>Returns a value indicating whether two <see cref="ContextTier"/> instances are not equivalent.</summary>
2424-
public static bool operator !=(ContextTier left, ContextTier right) => !left.Equals(right);
2425-
2426-
/// <inheritdoc/>
2427-
public override bool Equals([NotNullWhen(true)] object? obj) => obj is ContextTier other && Equals(other);
2428-
2429-
/// <inheritdoc/>
2430-
public bool Equals(ContextTier other) => string.Equals(Value, other.Value, StringComparison.OrdinalIgnoreCase);
2431-
2432-
/// <inheritdoc/>
2433-
public override int GetHashCode() => StringComparer.OrdinalIgnoreCase.GetHashCode(Value);
2434-
2435-
/// <inheritdoc/>
2436-
public override string ToString() => Value;
2437-
2438-
/// <summary>Provides a <see cref="JsonConverter{ContextTier}"/> for serializing <see cref="ContextTier"/> instances.</summary>
2439-
[EditorBrowsable(EditorBrowsableState.Never)]
2440-
public sealed class Converter : JsonConverter<ContextTier>
2441-
{
2442-
/// <inheritdoc/>
2443-
public override ContextTier Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) =>
2444-
new(GeneratedStringEnumJson.ReadValue(ref reader, typeToConvert));
2445-
2446-
/// <inheritdoc/>
2447-
public override void Write(Utf8JsonWriter writer, ContextTier value, JsonSerializerOptions options) =>
2448-
GeneratedStringEnumJson.WriteValue(writer, value.Value, typeof(ContextTier));
2449-
}
2450-
}
2451-
24522393
/// <summary>
24532394
/// Shared configuration properties for creating or resuming a Copilot session.
24542395
/// Use <see cref="SessionConfig"/> when creating a new session, or
@@ -3058,7 +2999,7 @@ private MessageOptions(MessageOptions? other)
30582999
/// <summary>
30593000
/// File or data attachments to include with the message.
30603001
/// </summary>
3061-
public IList<UserMessageAttachment>? Attachments { get; set; }
3002+
public IList<Attachment>? Attachments { get; set; }
30623003
/// <summary>
30633004
/// How to deliver the message. <c>"enqueue"</c> (default) appends to the message queue;
30643005
/// <c>"immediate"</c> interjects during an in-progress turn.

dotnet/test/E2E/SessionConfigE2ETests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ await session.SendAndWaitAsync(new MessageOptions
492492
Prompt = "What color is this pixel? Reply in one word.",
493493
Attachments =
494494
[
495-
new UserMessageAttachmentBlob
495+
new AttachmentBlob
496496
{
497497
Data = pngBase64,
498498
MimeType = "image/png",
@@ -517,7 +517,7 @@ await session.SendAndWaitAsync(new MessageOptions
517517
Prompt = "Summarize the attached file",
518518
Attachments =
519519
[
520-
new UserMessageAttachmentFile
520+
new AttachmentFile
521521
{
522522
Path = attachedPath,
523523
DisplayName = "attached.txt",

dotnet/test/E2E/SessionE2ETests.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ await session.SendAndWaitAsync(new MessageOptions
715715
Prompt = "Describe this image",
716716
Attachments =
717717
[
718-
new UserMessageAttachmentBlob
718+
new AttachmentBlob
719719
{
720720
Data = pngBase64,
721721
MimeType = "image/png",
@@ -740,17 +740,17 @@ await session.SendAndWaitAsync(new MessageOptions
740740
Prompt = "Read the attached file and reply with its contents.",
741741
Attachments =
742742
[
743-
new UserMessageAttachmentFile
743+
new AttachmentFile
744744
{
745745
DisplayName = "attached-file.txt",
746746
Path = filePath,
747-
LineRange = new UserMessageAttachmentFileLineRange { Start = 1, End = 1 },
747+
LineRange = new AttachmentFileLineRange { Start = 1, End = 1 },
748748
},
749749
],
750750
});
751751

752752
var userMessage = (await session.GetEventsAsync()).OfType<UserMessageEvent>().Last();
753-
var attachment = Assert.IsType<UserMessageAttachmentFile>(Assert.Single(userMessage.Data.Attachments!));
753+
var attachment = Assert.IsType<AttachmentFile>(Assert.Single(userMessage.Data.Attachments!));
754754
Assert.Equal("attached-file.txt", attachment.DisplayName);
755755
Assert.Equal(filePath, attachment.Path);
756756
Assert.Equal(1, attachment.LineRange!.Start);
@@ -771,7 +771,7 @@ await session.SendAndWaitAsync(new MessageOptions
771771
Prompt = "List the attached directory.",
772772
Attachments =
773773
[
774-
new UserMessageAttachmentDirectory
774+
new AttachmentDirectory
775775
{
776776
DisplayName = "attached-directory",
777777
Path = directoryPath,
@@ -780,7 +780,7 @@ await session.SendAndWaitAsync(new MessageOptions
780780
});
781781

782782
var userMessage = (await session.GetEventsAsync()).OfType<UserMessageEvent>().Last();
783-
var attachment = Assert.IsType<UserMessageAttachmentDirectory>(Assert.Single(userMessage.Data.Attachments!));
783+
var attachment = Assert.IsType<AttachmentDirectory>(Assert.Single(userMessage.Data.Attachments!));
784784
Assert.Equal("attached-directory", attachment.DisplayName);
785785
Assert.Equal(directoryPath, attachment.Path);
786786
}
@@ -798,22 +798,22 @@ await session.SendAndWaitAsync(new MessageOptions
798798
Prompt = "Summarize the selected code.",
799799
Attachments =
800800
[
801-
new UserMessageAttachmentSelection
801+
new AttachmentSelection
802802
{
803803
DisplayName = "selected-file.cs",
804804
FilePath = filePath,
805805
Text = "string Value = \"SELECTION_SENTINEL\";",
806-
Selection = new UserMessageAttachmentSelectionDetails
806+
Selection = new AttachmentSelectionDetails
807807
{
808-
Start = new UserMessageAttachmentSelectionDetailsStart { Line = 1, Character = 10 },
809-
End = new UserMessageAttachmentSelectionDetailsEnd { Line = 1, Character = 45 },
808+
Start = new AttachmentSelectionDetailsStart { Line = 1, Character = 10 },
809+
End = new AttachmentSelectionDetailsEnd { Line = 1, Character = 45 },
810810
},
811811
},
812812
],
813813
});
814814

815815
var userMessage = (await session.GetEventsAsync()).OfType<UserMessageEvent>().Last();
816-
var attachment = Assert.IsType<UserMessageAttachmentSelection>(Assert.Single(userMessage.Data.Attachments!));
816+
var attachment = Assert.IsType<AttachmentSelection>(Assert.Single(userMessage.Data.Attachments!));
817817
Assert.Equal("selected-file.cs", attachment.DisplayName);
818818
Assert.Equal(filePath, attachment.FilePath);
819819
Assert.Equal("string Value = \"SELECTION_SENTINEL\";", attachment.Text);
@@ -833,10 +833,10 @@ await session.SendAndWaitAsync(new MessageOptions
833833
Prompt = "Using only the GitHub reference metadata in this message, summarize the reference. Do not call any tools.",
834834
Attachments =
835835
[
836-
new UserMessageAttachmentGithubReference
836+
new AttachmentGithubReference
837837
{
838838
Number = 1234,
839-
ReferenceType = UserMessageAttachmentGithubReferenceType.Issue,
839+
ReferenceType = AttachmentGithubReferenceType.Issue,
840840
State = "open",
841841
Title = "Add E2E attachment coverage",
842842
Url = "https://github.com/github/copilot-sdk/issues/1234",
@@ -845,9 +845,9 @@ await session.SendAndWaitAsync(new MessageOptions
845845
});
846846

847847
var userMessage = (await session.GetEventsAsync()).OfType<UserMessageEvent>().Last();
848-
var attachment = Assert.IsType<UserMessageAttachmentGithubReference>(Assert.Single(userMessage.Data.Attachments!));
848+
var attachment = Assert.IsType<AttachmentGithubReference>(Assert.Single(userMessage.Data.Attachments!));
849849
Assert.Equal(1234, attachment.Number);
850-
Assert.Equal(UserMessageAttachmentGithubReferenceType.Issue, attachment.ReferenceType);
850+
Assert.Equal(AttachmentGithubReferenceType.Issue, attachment.ReferenceType);
851851
Assert.Equal("open", attachment.State);
852852
Assert.Equal("Add E2E attachment coverage", attachment.Title);
853853
Assert.Equal("https://github.com/github/copilot-sdk/issues/1234", attachment.Url);

dotnet/test/Unit/CloneTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ public void MessageOptions_Clone_CopiesAllProperties()
231231
var original = new MessageOptions
232232
{
233233
Prompt = "Hello",
234-
Attachments = [new UserMessageAttachmentFile { Path = "/test.txt", DisplayName = "test.txt" }],
234+
Attachments = [new AttachmentFile { Path = "/test.txt", DisplayName = "test.txt" }],
235235
Mode = "chat",
236236
};
237237

@@ -247,12 +247,12 @@ public void MessageOptions_Clone_AttachmentsAreIndependent()
247247
{
248248
var original = new MessageOptions
249249
{
250-
Attachments = [new UserMessageAttachmentFile { Path = "/test.txt", DisplayName = "test.txt" }],
250+
Attachments = [new AttachmentFile { Path = "/test.txt", DisplayName = "test.txt" }],
251251
};
252252

253253
var clone = original.Clone();
254254

255-
clone.Attachments!.Add(new UserMessageAttachmentFile { Path = "/other.txt", DisplayName = "other.txt" });
255+
clone.Attachments!.Add(new AttachmentFile { Path = "/other.txt", DisplayName = "other.txt" });
256256

257257
Assert.Single(original.Attachments!);
258258
}

go/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ The SDK supports image attachments via the `Attachments` field in `MessageOption
253253
_, err = session.Send(context.Background(), copilot.MessageOptions{
254254
Prompt: "What's in this image?",
255255
Attachments: []copilot.Attachment{
256-
&copilot.UserMessageAttachmentFile{
256+
&copilot.AttachmentFile{
257257
DisplayName: "image.jpg",
258258
Path: "/path/to/image.jpg",
259259
},
@@ -265,7 +265,7 @@ mimeType := "image/png"
265265
_, err = session.Send(context.Background(), copilot.MessageOptions{
266266
Prompt: "What's in this image?",
267267
Attachments: []copilot.Attachment{
268-
&copilot.UserMessageAttachmentBlob{
268+
&copilot.AttachmentBlob{
269269
Data: base64ImageData,
270270
MIMEType: mimeType,
271271
},

go/internal/e2e/rpc_event_log_e2e_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func TestRpcEventLogE2E(t *testing.T) {
2929
waitForRPCCondition(t, rpcEventLogTimeout, "persisted session.plan_changed event", func() (bool, error) {
3030
var err error
3131
read, err = session.RPC.EventLog.Read(t.Context(), &rpc.EventLogReadRequest{
32-
Max: rpcPtr(int32(100)),
32+
Max: rpcPtr(int64(100)),
3333
WaitMs: rpcPtr(int32(0)),
3434
})
3535
if err != nil {
@@ -67,7 +67,7 @@ func TestRpcEventLogE2E(t *testing.T) {
6767
}
6868
read, err = session.RPC.EventLog.Read(t.Context(), &rpc.EventLogReadRequest{
6969
Cursor: &tail.Cursor,
70-
Max: rpcPtr(int32(10)),
70+
Max: rpcPtr(int64(10)),
7171
WaitMs: rpcPtr(int32(0)),
7272
})
7373
return err == nil && read.CursorStatus == rpc.EventsCursorStatusOk && len(read.Events) == 0, err
@@ -131,7 +131,7 @@ func TestRpcEventLogE2E(t *testing.T) {
131131
go func() {
132132
result, err := session.RPC.EventLog.Read(t.Context(), &rpc.EventLogReadRequest{
133133
Cursor: &tail.Cursor,
134-
Max: rpcPtr(int32(10)),
134+
Max: rpcPtr(int64(10)),
135135
WaitMs: rpcPtr(int32(5000)),
136136
Types: &rpc.EventLogTypes{StringArray: []string{string(copilot.SessionEventTypeSessionTitleChanged)}},
137137
})

0 commit comments

Comments
 (0)