Skip to content

fix: normalize compacted Responses user inputs before session reuse#2925

Merged
seratch merged 2 commits intomainfrom
fix/normalize-compacted-user-inputs
Apr 17, 2026
Merged

fix: normalize compacted Responses user inputs before session reuse#2925
seratch merged 2 commits intomainfrom
fix/normalize-compacted-user-inputs

Conversation

@seratch
Copy link
Copy Markdown
Member

@seratch seratch commented Apr 17, 2026

This pull request fixes replay safety for compacted Responses user messages in OpenAIResponsesCompactionSession.

When responses.compact() returns user input_image or input_file content with null alternatives such as file_id: null, the SDK was previously storing that shape back into session history unchanged. That left the next responses.create call dependent on server tolerance for contract-invalid null combinations and also meant a normalization failure could clear the underlying session before replacement succeeded.

This change normalizes compacted user image and file inputs into replay-safe shapes before they are written back to the session, keeping only valid source fields such as image_url, file_id, file_url, or file_data as appropriate. It also defers clearing the underlying session until normalization succeeds so malformed compacted output does not erase existing history. The update includes regression coverage for compacted image normalization, compacted file normalization, and the failure path that preserves prior session items.

see also: openai/openai-agents-js#1181

@seratch seratch added this to the 0.14.x milestone Apr 17, 2026
@github-actions github-actions bot added bug Something isn't working feature:sessions labels Apr 17, 2026
@seratch seratch merged commit f84ef7f into main Apr 17, 2026
9 checks passed
@seratch seratch deleted the fix/normalize-compacted-user-inputs branch April 17, 2026 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working feature:sessions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant