Skip to content

Conversation

@christothes
Copy link
Collaborator

No description provided.

@christothes christothes marked this pull request as ready for review January 21, 2026 22:51
@@ -633,7 +633,7 @@ internal virtual CreateResponseOptions CreatePerCallOptions(CreateResponseOption
{
CreateResponseOptions clonedOptions = userProvidedOptions is null
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we consider doing a thread-static shared instance for default options rather than creating an instance per-call?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What scenario did you have in mind where we'd use the default options? My assumption is that we'll typically only clone when someone is passing in a non-default options instance.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're doing a new() if there's no custom options passed. My suggestion is to replace that with a thread-static version. We need to be able to safely mutate for this call but there's no reason why we need a fresh instance each time, is there?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, makes sense. For some reason I thought this comment was on the clone method.

@christothes christothes requested a review from jsquire January 22, 2026 16:04
@christothes christothes enabled auto-merge (squash) January 22, 2026 19:14
@christothes christothes merged commit 70f64fe into openai:main Jan 22, 2026
2 checks passed
[CodeGenType("CreateResponse")]
public partial class CreateResponseOptions
{
internal static readonly CreateResponseOptions Default = new CreateResponseOptions();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this work without being [ThreadStatic]? Won't we end up with concurrency issues because of the mutation during operations?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants