fix(types): allow missing name on function_call_arguments.done events - #3523
fix(types): allow missing name on function_call_arguments.done events#3523Solaris-star wants to merge 1 commit into
Conversation
Live Responses API streaming may omit `name` on `response.function_call_arguments.done` payloads. The generated model required `name: str`, so strict ResponseStreamEvent union validation failed (and typed access was misleading after lenient construct). Make `name` optional on the responses / beta responses done events and add unit coverage for missing and present values. Fixes openai#3472
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 00c35d5800
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
|
||
| def test_function_call_arguments_done_accepts_missing_name() -> None: | ||
| """Live Responses API may omit `name` on done events (issue #3472).""" | ||
| event = ResponseFunctionCallArgumentsDoneEvent.model_validate(PAYLOAD_WITHOUT_NAME) |
There was a problem hiding this comment.
Use Pydantic-v1-compatible validation in tests
In the pydantic-v1 CI session (noxfile.py installs pydantic<2 and runs the full pytest suite), this new test file fails before exercising the fix: under Pydantic v1 these models do not expose model_validate, and the later union test also calls pydantic.TypeAdapter, which is v2-only. Using the repository's compatibility helpers (or otherwise gating the v2-only union assertion) keeps the tests passing for the supported pydantic>=1.9.0,<3 range.
Useful? React with 👍 / 👎.
|
Nice, this fixes #3472.
|
jbeckwith-oai
left a comment
There was a problem hiding this comment.
Two blockers before this can land:
-
The new test module breaks the supported Pydantic v1 test matrix. Under
pydantic==1.10.26, all four tests fail becauseBaseModel.model_validateandpydantic.TypeAdapterare v2-only APIs. The production model change itself validates correctly on v1; please express these tests through the repository compatibility helpers (for exampleopenai._compat.model_parsefor models andopenai._models.validate_typefor the union) so the behavior is exercised on both supported Pydantic generations rather than skipping v1. -
The normal lint gate is red.
./scripts/lintreports an unsorted import block and an unusedpytestimport intests/test_response_function_call_arguments_done_event.py;ruff format --checkalso says that file needs formatting. Please run the repo formatter/linter and commit the result.
Summary
response.function_call_arguments.donewithout anamefield.name: str, so strictResponseStreamEventunion validation failed (missing: name) and typed access was misleading after lenient construction.nameoptional on the responses + beta responses done events; keep present values working.nameand for union validation.Fixes #3472
Test plan
pytest tests/test_response_function_call_arguments_done_event.py -o addopts=→ 4 passed