From 35e5878fefd315293932d0da458a7830a9c30c7e Mon Sep 17 00:00:00 2001 From: Junhyuk Lee Date: Thu, 30 Apr 2026 07:43:34 +0000 Subject: [PATCH 1/4] Advance OSS contribution for Responses API: undocumented reasoning+message pairing constraint breaks multi-turn conversations Nightly Codex produced a focused contribution for https://github.com/openai/openai-python/issues/3009. Constraint: Automated nightly run; keep changes small and reviewable. Confidence: medium Scope-risk: narrow Tested: See uploaded nightly artifacts and workflow logs. Not-tested: Maintainer CI beyond this workflow. --- .codex-nightly-retry-1.md | 13 +++++++++++ NIGHTLY_CODEX_FINAL_ATTEMPT_1.md | 5 ++++ NIGHTLY_CODEX_FINAL_ATTEMPT_2.md | 11 +++++++++ README.md | 29 ++++++++++++++++++++++++ examples/responses/conversation_state.py | 22 ++++++++++++++++++ 5 files changed, 80 insertions(+) create mode 100644 .codex-nightly-retry-1.md create mode 100644 NIGHTLY_CODEX_FINAL_ATTEMPT_1.md create mode 100644 NIGHTLY_CODEX_FINAL_ATTEMPT_2.md create mode 100644 examples/responses/conversation_state.py diff --git a/.codex-nightly-retry-1.md b/.codex-nightly-retry-1.md new file mode 100644 index 0000000000..95d75f4e57 --- /dev/null +++ b/.codex-nightly-retry-1.md @@ -0,0 +1,13 @@ +The previous attempt produced no source, test, docs, or example changes. + +Continue working. A successful nightly slot must produce a small, honest, +maintainer-reviewable PR unless the repository is technically impossible +to patch for this target. + +Requirements for this retry: +- Search the local repository for a directly related patch surface. +- Prefer a focused test, docs/example correction, typing/schema fix, CLI behavior fix, or small error-handling improvement. +- If the exact upstream symptom is server-side, produce a repository-local improvement that prevents user confusion or locks existing behavior without falsely claiming to fix the server. +- Do not stop with only NIGHTLY_REPORT.md. +- Modify at least one tracked source, test, docs, or example file if a defensible PR exists. +- Keep the diff small and explain the rationale in NIGHTLY_REPORT.md. diff --git a/NIGHTLY_CODEX_FINAL_ATTEMPT_1.md b/NIGHTLY_CODEX_FINAL_ATTEMPT_1.md new file mode 100644 index 0000000000..5c745d5574 --- /dev/null +++ b/NIGHTLY_CODEX_FINAL_ATTEMPT_1.md @@ -0,0 +1,5 @@ +Wrote [NIGHTLY_REPORT.md](/home/runner/work/oss-nightly-control/oss-nightly-control/target/NIGHTLY_REPORT.md) and did not change repository code. + +I stopped because the issue already has two active upstream PRs covering the maintainable SDK-side fixes: `#3013` for helper/validation behavior and `#3016` for documentation. A new code/doc PR from this checkout would likely duplicate ongoing review work. + +Tests were not run because no code changed. Current untracked files are `.codex-nightly-prompt.md`, `uv.lock`, and `NIGHTLY_REPORT.md`; I only added the report. \ No newline at end of file diff --git a/NIGHTLY_CODEX_FINAL_ATTEMPT_2.md b/NIGHTLY_CODEX_FINAL_ATTEMPT_2.md new file mode 100644 index 0000000000..97e68a8b81 --- /dev/null +++ b/NIGHTLY_CODEX_FINAL_ATTEMPT_2.md @@ -0,0 +1,11 @@ +Implemented a small, defensible docs/example patch for `openai-python#3009`. + +Changed: +- [README.md](/home/runner/work/oss-nightly-control/oss-nightly-control/target/README.md:47): added a `Conversation state` section showing `previous_response_id` and warning not to filter manual histories down to only messages. +- [examples/responses/conversation_state.py](/home/runner/work/oss-nightly-control/oss-nightly-control/target/examples/responses/conversation_state.py:1): added a minimal two-turn Responses example. +- [NIGHTLY_REPORT.md](/home/runner/work/oss-nightly-control/oss-nightly-control/target/NIGHTLY_REPORT.md:1): updated with rationale, tests, and risks. + +Verified: +- `python -m py_compile examples/responses/conversation_state.py` + +I also checked the current upstream context: issue [#3009](https://github.com/openai/openai-python/issues/3009) is still open, with active related PRs [#3013](https://github.com/openai/openai-python/pull/3013) and [#3016](https://github.com/openai/openai-python/pull/3016), so this patch avoids duplicating their helper/docstring surfaces. \ No newline at end of file diff --git a/README.md b/README.md index 9450c0bc51..fda89c2a5e 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,35 @@ response = client.responses.create( print(response.output_text) ``` +### Conversation state + +For multi-turn conversations with the Responses API, use `previous_response_id` +to have the API retain context between turns. + +```python +from openai import OpenAI + +client = OpenAI() + +response = client.responses.create( + model="gpt-5.2", + input="Write a haiku about recursion in programming.", +) +print(response.output_text) + +response = client.responses.create( + model="gpt-5.2", + input="Now explain it in plain English.", + previous_response_id=response.id, +) +print(response.output_text) +``` + +If you manually manage conversation history instead, preserve all items from +`response.output` in their original order. Reasoning models may return reasoning +items together with assistant messages, and filtering those items down to only +messages can break subsequent requests. + The previous standard (supported indefinitely) for generating text is the [Chat Completions API](https://platform.openai.com/docs/api-reference/chat). You can use that API to generate text from the model with the code below. ```python diff --git a/examples/responses/conversation_state.py b/examples/responses/conversation_state.py new file mode 100644 index 0000000000..d7e7a0cc35 --- /dev/null +++ b/examples/responses/conversation_state.py @@ -0,0 +1,22 @@ +from openai import OpenAI + + +client = OpenAI() + +response = client.responses.create( + model="gpt-5.2", + input="Write a haiku about recursion in programming.", +) +print(response.output_text) + +response = client.responses.create( + model="gpt-5.2", + input="Now explain it in plain English.", + previous_response_id=response.id, +) +print(response.output_text) + +# If you manually manage conversation history instead of using +# previous_response_id, append response.output items in order. Reasoning models +# may return reasoning items together with assistant messages, and filtering +# those items down to only messages can break the next request. From b2ef3280875ea8d42770b5ef725c0286b016d26d Mon Sep 17 00:00:00 2001 From: Junhyuk Lee <58055473+xodn348@users.noreply.github.com> Date: Thu, 30 Apr 2026 11:46:00 -0500 Subject: [PATCH 2/4] Remove nightly runner artifact from PR branch --- NIGHTLY_CODEX_FINAL_ATTEMPT_1.md | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 NIGHTLY_CODEX_FINAL_ATTEMPT_1.md diff --git a/NIGHTLY_CODEX_FINAL_ATTEMPT_1.md b/NIGHTLY_CODEX_FINAL_ATTEMPT_1.md deleted file mode 100644 index 5c745d5574..0000000000 --- a/NIGHTLY_CODEX_FINAL_ATTEMPT_1.md +++ /dev/null @@ -1,5 +0,0 @@ -Wrote [NIGHTLY_REPORT.md](/home/runner/work/oss-nightly-control/oss-nightly-control/target/NIGHTLY_REPORT.md) and did not change repository code. - -I stopped because the issue already has two active upstream PRs covering the maintainable SDK-side fixes: `#3013` for helper/validation behavior and `#3016` for documentation. A new code/doc PR from this checkout would likely duplicate ongoing review work. - -Tests were not run because no code changed. Current untracked files are `.codex-nightly-prompt.md`, `uv.lock`, and `NIGHTLY_REPORT.md`; I only added the report. \ No newline at end of file From 8d96381fd90f4a6e34f2504f8b14bc89e501bfda Mon Sep 17 00:00:00 2001 From: Junhyuk Lee <58055473+xodn348@users.noreply.github.com> Date: Thu, 30 Apr 2026 11:46:14 -0500 Subject: [PATCH 3/4] Remove nightly runner artifact from PR branch --- NIGHTLY_CODEX_FINAL_ATTEMPT_2.md | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 NIGHTLY_CODEX_FINAL_ATTEMPT_2.md diff --git a/NIGHTLY_CODEX_FINAL_ATTEMPT_2.md b/NIGHTLY_CODEX_FINAL_ATTEMPT_2.md deleted file mode 100644 index 97e68a8b81..0000000000 --- a/NIGHTLY_CODEX_FINAL_ATTEMPT_2.md +++ /dev/null @@ -1,11 +0,0 @@ -Implemented a small, defensible docs/example patch for `openai-python#3009`. - -Changed: -- [README.md](/home/runner/work/oss-nightly-control/oss-nightly-control/target/README.md:47): added a `Conversation state` section showing `previous_response_id` and warning not to filter manual histories down to only messages. -- [examples/responses/conversation_state.py](/home/runner/work/oss-nightly-control/oss-nightly-control/target/examples/responses/conversation_state.py:1): added a minimal two-turn Responses example. -- [NIGHTLY_REPORT.md](/home/runner/work/oss-nightly-control/oss-nightly-control/target/NIGHTLY_REPORT.md:1): updated with rationale, tests, and risks. - -Verified: -- `python -m py_compile examples/responses/conversation_state.py` - -I also checked the current upstream context: issue [#3009](https://github.com/openai/openai-python/issues/3009) is still open, with active related PRs [#3013](https://github.com/openai/openai-python/pull/3013) and [#3016](https://github.com/openai/openai-python/pull/3016), so this patch avoids duplicating their helper/docstring surfaces. \ No newline at end of file From 1e3940c90a5e4e6b6611099e56bca934a1cdd300 Mon Sep 17 00:00:00 2001 From: Junhyuk Lee <58055473+xodn348@users.noreply.github.com> Date: Thu, 30 Apr 2026 11:46:15 -0500 Subject: [PATCH 4/4] Remove nightly retry artifact from PR branch --- .codex-nightly-retry-1.md | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 .codex-nightly-retry-1.md diff --git a/.codex-nightly-retry-1.md b/.codex-nightly-retry-1.md deleted file mode 100644 index 95d75f4e57..0000000000 --- a/.codex-nightly-retry-1.md +++ /dev/null @@ -1,13 +0,0 @@ -The previous attempt produced no source, test, docs, or example changes. - -Continue working. A successful nightly slot must produce a small, honest, -maintainer-reviewable PR unless the repository is technically impossible -to patch for this target. - -Requirements for this retry: -- Search the local repository for a directly related patch surface. -- Prefer a focused test, docs/example correction, typing/schema fix, CLI behavior fix, or small error-handling improvement. -- If the exact upstream symptom is server-side, produce a repository-local improvement that prevents user confusion or locks existing behavior without falsely claiming to fix the server. -- Do not stop with only NIGHTLY_REPORT.md. -- Modify at least one tracked source, test, docs, or example file if a defensible PR exists. -- Keep the diff small and explain the rationale in NIGHTLY_REPORT.md.