Skip to content

fix(sessions): reset compaction state on clear - #4865

Open
sylvesterkaczmarek wants to merge 1 commit into
openai:mainfrom
sylvesterkaczmarek:fix/compaction-clear-response-state
Open

fix(sessions): reset compaction state on clear#4865
sylvesterkaczmarek wants to merge 1 commit into
openai:mainfrom
sylvesterkaczmarek:fix/compaction-clear-response-state

Conversation

@sylvesterkaczmarek

Copy link
Copy Markdown
Contributor

Summary

Reset retained response-chain state after OpenAIResponsesCompactionSession.clear_session() successfully clears the underlying history.

The wrapper previously reset cached session items and _deferred_response_id, but retained _response_id and _last_unstored_response_id. A later previous_response_id compaction could therefore reuse a response chain belonging to history the caller explicitly erased.

A successful clear now resets all three response-chain fields alongside the history caches. The reset occurs only after the underlying clear succeeds, preserving existing state if the backend clear fails.

Test plan

  • Added a regression proving a pre-clear response ID cannot be reused by a later previous_response_id compaction.
  • uv run pytest -q tests/memory/test_openai_responses_compaction_session.py — 56 passed.
  • Ruff check/format — passed.
  • Targeted mypy — passed.
  • Targeted Pyright — 0 errors, 0 warnings.
  • git diff --check — passed.
  • Repository-wide verification was also attempted: lint passed and the test run reached 7,513 passed / 69 skipped before unrelated existing optional-integration, voice, sandbox, and release-contract environment failures.

Fixes #4864.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 4, 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-04T18:24:52.669918Z c7c762f PR opened
🔒 Security Review Completed 2026-09-04T18:25:37.423078Z c7c762f PR opened
ℹ️ 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.

@seratch seratch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you resolve the conflicts?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clearing a compaction session retains the previous response chain

2 participants