You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Clearing a compaction session retains the previous response chain #4864
OpenAIResponsesCompactionSession.clear_session() clears the underlying history and cached compaction items, and resets _deferred_response_id, but it leaves _response_id and _last_unstored_response_id unchanged.
As a result, later compaction can reuse response-chain state from history the caller explicitly cleared. In previous_response_id mode, a stale response ID can still be sent to responses.compact after the session is empty.
On current main, the second call proceeds instead of raising that no response ID is available for the cleared session. A focused regression reaches the mocked compact client after the clear.
Expected behavior
A successful clear_session() should reset all response-chain state owned by the wrapper: _response_id, _deferred_response_id, and _last_unstored_response_id, in addition to the cached history.
After clear, explicit previous_response_id compaction without a newly supplied response ID should fail before any client call. If the underlying clear fails, response-chain state should remain unchanged because the old history may still exist.
I implemented and tested a focused fix on the published fork branch fix/issue-4864-clear-response-chain, commit ce343f0. It clears _response_id, _deferred_response_id, and _last_unstored_response_id after a successful clear, preserves them if the underlying clear fails, and adds regression tests. The focused compaction test file passes (66 tests), plus Ruff, mypy, and pyright for the changed file.
Thanks for validating the same fix shape. There is already an open implementation PR for this issue, #4865, covering the response-chain reset and regressions. To avoid duplicate implementation/review work, please consolidate any follow-up there rather than opening a second PR.
Fixed on main by #5000, which superseded #4865. Clearing now invalidates all response-chain state, including after uncertain backend outcomes. The fix is not yet included in v0.22.3. Closing this as resolved; until a release includes it, recreating the compaction wrapper after a successful clear avoids retaining the old chain.
Activity
Neonstudio28 commentedon Sep 11, 2026
I implemented and tested a focused fix on the published fork branch
fix/issue-4864-clear-response-chain, commitce343f0. It clears_response_id,_deferred_response_id, and_last_unstored_response_idafter a successful clear, preserves them if the underlying clear fails, and adds regression tests. The focused compaction test file passes (66 tests), plus Ruff, mypy, and pyright for the changed file.sylvesterkaczmarek commentedon Sep 11, 2026
Thanks for validating the same fix shape. There is already an open implementation PR for this issue, #4865, covering the response-chain reset and regressions. To avoid duplicate implementation/review work, please consolidate any follow-up there rather than opening a second PR.
jbeckwith-oai commentedon Sep 28, 2026
Fixed on main by #5000, which superseded #4865. Clearing now invalidates all response-chain state, including after uncertain backend outcomes. The fix is not yet included in v0.22.3. Closing this as resolved; until a release includes it, recreating the compaction wrapper after a successful clear avoids retaining the old chain.