Skip to content

Commit 3be7414

Browse files
authored
Add support for included properties (a.k.a. include) in Responses (#820)
In addition to offering the expected functionality, this change also fixes #779. That is because the failure reported in this issue is by design, and to fix it, users must request the encrypted reasoning content via the included properties like this: ```csharp ResponseCreationOptions options = new() { StoredOutputEnabled = false, IncludedProperties = { IncludedResponseProperty.ReasoningEncryptedContent } }; ``` For more context, see the following docs: > When using the Responses API in a stateless mode (either with `store` set to `false`, or when an organization is enrolled in zero data retention), you must still retain reasoning items across conversation turns using the techniques described above. But in order to have reasoning items that can be sent with subsequent API requests, each of your API requests must have `reasoning.encrypted_content` in the `include` parameter of API requests ... Any reasoning items in the `output` array will now have an `encrypted_content` property, which will contain encrypted reasoning tokens that can be passed along with future conversation turns. From: 🔗 https://platform.openai.com/docs/guides/reasoning#encrypted-reasoning-items
1 parent bfadf5c commit 3be7414

19 files changed

+2050
-1319
lines changed

api/OpenAI.net8.0.cs

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5417,6 +5417,25 @@ public class ImageGenerationToolInputImageMask : IJsonModel<ImageGenerationToolI
54175417
public override readonly string ToString();
54185418
}
54195419
[Experimental("OPENAI001")]
5420+
public readonly partial struct IncludedResponseProperty : IEquatable<IncludedResponseProperty> {
5421+
public IncludedResponseProperty(string value);
5422+
public static IncludedResponseProperty CodeInterpreterCallOutputs { get; }
5423+
public static IncludedResponseProperty ComputerCallOutputImageUri { get; }
5424+
public static IncludedResponseProperty FileSearchCallResults { get; }
5425+
public static IncludedResponseProperty MessageInputImageUri { get; }
5426+
public static IncludedResponseProperty ReasoningEncryptedContent { get; }
5427+
public readonly bool Equals(IncludedResponseProperty other);
5428+
[EditorBrowsable(EditorBrowsableState.Never)]
5429+
public override readonly bool Equals(object obj);
5430+
[EditorBrowsable(EditorBrowsableState.Never)]
5431+
public override readonly int GetHashCode();
5432+
public static bool operator ==(IncludedResponseProperty left, IncludedResponseProperty right);
5433+
public static implicit operator IncludedResponseProperty(string value);
5434+
public static implicit operator IncludedResponseProperty?(string value);
5435+
public static bool operator !=(IncludedResponseProperty left, IncludedResponseProperty right);
5436+
public override readonly string ToString();
5437+
}
5438+
[Experimental("OPENAI001")]
54205439
public class McpTool : ResponseTool, IJsonModel<McpTool>, IPersistableModel<McpTool> {
54215440
public McpTool(string serverLabel, McpToolConnectorId connectorId);
54225441
public McpTool(string serverLabel, Uri serverUri);
@@ -5637,16 +5656,16 @@ public class OpenAIResponseClient {
56375656
public virtual ClientResult<ResponseDeletionResult> DeleteResponse(string responseId, CancellationToken cancellationToken = default);
56385657
public virtual Task<ClientResult> DeleteResponseAsync(string responseId, RequestOptions options);
56395658
public virtual Task<ClientResult<ResponseDeletionResult>> DeleteResponseAsync(string responseId, CancellationToken cancellationToken = default);
5640-
public virtual ClientResult GetResponse(string responseId, bool? stream, int? startingAfter, RequestOptions options);
5641-
public virtual ClientResult<OpenAIResponse> GetResponse(string responseId, CancellationToken cancellationToken = default);
5642-
public virtual Task<ClientResult> GetResponseAsync(string responseId, bool? stream, int? startingAfter, RequestOptions options);
5643-
public virtual Task<ClientResult<OpenAIResponse>> GetResponseAsync(string responseId, CancellationToken cancellationToken = default);
5659+
public virtual ClientResult GetResponse(string responseId, IEnumerable<IncludedResponseProperty> include, bool? stream, int? startingAfter, bool? includeObfuscation, RequestOptions options);
5660+
public virtual ClientResult<OpenAIResponse> GetResponse(string responseId, IEnumerable<IncludedResponseProperty> include = null, CancellationToken cancellationToken = default);
5661+
public virtual Task<ClientResult> GetResponseAsync(string responseId, IEnumerable<IncludedResponseProperty> include, bool? stream, int? startingAfter, bool? includeObfuscation, RequestOptions options);
5662+
public virtual Task<ClientResult<OpenAIResponse>> GetResponseAsync(string responseId, IEnumerable<IncludedResponseProperty> include = null, CancellationToken cancellationToken = default);
56445663
public virtual CollectionResult<ResponseItem> GetResponseInputItems(string responseId, ResponseItemCollectionOptions options = null, CancellationToken cancellationToken = default);
56455664
public virtual CollectionResult GetResponseInputItems(string responseId, int? limit, string order, string after, string before, RequestOptions options);
56465665
public virtual AsyncCollectionResult<ResponseItem> GetResponseInputItemsAsync(string responseId, ResponseItemCollectionOptions options = null, CancellationToken cancellationToken = default);
56475666
public virtual AsyncCollectionResult GetResponseInputItemsAsync(string responseId, int? limit, string order, string after, string before, RequestOptions options);
5648-
public virtual CollectionResult<StreamingResponseUpdate> GetResponseStreaming(string responseId, int? startingAfter = null, CancellationToken cancellationToken = default);
5649-
public virtual AsyncCollectionResult<StreamingResponseUpdate> GetResponseStreamingAsync(string responseId, int? startingAfter = null, CancellationToken cancellationToken = default);
5667+
public virtual CollectionResult<StreamingResponseUpdate> GetResponseStreaming(string responseId, IEnumerable<IncludedResponseProperty> include = null, int? startingAfter = null, bool? includeObfuscation = null, CancellationToken cancellationToken = default);
5668+
public virtual AsyncCollectionResult<StreamingResponseUpdate> GetResponseStreamingAsync(string responseId, IEnumerable<IncludedResponseProperty> include = null, int? startingAfter = null, bool? includeObfuscation = null, CancellationToken cancellationToken = default);
56505669
}
56515670
[Experimental("OPENAI001")]
56525671
public static class OpenAIResponsesModelFactory {
@@ -5746,6 +5765,7 @@ public enum ResponseContentPartKind {
57465765
public class ResponseCreationOptions : IJsonModel<ResponseCreationOptions>, IPersistableModel<ResponseCreationOptions> {
57475766
public bool? BackgroundModeEnabled { get; set; }
57485767
public string EndUserId { get; set; }
5768+
public IList<IncludedResponseProperty> IncludedProperties { get; }
57495769
public string Instructions { get; set; }
57505770
public int? MaxOutputTokenCount { get; set; }
57515771
public IDictionary<string, string> Metadata { get; }

api/OpenAI.netstandard2.0.cs

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4749,6 +4749,24 @@ public class ImageGenerationToolInputImageMask : IJsonModel<ImageGenerationToolI
47494749
public static bool operator !=(ImageGenerationToolSize left, ImageGenerationToolSize right);
47504750
public override readonly string ToString();
47514751
}
4752+
public readonly partial struct IncludedResponseProperty : IEquatable<IncludedResponseProperty> {
4753+
public IncludedResponseProperty(string value);
4754+
public static IncludedResponseProperty CodeInterpreterCallOutputs { get; }
4755+
public static IncludedResponseProperty ComputerCallOutputImageUri { get; }
4756+
public static IncludedResponseProperty FileSearchCallResults { get; }
4757+
public static IncludedResponseProperty MessageInputImageUri { get; }
4758+
public static IncludedResponseProperty ReasoningEncryptedContent { get; }
4759+
public readonly bool Equals(IncludedResponseProperty other);
4760+
[EditorBrowsable(EditorBrowsableState.Never)]
4761+
public override readonly bool Equals(object obj);
4762+
[EditorBrowsable(EditorBrowsableState.Never)]
4763+
public override readonly int GetHashCode();
4764+
public static bool operator ==(IncludedResponseProperty left, IncludedResponseProperty right);
4765+
public static implicit operator IncludedResponseProperty(string value);
4766+
public static implicit operator IncludedResponseProperty?(string value);
4767+
public static bool operator !=(IncludedResponseProperty left, IncludedResponseProperty right);
4768+
public override readonly string ToString();
4769+
}
47524770
public class McpTool : ResponseTool, IJsonModel<McpTool>, IPersistableModel<McpTool> {
47534771
public McpTool(string serverLabel, McpToolConnectorId connectorId);
47544772
public McpTool(string serverLabel, Uri serverUri);
@@ -4950,16 +4968,16 @@ public class OpenAIResponseClient {
49504968
public virtual ClientResult<ResponseDeletionResult> DeleteResponse(string responseId, CancellationToken cancellationToken = default);
49514969
public virtual Task<ClientResult> DeleteResponseAsync(string responseId, RequestOptions options);
49524970
public virtual Task<ClientResult<ResponseDeletionResult>> DeleteResponseAsync(string responseId, CancellationToken cancellationToken = default);
4953-
public virtual ClientResult GetResponse(string responseId, bool? stream, int? startingAfter, RequestOptions options);
4954-
public virtual ClientResult<OpenAIResponse> GetResponse(string responseId, CancellationToken cancellationToken = default);
4955-
public virtual Task<ClientResult> GetResponseAsync(string responseId, bool? stream, int? startingAfter, RequestOptions options);
4956-
public virtual Task<ClientResult<OpenAIResponse>> GetResponseAsync(string responseId, CancellationToken cancellationToken = default);
4971+
public virtual ClientResult GetResponse(string responseId, IEnumerable<IncludedResponseProperty> include, bool? stream, int? startingAfter, bool? includeObfuscation, RequestOptions options);
4972+
public virtual ClientResult<OpenAIResponse> GetResponse(string responseId, IEnumerable<IncludedResponseProperty> include = null, CancellationToken cancellationToken = default);
4973+
public virtual Task<ClientResult> GetResponseAsync(string responseId, IEnumerable<IncludedResponseProperty> include, bool? stream, int? startingAfter, bool? includeObfuscation, RequestOptions options);
4974+
public virtual Task<ClientResult<OpenAIResponse>> GetResponseAsync(string responseId, IEnumerable<IncludedResponseProperty> include = null, CancellationToken cancellationToken = default);
49574975
public virtual CollectionResult<ResponseItem> GetResponseInputItems(string responseId, ResponseItemCollectionOptions options = null, CancellationToken cancellationToken = default);
49584976
public virtual CollectionResult GetResponseInputItems(string responseId, int? limit, string order, string after, string before, RequestOptions options);
49594977
public virtual AsyncCollectionResult<ResponseItem> GetResponseInputItemsAsync(string responseId, ResponseItemCollectionOptions options = null, CancellationToken cancellationToken = default);
49604978
public virtual AsyncCollectionResult GetResponseInputItemsAsync(string responseId, int? limit, string order, string after, string before, RequestOptions options);
4961-
public virtual CollectionResult<StreamingResponseUpdate> GetResponseStreaming(string responseId, int? startingAfter = null, CancellationToken cancellationToken = default);
4962-
public virtual AsyncCollectionResult<StreamingResponseUpdate> GetResponseStreamingAsync(string responseId, int? startingAfter = null, CancellationToken cancellationToken = default);
4979+
public virtual CollectionResult<StreamingResponseUpdate> GetResponseStreaming(string responseId, IEnumerable<IncludedResponseProperty> include = null, int? startingAfter = null, bool? includeObfuscation = null, CancellationToken cancellationToken = default);
4980+
public virtual AsyncCollectionResult<StreamingResponseUpdate> GetResponseStreamingAsync(string responseId, IEnumerable<IncludedResponseProperty> include = null, int? startingAfter = null, bool? includeObfuscation = null, CancellationToken cancellationToken = default);
49634981
}
49644982
public static class OpenAIResponsesModelFactory {
49654983
public static MessageResponseItem MessageResponseItem(string id = null, MessageRole role = MessageRole.Assistant, MessageStatus? status = null);
@@ -5048,6 +5066,7 @@ public enum ResponseContentPartKind {
50485066
public class ResponseCreationOptions : IJsonModel<ResponseCreationOptions>, IPersistableModel<ResponseCreationOptions> {
50495067
public bool? BackgroundModeEnabled { get; set; }
50505068
public string EndUserId { get; set; }
5069+
public IList<IncludedResponseProperty> IncludedProperties { get; }
50515070
public string Instructions { get; set; }
50525071
public int? MaxOutputTokenCount { get; set; }
50535072
public IDictionary<string, string> Metadata { get; }

specification/base/typespec/responses/operations.tsp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,19 @@ interface Responses {
3636
@route("{response_id}")
3737
getResponse(
3838
@path
39-
@example("resp_677efb5139a88190b512bc3fef8e535d")
4039
response_id: string,
4140

4241
@query(#{ name: "include[]", explode: true })
43-
includables?: Includable[] = #[],
42+
include?: Includable[],
43+
44+
@query(#{ explode: true })
45+
stream?: boolean,
46+
47+
@query(#{ explode: true })
48+
starting_after?: int32,
4449

45-
@query stream?: boolean = false,
46-
@query starting_after?: int32,
50+
@query(#{ explode: true })
51+
include_obfuscation?: boolean,
4752
): Response | SseResponseOf<ResponseStreamEvent> | ResponseErrorResponse;
4853

4954
@delete
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace OpenAI.Responses;
2+
3+
[CodeGenType("Includable")]
4+
public readonly partial struct IncludedResponseProperty
5+
{
6+
[CodeGenMember("MessageInputImageImageUrl")]
7+
public static IncludedResponseProperty MessageInputImageUri { get; } = new IncludedResponseProperty(MessageInputImageImageUrlValue);
8+
9+
[CodeGenMember("ComputerCallOutputOutputImageUrl")]
10+
public static IncludedResponseProperty ComputerCallOutputImageUri { get; } = new IncludedResponseProperty(ComputerCallOutputOutputImageUrlValue);
11+
}

src/Custom/Responses/Internal/InternalIncludable.cs

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/Custom/Responses/OpenAIResponseClient.Protocol.cs

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)