Skip to content

fix: preserve response input message roundtrips - #954

Open
SiluPanda wants to merge 1 commit into
openai:mainfrom
SiluPanda:fix/response-input-item-default-type
Open

fix: preserve response input message roundtrips#954
SiluPanda wants to merge 1 commit into
openai:mainfrom
SiluPanda:fix/response-input-item-default-type

Conversation

@SiluPanda

Copy link
Copy Markdown

Closes #584.

ResponseInputItem.Message.Builder left its documented constant type unset, so serializing a user-built message omitted the union discriminator and deserializing it produced _unknown. EasyInputMessage.Builder had the same missing default.

This change:

  • defaults both message builders to type: "message"
  • makes structured, non-assistant message JSON without phase deserialize to the narrower ResponseInputItem.Message variant
  • preserves EasyInputMessage preference for string content, assistant roles, phase-bearing messages, missing roles, and unknown/future roles
  • adds roundtrip and discriminator-boundary coverage

The tie-break is necessary because a structured EasyInputMessage and Message with a user, system, or developer role and no phase are wire-identical. The new test documents Message as the canonical branch for that shape rather than leaving the choice implicit.

Validation

  • ./gradlew :openai-java-core:test --tests com.openai.models.responses.ResponseInputItemTest --tests com.openai.models.responses.EasyInputMessageTest :openai-java-core:lintKotlin --console=plain
    • ResponseInputItemTest: 73 tests, 0 failures
    • EasyInputMessageTest: 2 tests, 0 failures
    • Kotlin lint passed
  • authoritative local Castiron budget check against current main: 1,735 / 2,000 custom lines, with budget isolation and budget checks both passing
  • git diff --check

Security review note

This touches Jackson polymorphic deserialization. The added dispatch condition only examines the already-parsed type, role, content shape, and phase presence; it adds no I/O, recursion, payload limit, or credential/logging behavior. Exact known input roles are required before changing the existing ordering, so malformed, missing, and future roles retain the current EasyInputMessage-first path.

AI assistance: I used Codex to help investigate the generated union behavior, draft the implementation and tests, and run validation. I reviewed the resulting code, the ambiguity tradeoff, and the test output.

@SiluPanda
SiluPanda requested a review from a team as a code owner August 30, 2026 12:49
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 30, 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-08-30T12:52:26.555724Z c04f0c7 PR opened
🔒 Security Review Completed 2026-08-30T12:53:04.748025Z c04f0c7 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.

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.

Deserializing ResponseInputItem results in unknown state

1 participant