-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add support for previous_response_id from Responses API
#2756
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
DouweM
merged 20 commits into
pydantic:main
from
GDaamn:feat/add-support-previous_response_id
Sep 12, 2025
Merged
Changes from 19 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
485a1c4
add support for previous_response_id from Responses API
GDaamn 0027f6c
update link
GDaamn 22eefe9
update logic and docs
GDaamn 68da416
update import in test
GDaamn 51b1f0a
fix test
GDaamn 9f7736b
add fixes for types
GDaamn a0468ad
Update docs
GDaamn e7d904b
update conditional check
GDaamn dee583d
update conditional check
GDaamn 09f4f8d
update tests and docs
GDaamn 29f453d
clean-up
GDaamn 85d96a7
update logic
GDaamn f6c5520
clean-up
GDaamn fc9cb25
clean-up
GDaamn 23f174e
update docs
GDaamn b1aba38
update docstring
GDaamn 9779c74
update function signature
GDaamn ff81726
update docstring
GDaamn 40ba00d
update code comments in docs
GDaamn cf19b2b
Update docs/models/openai.md
DouweM File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
131 changes: 131 additions & 0 deletions
131
tests/models/cassettes/test_openai_responses/test_openai_previous_response_id.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,131 @@ | ||
| interactions: | ||
| - request: | ||
| headers: | ||
| accept: | ||
| - application/json | ||
| accept-encoding: | ||
| - gzip, deflate | ||
| connection: | ||
| - keep-alive | ||
| content-type: | ||
| - application/json | ||
| host: | ||
| - api.openai.com | ||
| method: POST | ||
| parsed_body: | ||
| input: | ||
| - content: The secret key is sesame | ||
| role: user | ||
| instructions: '' | ||
| model: gpt-5 | ||
| text: | ||
| format: | ||
| type: text | ||
| uri: https://api.openai.com/v1/responses | ||
| response: | ||
| headers: | ||
| content-type: | ||
| - application/json | ||
| parsed_body: | ||
| created_at: 1743075629 | ||
| error: null | ||
| id: resp_1234 | ||
| incomplete_details: null | ||
| instructions: '' | ||
| max_output_tokens: null | ||
| metadata: {} | ||
| model: gpt-5 | ||
| object: response | ||
| output: | ||
| - content: | ||
| - annotations: [] | ||
| text: "Open sesame! What would you like to unlock?" | ||
| type: output_text | ||
| id: msg_test_previous_response_id | ||
| role: assistant | ||
| status: completed | ||
| type: message | ||
| parallel_tool_calls: true | ||
| previous_response_id: null | ||
| reasoning: null | ||
| status: complete | ||
| status_details: null | ||
| tool_calls: null | ||
| total_tokens: 15 | ||
| usage: | ||
| input_tokens: 10 | ||
| input_tokens_details: | ||
| cached_tokens: 0 | ||
| output_tokens: 1 | ||
| output_tokens_details: | ||
| reasoning_tokens: 0 | ||
| total_tokens: 11 | ||
| status: | ||
| code: 200 | ||
| message: OK | ||
| - request: | ||
| headers: | ||
| accept: | ||
| - application/json | ||
| accept-encoding: | ||
| - gzip, deflate | ||
| connection: | ||
| - keep-alive | ||
| content-type: | ||
| - application/json | ||
| host: | ||
| - api.openai.com | ||
| method: POST | ||
| parsed_body: | ||
| input: | ||
| - content: What is the secret key again? | ||
| role: user | ||
| instructions: '' | ||
| model: gpt-5 | ||
| text: | ||
| format: | ||
| type: text | ||
| previous_response_id: resp_1234 | ||
| uri: https://api.openai.com/v1/responses | ||
| response: | ||
| headers: | ||
| content-type: | ||
| - application/json | ||
| parsed_body: | ||
| created_at: 1743075630 | ||
| error: null | ||
| id: resp_5678 | ||
| incomplete_details: null | ||
| instructions: '' | ||
| max_output_tokens: null | ||
| metadata: {} | ||
| model: gpt-5 | ||
| object: response | ||
| output: | ||
| - content: | ||
| - annotations: [] | ||
| text: "sesame" | ||
| type: output_text | ||
| id: msg_test_previous_response_id | ||
| role: assistant | ||
| status: completed | ||
| type: message | ||
| parallel_tool_calls: true | ||
| previous_response_id: resp_1234 | ||
| reasoning: null | ||
| status: complete | ||
| status_details: null | ||
| tool_calls: null | ||
| total_tokens: 15 | ||
| usage: | ||
| input_tokens: 10 | ||
| input_tokens_details: | ||
| cached_tokens: 0 | ||
| output_tokens: 1 | ||
| output_tokens_details: | ||
| reasoning_tokens: 0 | ||
| total_tokens: 11 | ||
| status: | ||
| code: 200 | ||
| message: OK | ||
| version: 1 |
67 changes: 67 additions & 0 deletions
67
tests/models/cassettes/test_openai_responses/test_openai_previous_response_id_auto_mode.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| interactions: | ||
| - request: | ||
| headers: | ||
| accept: | ||
| - application/json | ||
| accept-encoding: | ||
| - gzip, deflate | ||
| connection: | ||
| - keep-alive | ||
| content-type: | ||
| - application/json | ||
| host: | ||
| - api.openai.com | ||
| method: POST | ||
| parsed_body: | ||
| input: | ||
| - content: What is the first secret key? | ||
| role: user | ||
| instructions: '' | ||
| model: gpt-5 | ||
| text: | ||
| format: | ||
| type: text | ||
| previous_response_id: resp_68b9bda81f5c8197a5a51a20a9f4150a000497db2a4c777b | ||
| uri: https://api.openai.com/v1/responses | ||
| response: | ||
| headers: | ||
| content-type: | ||
| - application/json | ||
| parsed_body: | ||
| created_at: 1743075630 | ||
| error: null | ||
| id: resp_a4168b9bda81f5c8197a5a51a20a9f4150a000497db2a4c5 | ||
| incomplete_details: null | ||
| instructions: '' | ||
| max_output_tokens: null | ||
| metadata: {} | ||
| model: gpt-5 | ||
| object: response | ||
| output: | ||
| - content: | ||
| - annotations: [] | ||
| text: "sesame" | ||
| type: output_text | ||
| id: msg_test_previous_response_id_auto | ||
| role: assistant | ||
| status: completed | ||
| type: message | ||
| parallel_tool_calls: true | ||
| previous_response_id: resp_68b9bda81f5c8197a5a51a20a9f4150a000497db2a4c777b | ||
| reasoning: null | ||
| status: complete | ||
| status_details: null | ||
| tool_calls: null | ||
| total_tokens: 15 | ||
| usage: | ||
| input_tokens: 10 | ||
| input_tokens_details: | ||
| cached_tokens: 0 | ||
| output_tokens: 1 | ||
| output_tokens_details: | ||
| reasoning_tokens: 0 | ||
| total_tokens: 11 | ||
| status: | ||
| code: 200 | ||
| message: OK | ||
| version: 1 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.