Skip to content

fix(memory): allow base session settings overrides for subclasses - #4842

Open
Hughhhhcoder wants to merge 2 commits into
openai:mainfrom
Hughhhhcoder:codex/openai-agents-session-settings
Open

fix(memory): allow base session settings overrides for subclasses#4842
Hughhhhcoder wants to merge 2 commits into
openai:mainfrom
Hughhhhcoder:codex/openai-agents-session-settings

Conversation

@Hughhhhcoder

Copy link
Copy Markdown
Contributor

Fixes #4819

Bug

A session configured with a SessionSettings subclass cannot be used with a RunConfig session-settings override. The run fails with a TypeError when RunConfig provides a base SessionSettings instance (including the dict form, which RunConfig normalizes to the base type).

Root cause

SessionSettings.resolve() coerced every non-dict override to type(self), rejecting a valid base SessionSettings instance. It also read subclass-only fields without a default, so a base override could not be overlaid onto a subclass.

Fix

  • Accept any existing SessionSettings instance when resolving an override, matching the existing ModelSettings behavior.
  • Read fields with a None default so base settings can be applied while preserving subclass-specific values.
  • Add a regression test covering a subclass receiving a RunConfig-normalized base override.

Validation

  • pytest -q tests/memory (204 passed)
  • pytest -q tests/memory/test_session.py tests/test_run_config.py tests/memory/test_session_limit.py tests/memory/test_openai_conversations_session.py (154 passed)
  • Ruff check and format check passed.
  • Mypy passed for the changed code paths.
  • Manual end-to-end Runner.run reproduction completed successfully with the subclass settings preserved.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-03T10:55:35.804934Z 1cc8917 Manual request
🔒 Security Review Completed 2026-09-03T10:56:28.807411Z 1cc8917 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Hughhhhcoder

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: a4ce73785b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: a4ce73785b

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@sylvesterkaczmarek sylvesterkaczmarek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Accepting any SessionSettings instance also accepts an incompatible sibling subclass. ASettings.resolve(BSettings(...)) will now apply common fields and silently discard B-only fields instead of rejecting the mismatch. Could this allow only base SessionSettings or instances compatible with type(self), and add a sibling-subclass regression?

@Hughhhhcoder

Copy link
Copy Markdown
Contributor Author

Addressed in commit 1cc89176. SessionSettings.resolve now accepts the base SessionSettings type or an instance compatible with the current settings subclass, and raises TypeError for incompatible sibling subclasses instead of silently dropping their fields. Added a sibling-subclass regression test. Validation: 102 related tests passed; Ruff, formatting, mypy, and diff checks passed.

@Hughhhhcoder

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: 1cc89176df

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: 1cc89176df

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@Hughhhhcoder

Copy link
Copy Markdown
Contributor Author

Thanks for catching this. Commit 1cc89176 now accepts the base SessionSettings type or an instance compatible with type(self), and raises TypeError for an incompatible sibling subclass instead of silently discarding its fields. The new regression covers the sibling-subclass case; uv run --locked pytest tests/memory/test_session.py -k session_settings -q passes (11 passed, 44 deselected).

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.

SessionSettings.resolve() raises TypeError when a subclass instance receives a base SessionSettings (or dict) override via RunConfig

2 participants