I am using the library not only to talk to open ai, but also to talk to azure ai agents that fully support the responses api. It looks like azure ai skips empty attributes in their response and openai does not. This causes problems in some classes where the code tries to access the array index of optional attribute without checking if it exists:
- Example - WebSearchUserLocation.php:
The constructor shows that "city" is optional:
public readonly ?string $city
But in public static function from() the acces to it is not checked:
city: $attributes['city'],
Much better would be this:
city: $attributes['city'] ?? null,
- Example - OutputMcpCall.php:
The construtor shows that "approvalRequestId" is optional:
public readonly ?string $approvalRequestId = null,
But the same in public static function from():
approvalRequestId: $attributes['approval_request_id'],
While this would be much better:
approvalRequestId: $attributes['approval_request_id'] ?? null,
I am not sure if you are generating this could automatically. If not I could start making pull request for all those cases where I run into a problem. Should I do that?
I am using the library not only to talk to open ai, but also to talk to azure ai agents that fully support the responses api. It looks like azure ai skips empty attributes in their response and openai does not. This causes problems in some classes where the code tries to access the array index of optional attribute without checking if it exists:
The constructor shows that "city" is optional:
public readonly ?string $cityBut in public static function from() the acces to it is not checked:
city: $attributes['city'],Much better would be this:
city: $attributes['city'] ?? null,The construtor shows that "approvalRequestId" is optional:
public readonly ?string $approvalRequestId = null,But the same in public static function from():
approvalRequestId: $attributes['approval_request_id'],While this would be much better:
approvalRequestId: $attributes['approval_request_id'] ?? null,I am not sure if you are generating this could automatically. If not I could start making pull request for all those cases where I run into a problem. Should I do that?