Skip to content

Factor Responses into its own assembly#889

Open
christothes wants to merge 42 commits intoopenai:mainfrom
christothes:chriss/module-refactor
Open

Factor Responses into its own assembly#889
christothes wants to merge 42 commits intoopenai:mainfrom
christothes:chriss/module-refactor

Conversation

@christothes
Copy link
Copy Markdown
Collaborator

No description provided.

Copy link
Copy Markdown
Collaborator

@jsquire jsquire left a comment

Choose a reason for hiding this comment

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

I've got a PR out to move the repository configuration and package management to a centralized version, which would remove a lot of the redundancies that you needed in the project files and such.

Comment thread src/Shared/debug.targets Outdated
Comment thread tests/Responses/OpenAI.Responses.Tests.csproj Outdated
@christothes christothes marked this pull request as ready for review January 22, 2026 20:44
Comment thread src/Custom/Responses/OpenAIContext.Definition.cs Outdated
Comment thread src/Custom/TypeForwarding.cs Outdated
Comment thread src/Shared/OpenAI.Shared.csproj Outdated
@christothes christothes force-pushed the chriss/module-refactor branch from eb86e8b to c6532a5 Compare February 4, 2026 16:08
Comment thread api/OpenAI.Responses.netstandard2.0.cs Outdated
Comment thread scripts/Export-Api.ps1
@@ -84,11 +85,30 @@ if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: Edit the error message to something like "GenAPI failed for OpenAI with exit code $LASTEXITCODE" to differentiate it from failing for OpenAI.Responses.

Comment thread examples/OpenAI.Examples.csproj Outdated
Comment thread scripts/Export-Api.ps1
if ($LASTEXITCODE -ne 0) {
Write-Error "GenAPI failed for OpenAI.Responses with exit code $LASTEXITCODE"
exit $LASTEXITCODE
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I see that the API listings for OpenAI still contain all the stuff from OpenAI.Responses, and I wonder if it would be preferable to not modify this script. I'm thinking it might be better to not produce individual API listings for Responses for a few reasons:

  1. It feels redundant.
  2. It sets the precedent of having to modify this script every time we split a library out of the base library.
  3. It adds at least some latency to this script (which is already a little slow).

In general, if our infra can continue to work without modifications, I think that would be ideal. I'm thinking of this script, but I'm also thinking of other validation scripts (Test-ApiCompatibility.ps1, Test-AotCompatibility.ps1, etc.), as well as our pipelines.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I think as we have new assemblies it's important to understand if there are any differences between what shows up in the main assembly and what shows up in the sub-assembly. I think it will always be true that the main assembly will contain everything, but it's not always clear what subset would be available in the subassembly.

@@ -0,0 +1,57 @@
<Project Sdk="Microsoft.NET.Sdk">
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Are there benefits to splitting the OpenAI.Tests project too, or is it reasonable to keep it unchanged? If keeping one single project works fine, I would strongly prefer that for simplicity. Otherwise, I worry that this will be difficult to scale and impact our productivity.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is to validate that tests still pass when loading just the subassembly and not the main assembly.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I agree that this is valuable. Can we think of an alternative that allows us to get this benefit in some way that does not require maintaining separate projects and separate test infrastructure for each new library that we onboard? I'm a little worried because I'm envisioning a nearby future where we have over a dozen libraries, and the cost of standing up test infra for each, along with modifying pipelines, scripts, etc. and then maintaining all of it will hinder us.

I'm thinking about it in the following way: Because the OpenAI library is by design just a passthrough for the OpenAI.Responses library, testing OpenAI.Responses through OpenAI is a valid way of testing its functionality. Then, the question changes from "does this work at all?" to "can we validate that this is all actually coming from OpenAI.Responses?". The funny part is that because all the functionality related to the Responses API must be in OpenAI.Responses and we must not put any of it in OpenAI by design, the answer is technically an automatic "yes" by definition. So while I agree that this validation would be good to have to ensure that we don't accidentally break our design somehow, it also feels a little superfluous and makes the trade-off in complexity a bit of a hard pill to swallow. 😕

What could be considered a "good enough" way to validate that the functionality is actually coming from OpenAI.Responses? I'm even considering something like the following: "What if we had a job in our nightly pipeline that checks out main, deletes everything in the test project except Responses, swaps the dependency from OpenAI to OpenAI.Responses, and runs the recorded tests?". While a solution like this is still something that we will need to maintain, maintaining a single pipeline job is simpler compared to multiple test projects and test infras. It would be entirely isolated in a single YAML file, and because we're delegating the validation to a pipeline, we can basically forget about it during our day-to-day work. Am I crazy? 🤔

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Let me see what I can do to improve it - worst case we can rely on just the main assembly

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Just pushed an update that refactors things a bit to minimize duplication. Let me know if this looks ok to you.

Comment thread tests/Responses/ResponseStoreTests.cs Outdated
Comment thread tests/Responses/ResponsesTests.cs Outdated
Comment thread README.md Outdated
Comment thread Directory.Packages.props Outdated
Comment thread Directory.Build.props Outdated
[ModelReaderWriterBuildable(typeof(WebSearchToolApproximateLocation))]
[ModelReaderWriterBuildable(typeof(WebSearchToolFilters))]
[ModelReaderWriterBuildable(typeof(WebSearchToolLocation))]
public partial class ResponsesModelContext
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This should be auto-generated.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Are you suggesting we do this via a Visitor or something like that? We can certainly do that longer term.


namespace OpenAI.Responses.Internal
{
internal partial class OpenAIError
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Question: The name of this file says "Generated", but it's not in the Generated folder. Is this file generated or is it a custom copy of a generated file?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

custom copy.

/// as the specified <see cref="OpenAIClientOptions"/>.
/// </summary>
/// <returns> A new <see cref="ResponsesClientOptions"/> with the same property values. </returns>
internal ResponsesClientOptions ToResponsesClientOptionss()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
internal ResponsesClientOptions ToResponsesClientOptionss()
internal ResponsesClientOptions ToResponsesClientOptions()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should these methods move to the Responses assembly as extension methods?

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.

5 participants