Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Sep 8, 2025

Closes #7789

Summary

This PR adds a new configuration option openAiNativeStatelessMode that allows users to globally set the OpenAI provider to stateless mode, preventing responses from being stored on OpenAI servers.

Changes

  • Added openAiNativeStatelessMode boolean option to the provider settings schema
  • Modified OpenAI native provider to check this setting and override metadata.store accordingly
  • Added comprehensive tests for the new configuration option

How to Use

Users can enable stateless mode by adding the following to their settings:

{
  "openAiNativeStatelessMode": true
}

When enabled, all OpenAI API requests will include store: false, preventing response storage on OpenAI servers. This is useful for users who prefer local state management over server-side state.

Testing

  • ✅ Added unit tests for the new configuration option
  • ✅ Tests verify proper override logic and backward compatibility
  • ✅ All existing tests pass

Notes

  • Maintains backward compatibility - default behavior unchanged unless explicitly configured
  • When openAiNativeStatelessMode is true, it overrides any per-request metadata.store settings
  • Responses in stateless mode cannot be referenced using previous_response_id

Important

Adds openAiNativeStatelessMode option to control response storage in OpenAI native provider, with tests ensuring correct behavior and backward compatibility.

  • Behavior:
    • Adds openAiNativeStatelessMode option to provider-settings.ts to control response storage in OpenAI native provider.
    • In openai-native.ts, modifies OpenAiNativeHandler to respect openAiNativeStatelessMode, setting store: false when enabled.
    • Overrides any per-request metadata.store settings when openAiNativeStatelessMode is true.
  • Testing:
    • Adds tests in openai-native.spec.ts to verify openAiNativeStatelessMode behavior.
    • Tests ensure store is set to false when openAiNativeStatelessMode is enabled and respects metadata.store when disabled.
    • Verifies backward compatibility by ensuring default behavior remains unchanged unless configured.
  • Misc:
    • Maintains backward compatibility with existing configurations.

This description was created by Ellipsis for 53df91c. You can customize this summary. It will automatically update as commits are pushed.

- Add openAiNativeStatelessMode boolean option to OpenAI Native provider settings
- Update provider to check this setting and override metadata.store accordingly
- Add comprehensive tests for the new configuration option
- Maintain backward compatibility (defaults to current behavior)

Fixes #7789
@roomote roomote bot requested review from cte, jr and mrubens as code owners September 8, 2025 18:58
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Sep 8, 2025
stream: false, // Non-streaming for completePrompt
store: false, // Don't store prompt completions
// Use stateless mode if configured, otherwise don't store prompt completions
store: this.options.openAiNativeStatelessMode ? false : false,
Copy link
Contributor

Choose a reason for hiding this comment

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

In completePrompt, the code sets the store field as:

store: this.options.openAiNativeStatelessMode ? false : false

This always yields false. If prompt completions are meant to be non-stored regardless of configuration, consider simplifying to a literal false and adding a comment to explain the rationale.

Suggested change
store: this.options.openAiNativeStatelessMode ? false : false,
\t\t\t\tstore: false, // prompt completions are never stored (see rationale above)

Copy link
Contributor Author

@roomote roomote bot left a comment

Choose a reason for hiding this comment

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

Reviewing my own code is like debugging in a mirror - everything looks backwards but the bugs are still mine.

stream: false, // Non-streaming for completePrompt
store: false, // Don't store prompt completions
// Use stateless mode if configured, otherwise don't store prompt completions
store: this.options.openAiNativeStatelessMode ? false : false,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this intentional? The expression this.options.openAiNativeStatelessMode ? false : false always evaluates to false. Could we simplify this to just store: false since prompt completions shouldn't be stored regardless of the stateless mode setting?

stream: true,
store: metadata?.store !== false, // Default to true unless explicitly set to false
// Check if stateless mode is enabled in configuration, otherwise use metadata.store
store: this.options.openAiNativeStatelessMode ? false : metadata?.store !== false,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Consider extracting the store property logic into a helper method like getStoreValue(metadata) since this same logic appears in both line 259 and line 1291. This would improve maintainability and ensure consistency.

expect(secondCallBody.previous_response_id).toBe("resp_789")
})

it("should respect openAiNativeStatelessMode configuration", async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would it be helpful to add a test case for when openAiNativeStatelessMode is true AND metadata.store is explicitly set to true? This would verify that the global setting takes precedence over per-request settings as documented.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Sep 8, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Sep 8, 2025
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Sep 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Feature: Add Configuration Option for Stateless Mode in OpenAI Provider

3 participants