Skip to content

fix: restore session history when responses compaction replacement fails#1265

Merged
seratch merged 2 commits intomainfrom
fix/compaction-session-restore
May 7, 2026
Merged

fix: restore session history when responses compaction replacement fails#1265
seratch merged 2 commits intomainfrom
fix/compaction-session-restore

Conversation

@seratch
Copy link
Copy Markdown
Member

@seratch seratch commented May 7, 2026

This pull request fixes a data-loss edge case in OpenAIResponsesCompactionSession when replacing stored history after responses.compact.

The previous flow cleared the underlying session before writing compacted output, so a failing addItems() call could leave the session empty or partially replaced. The new flow snapshots the previous session items, restores them when replacement fails, and preserves the original replacement error when restore itself fails.

This mirrors the safety fix from the Python SDK: openai/openai-agents-python#3117

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 7, 2026

🦋 Changeset detected

Latest commit: 06e3083

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@openai/agents-openai Patch
@openai/agents Patch
@openai/agents-core Patch
@openai/agents-realtime Patch
@openai/agents-extensions Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions Bot added this to the 0.9.x milestone May 7, 2026
@seratch seratch modified the milestones: 0.9.x, 0.10.x May 7, 2026
@openai openai deleted a comment from chatgpt-codex-connector Bot May 7, 2026
@seratch seratch force-pushed the fix/compaction-session-restore branch from 181df4d to d389190 Compare May 7, 2026 06:02
@seratch
Copy link
Copy Markdown
Member Author

seratch commented May 7, 2026

@codex review

@openai openai deleted a comment from chatgpt-codex-connector Bot May 7, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d3891907d5

ℹ️ 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".

@seratch seratch merged commit 4dc2614 into main May 7, 2026
7 checks passed
@seratch seratch deleted the fix/compaction-session-restore branch May 7, 2026 06:30
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.

1 participant