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 👍 / 👎.
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