Nullable Responses request fields can crash the local server
Summary
ResponsesRequest declares several fields as optional, but the local Responses API server later treats some of them as concrete values. Explicit JSON null therefore validates and can fail at runtime.
Three concrete paths are affected:
metadata=Nonevalidates, thenStreamResponsesEvents.__init__()callsrequest_body.metadata.get(...).tools=Nonevalidates. Ifinstructionsis non-empty, the server entersif body.instructions or body.tools:and then iteratesfor tool in body.tools.max_output_tokens=Nonevalidates, then the generation loop compareslen(self.output_tokens) >= self.request_body.max_output_tokens.
The official OpenAI Python Responses request types also expose these parameters as optional, so explicit nullable values are part of the client-side contract rather than malformed Python objects.
Impact
Requests that pass validation can fail later with AttributeError or TypeError instead of being processed with the server's existing defaults/empty values.
Proposed resolution
Normalize the nullable fields at the ResponsesRequest model boundary:
metadata=None->{}tools=None->[]max_output_tokens=None->DEFAULT_MAX_OUTPUT_TOKENS
This lets the rest of the server keep its existing concrete-value assumptions while preserving accepted nullable request input.
Add model-level regressions for all three explicit-None cases.
Source: openai/gpt-oss